/* ==========================================================================
   UBU Auto Check-in — Dual-Theme Multi-User SaaS Dashboard Stylesheet
   Themes: OLED Dark (#020617 / #0E1223) + Crisp Swiss Light (#F8FAFC / #FFFFFF)
   Design System: design-system/ubu-auto-checkin/MASTER.md
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg: #F8FAFC;
  --card: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --sidebar-bg: #FFFFFF;
  --topbar-bg: rgba(255, 255, 255, 0.9);
  --muted: #F1F5F9;
  --muted-hover: #E2E8F0;

  --fg: #0F172A;
  --heading: #0F172A;
  --muted-fg: #475569;

  --border: #CBD5E1;
  --border-subtle: #E2E8F0;

  --primary: #1D4ED8;
  --primary-hover: #1E40AF;
  --primary-btn-bg: #1D4ED8;
  --primary-btn-hover: #1E40AF;
  --on-primary: #FFFFFF;

  --accent: #16A34A;
  --accent-text: #15803D;
  --on-accent: #FFFFFF;

  --success: #166534;
  --success-bg: #DCFCE7;
  --success-border: #86EFAC;

  --warning: #92400E;
  --warning-bg: #FEF3C7;
  --warning-border: #FCD34D;

  --destructive: #B91C1C;
  --destructive-btn-bg: #DC2626;
  --destructive-btn-hover: #B91C1C;
  --destructive-bg: #FEE2E2;
  --destructive-border: #FCA5A5;

  --info: #1E40AF;
  --info-bg: #DBEAFE;
  --info-border: #93C5FD;

  --focus-ring-color: #1D4ED8;
  --focus-ring-soft: rgba(29, 78, 216, 0.18);

  --terminal-bg: #020617;
  --terminal-fg: #E2E8F0;
  --terminal-border: #1E293B;

  --scrim: rgba(15, 23, 42, 0.52);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 36px rgba(15, 23, 42, 0.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --sidebar-width: 248px;
  --topbar-height: 60px;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --font-sans: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #020617;
  --card: #0E1223;
  --surface-elevated: #141A30;
  --sidebar-bg: #080C1A;
  --topbar-bg: rgba(8, 12, 26, 0.88);
  --muted: #1A1E2F;
  --muted-hover: #232A42;

  --fg: #F8FAFC;
  --heading: #F8FAFC;
  --muted-fg: #94A3B8;

  --border: #334155;
  --border-subtle: #1E293B;

  --primary: #3B82F6;
  --primary-hover: #60A5FA;
  --primary-btn-bg: #2563EB;
  --primary-btn-hover: #1D4ED8;
  --on-primary: #FFFFFF;

  --accent: #22C55E;
  --accent-text: #4ADE80;
  --on-accent: #020617;

  --success: #4ADE80;
  --success-bg: rgba(22, 163, 74, 0.18);
  --success-border: rgba(74, 222, 128, 0.36);

  --warning: #FBBF24;
  --warning-bg: rgba(217, 119, 6, 0.2);
  --warning-border: rgba(251, 191, 36, 0.4);

  --destructive: #FCA5A5;
  --destructive-btn-bg: #DC2626;
  --destructive-btn-hover: #B91C1C;
  --destructive-bg: rgba(220, 38, 38, 0.2);
  --destructive-border: rgba(248, 113, 113, 0.42);

  --info: #93C5FD;
  --info-bg: rgba(59, 130, 246, 0.2);
  --info-border: rgba(96, 165, 250, 0.4);

  --focus-ring-color: #60A5FA;
  --focus-ring-soft: rgba(96, 165, 250, 0.25);

  --terminal-bg: #020617;
  --terminal-fg: #E2E8F0;
  --terminal-border: #334155;

  --scrim: rgba(2, 6, 23, 0.72);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.65);

  color-scheme: dark;
}

/* ==========================================================================
   Base Reset & WCAG 2.2 Defaults
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-padding-top: calc(var(--topbar-height) + 16px);
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--fg);
  background-color: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

body.modal-open,
body.drawer-open {
  overflow: hidden;
}

h1, h2, h3, h4, p, dl, dd, dt, ul, ol, pre {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.tabular-nums {
  font-variant-numeric: tabular-nums;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background-color: var(--primary-btn-bg);
  color: var(--on-primary);
  padding: 10px 16px;
  font-weight: 600;
  z-index: 300;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Auth Gate Shell (Unauthenticated Split Card)
   ========================================================================== */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background-color: var(--bg);
}

[data-theme="dark"] .auth-shell {
  background-image:
    radial-gradient(640px circle at 15% 10%, rgba(34, 197, 94, 0.08), transparent 60%),
    radial-gradient(720px circle at 88% 85%, rgba(59, 130, 246, 0.1), transparent 60%);
}

.auth-topbar {
  width: 100%;
  max-width: 980px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}

.auth-tz-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-fg);
}

.auth-center {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 0 28px;
}

.auth-split-card {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-hero {
  padding: 36px 34px;
  background-color: var(--muted);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}

[data-theme="dark"] .auth-hero {
  background: linear-gradient(155deg, #0B1228 0%, #0E1223 55%, #091820 100%);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--primary-btn-bg);
  color: var(--on-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-mark-lg {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
}

.auth-brand-title {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
}

.auth-brand-sub {
  font-size: 12.5px;
  color: var(--muted-fg);
}

.auth-hero-heading {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--heading);
  text-wrap: balance;
}

.auth-hero-copy {
  font-size: 14px;
  color: var(--muted-fg);
  line-height: 1.6;
}

.auth-feature-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

.auth-feature-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.auth-feature-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
  color: var(--accent-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.auth-feature-item strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 2px;
}

.auth-feature-item span {
  display: block;
  font-size: 12.5px;
  color: var(--muted-fg);
  line-height: 1.45;
}

.auth-form-pane {
  padding: 36px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: var(--card);
}

.auth-state {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-loading-box {
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--muted-fg);
  font-size: 14px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.3;
}

.auth-desc {
  font-size: 14px;
  color: var(--muted-fg);
  line-height: 1.55;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-welcome-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.45;
}

.auth-welcome-banner svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.account-chip-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background-color: var(--muted);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.account-chip-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account-chip-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.account-chip-text strong {
  font-size: 14px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background-color: var(--primary-btn-bg);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.cli-command-box {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--terminal-bg);
  overflow: hidden;
}

.cli-command-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--terminal-border);
  background-color: rgba(255, 255, 255, 0.03);
}

.cli-command-label {
  font-size: 12px;
  font-weight: 600;
  color: #94A3B8;
}

.cli-command-pre {
  padding: 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #4ADE80;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.auth-actions-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==========================================================================
   App Shell: Fixed Left Sidebar (248px) + Slim Sticky Topbar (60px)
   ========================================================================== */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: var(--scrim);
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 70;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform 220ms ease;
}

.sidebar-header {
  height: var(--topbar-height);
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.02em;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-daemon-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted-fg);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn.sidebar-close-btn {
  display: none;
}

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-label {
  padding: 0 10px 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted-fg);
}

.sidebar-nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-fg);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.sidebar-nav-item svg {
  flex-shrink: 0;
}

.sidebar-nav-item:hover {
  background-color: var(--muted);
  color: var(--fg);
}

.sidebar-nav-item.is-active {
  background-color: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
  background-color: var(--sidebar-bg);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--muted);
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.sidebar-user-meta {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar-user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Workspace Right Side */
.app-workspace {
  flex: 1 1 auto;
  margin-left: var(--sidebar-width);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  padding: 0 24px;
  background-color: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.icon-btn.mobile-menu-btn {
  display: none;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-utils {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.clock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--muted);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--muted-fg);
  white-space: nowrap;
}

.clock-badge time {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--fg);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--fg);
  flex-shrink: 0;
  transition: background-color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover {
  background-color: var(--muted);
}

.workspace-main {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.mt-section {
  margin-top: 24px;
}

.mt-form {
  margin-top: 18px;
}

/* ==========================================================================
   Context Bar & Alert Banners
   ========================================================================== */
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  background-color: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.context-bar-left,
.context-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.context-bar-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}

.context-select {
  min-width: 220px;
}

.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.5;
  flex-wrap: wrap;
}

.alert-banner-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1 1 240px;
}

.alert-banner-body svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}

.alert-destructive {
  background-color: var(--destructive-bg);
  border-color: var(--destructive-border);
  color: var(--destructive);
}

.info-callout {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
  font-size: 13px;
  line-height: 1.5;
}

.info-callout svg {
  flex-shrink: 0;
  margin-top: 2px;
}

/* ==========================================================================
   KPI Bento Grid
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms ease, background-color 160ms ease;
}

.kpi-interactive {
  cursor: pointer;
}

.kpi-interactive:hover {
  border-color: var(--primary);
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-fg);
}

.kpi-icon {
  color: var(--muted-fg);
  flex-shrink: 0;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  color: var(--heading);
}

.kpi-badge-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.kpi-sub {
  font-size: 12.5px;
  color: var(--muted-fg);
  line-height: 1.4;
}

/* ==========================================================================
   Toolbars, Filters & Search
   ========================================================================== */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.users-toolbar-left {
  flex: 1 1 360px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.01em;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: var(--muted);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted-fg);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.filter-chip:hover {
  color: var(--fg);
}

.filter-chip.is-active {
  background-color: var(--card);
  color: var(--heading);
  border-color: var(--border);
  font-weight: 600;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 220px;
  flex: 0 1 280px;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--muted-fg);
  pointer-events: none;
}

.search-input {
  width: 100% !important;
  padding-left: 34px !important;
  min-height: 36px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn-sm {
  padding: 5px 11px;
  min-height: 34px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--primary-btn-bg);
  color: var(--on-primary);
  border-color: var(--primary-btn-bg);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-btn-hover);
  border-color: var(--primary-btn-hover);
}

.btn-secondary {
  background-color: var(--card);
  color: var(--fg);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--muted);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--info-bg);
}

.btn-destructive {
  background-color: var(--destructive-btn-bg);
  color: #FFFFFF;
  border-color: var(--destructive-btn-bg);
}

.btn-destructive:hover:not(:disabled) {
  background-color: var(--destructive-btn-hover);
  border-color: var(--destructive-btn-hover);
}

.btn-ghost-danger {
  background-color: transparent;
  color: var(--destructive);
  border-color: var(--border);
}

.btn-ghost-danger:hover:not(:disabled) {
  background-color: var(--destructive-bg);
  border-color: var(--destructive-border);
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-neutral {
  background-color: var(--muted);
  color: var(--muted-fg);
  border-color: var(--border-subtle);
}

.badge-success {
  background-color: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

.badge-warning {
  background-color: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning-border);
}

.badge-destructive {
  background-color: var(--destructive-bg);
  color: var(--destructive);
  border-color: var(--destructive-border);
}

.badge-info {
  background-color: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

.badge-btn {
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.badge-btn:hover {
  border-color: var(--primary);
  background-color: var(--info-bg);
  color: var(--info);
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ==========================================================================
   Courses Grid & Cards
   ========================================================================== */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.course-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 160ms ease;
}

.course-card:hover {
  border-color: var(--primary);
}

.course-card.is-paused {
  border-left: 3px solid var(--warning);
}

.course-card.is-ended {
  border-left: 3px solid var(--muted-fg);
  opacity: 0.86;
}

.course-card-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.course-name-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.course-index {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-fg);
  flex-shrink: 0;
}

.course-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.35;
  word-break: break-word;
}

.course-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--fg);
  background-color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.course-ext-link:hover {
  text-decoration: none;
  border-color: var(--primary);
  background-color: var(--info-bg);
  color: var(--info);
}

.course-card-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.course-detail-grid {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 8px 12px;
  font-size: 14px;
}

.course-detail-grid dt {
  color: var(--muted-fg);
  font-weight: 500;
}

.course-detail-grid dd {
  color: var(--fg);
  min-width: 0;
  word-break: break-word;
}

.window-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.window-chip {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  background-color: var(--info-bg);
  color: var(--info);
  border-radius: 4px;
  white-space: nowrap;
}

.sessions-block {
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.sessions-heading {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 6px;
}

.sessions-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 6px 9px;
  border-radius: 6px;
  background-color: var(--muted);
  flex-wrap: wrap;
}

.session-item--ignored {
  opacity: 0.72;
  border: 1px dashed var(--border);
  background-color: transparent;
}

.session-no {
  font-weight: 600;
  color: var(--heading);
  flex-shrink: 0;
}

.session-item--ignored .session-no,
.session-item--ignored .session-label {
  color: var(--muted-fg);
}

.session-main {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

.session-label {
  color: var(--fg);
  text-align: right;
  word-break: break-word;
}

.sessions-ignore-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted-fg);
  line-height: 1.45;
}

.schedule-mismatch-hint {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--warning-border);
  background-color: var(--warning-bg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.schedule-mismatch-text {
  margin: 0;
  font-size: 13px;
  color: var(--warning);
  line-height: 1.5;
}

.course-card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.course-rand-code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-fg);
}

.course-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.empty-state {
  grid-column: 1 / -1;
  background-color: var(--card);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted-fg);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.empty-desc {
  font-size: 14px;
  color: var(--muted-fg);
  max-width: 440px;
}

/* ==========================================================================
   Panel Cards & Data Tables
   ========================================================================== */
.panel-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* One-Click Telegram Deep-Link Card */
.tg-connect-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--muted);
}

.tg-connect-copy {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1 1 260px;
  min-width: 0;
}

.tg-connect-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background-color: var(--info-bg);
  border: 1px solid var(--info-border);
  color: var(--info);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tg-connected-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--success-border);
  background-color: var(--success-bg);
}

.tg-connected-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.tg-connected-icon {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background-color: var(--card);
  border: 1px solid var(--success-border);
  color: var(--success);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tg-connected-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.tg-connected-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tg-box-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--heading);
  line-height: 1.35;
}

.tg-box-desc {
  font-size: 13px;
  color: var(--muted-fg);
  line-height: 1.5;
  margin-top: 2px;
}

.tg-connected-box .tg-box-title {
  color: var(--success);
}

.tg-connected-box .tg-box-desc {
  color: var(--fg);
  margin-top: 0;
}

.tg-connected-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tg-linking-status {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--info-border);
  background-color: var(--info-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tg-linking-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tg-linking-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tg-linking-copy strong {
  font-size: 14px;
  color: var(--info);
}

.tg-linking-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.tg-deep-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--info);
  text-decoration: underline;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
  flex-shrink: 0;
}

.tg-manual-body {
  margin-top: 14px;
}

#tg-manual-details[open] > .guide-summary svg {
  transform: rotate(90deg);
}

#tg-manual-details > .guide-summary svg {
  transition: transform 150ms ease;
}

.panel-card-body {
  padding: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--heading);
}

.card-subtitle {
  font-size: 13px;
  color: var(--muted-fg);
  margin-top: 2px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

.data-table th {
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-fg);
  background-color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background-color: var(--muted);
}

.table-empty {
  text-align: center;
  color: var(--muted-fg);
  padding: 28px 16px !important;
}

.mono-cell {
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 170px;
}

.user-cell-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-cell-name {
  font-weight: 600;
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Forms, Inputs, Field Errors & Switches
   ========================================================================== */
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.form-grid-flush {
  padding: 0;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field-full {
  grid-column: 1 / -1;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.req-mark {
  color: var(--destructive);
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.4;
  min-height: 42px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-input:focus {
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 3px var(--focus-ring-soft);
  outline: none;
}

.form-input[aria-invalid="true"] {
  border-color: var(--destructive);
}

.form-input[readonly] {
  background-color: var(--muted);
  color: var(--muted-fg);
}

.form-input-sm {
  min-height: 36px;
  padding: 5px 10px;
  font-size: 13px;
  width: auto;
}

.mono-input {
  font-family: var(--font-mono);
  font-size: 13px;
}

.form-help {
  font-size: 12.5px;
  color: var(--muted-fg);
  line-height: 1.45;
}

.form-help.is-valid {
  color: var(--success);
}

.form-help.is-error {
  color: var(--destructive);
}

.field-error {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--destructive);
  line-height: 1.4;
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-action .form-input {
  padding-right: 44px;
}

.input-eye-btn {
  position: absolute;
  right: 5px;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, color 150ms ease;
}

.input-eye-btn:hover {
  color: var(--fg);
  background-color: var(--muted);
}

/* Accessible Switch */
.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--muted);
}

.switch-row-compact {
  padding: 10px 12px;
}

.switch-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background-color: var(--border);
  flex-shrink: 0;
  margin-top: 2px;
  transition: background-color 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #FFFFFF;
  transition: transform 160ms ease;
}

.switch-input:checked + .switch-track {
  background-color: var(--primary-btn-bg);
}

.switch-input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
}

.switch-input:focus-visible + .switch-track {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.switch-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.switch-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.switch-desc {
  font-size: 12.5px;
  color: var(--muted-fg);
  line-height: 1.45;
}

/* Disclosure Guide */
.guide-disclosure {
  border-top: 1px solid var(--border-subtle);
  padding: 14px 20px;
  background-color: var(--muted);
}

.guide-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--heading);
  cursor: pointer;
  list-style: none;
}

.guide-summary::-webkit-details-marker {
  display: none;
}

.guide-steps {
  margin-top: 12px;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13.5px;
  color: var(--fg);
}

.guide-steps code,
.inline-code,
.form-help code {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background-color: var(--card);
  border: 1px solid var(--border-subtle);
}

.inline-feedback {
  margin: 14px 20px 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
}

.inline-feedback.is-success {
  background-color: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.inline-feedback.is-error {
  background-color: var(--destructive-bg);
  border-color: var(--destructive-border);
  color: var(--destructive);
}

.form-footer-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Daemon & Live OLED Terminal Log Viewer
   ========================================================================== */
.daemon-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-success {
  background-color: var(--accent);
  box-shadow: 0 0 0 4px var(--success-bg);
}

.dot-warning {
  background-color: var(--warning);
  box-shadow: 0 0 0 4px var(--warning-bg);
}

.dot-destructive {
  background-color: var(--destructive-btn-bg);
  box-shadow: 0 0 0 4px var(--destructive-bg);
}

.dot-neutral {
  background-color: var(--muted-fg);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--border-subtle);
}

.meta-item {
  padding: 14px 18px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-item:last-child {
  border-right: none;
}

.meta-item dt {
  font-size: 12px;
  color: var(--muted-fg);
  font-weight: 500;
}

.meta-item dd {
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
}

.daemon-controls {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tip-box {
  margin: 0 20px 20px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background-color: var(--muted);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tip-box.is-warning {
  background-color: var(--warning-bg);
  border-color: var(--warning-border);
}

.tip-box-text {
  font-size: 13.5px;
  color: var(--fg);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tip-box.is-warning .tip-box-text {
  color: var(--warning);
}

.code-copy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background-color: var(--card);
  border: 1px solid var(--border);
}

.code-copy-row code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
  word-break: break-all;
}

.log-header {
  align-items: center;
}

.log-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
}

.inline-checkbox input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-btn-bg);
  cursor: pointer;
}

.log-terminal {
  background-color: var(--terminal-bg);
  color: var(--terminal-fg);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  padding: 14px 16px;
  height: 440px;
  overflow: auto;
  border-top: 1px solid var(--terminal-border);
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 1px 0;
}

.log-line-error {
  color: #FCA5A5;
}

.log-line-warn {
  color: #FCD34D;
}

.log-line-info {
  color: #E2E8F0;
}

.log-line-debug {
  color: #94A3B8;
}

.log-empty {
  color: #94A3B8;
  padding: 16px 0;
}

/* ==========================================================================
   Modals (Strict .modal-dialog > form flex column with min-height: 0)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overscroll-behavior: contain;
}

.modal-dialog {
  width: 100%;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-lg {
  max-width: 680px;
}

.modal-sm {
  max-width: 450px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--heading);
}

.modal-body {
  padding: 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

.modal-intro {
  font-size: 14px;
  color: var(--muted-fg);
}

.confirm-text {
  font-size: 14.5px;
  color: var(--fg);
  line-height: 1.6;
}

/* Admin Multi-User Target Selector in Add Course Modal */
.admin-targets-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background-color: var(--muted);
}

.target-users-list {
  max-height: 170px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.target-users-list.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.target-user-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
  cursor: pointer;
  font-size: 13px;
  min-width: 0;
}

.target-user-option input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-btn-bg);
  flex-shrink: 0;
}

.target-user-option-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.target-user-option-text strong {
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.target-user-option-text span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-fg);
}

/* Course Modal & 24h Schedule Builder */
.url-resolve-row {
  display: flex;
  gap: 8px;
}

.url-resolve-row .form-input {
  flex: 1;
}

.resolve-preview {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--info-border);
  background-color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resolve-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted-fg);
}

.preview-sessions {
  font-size: 13px;
  color: var(--muted-fg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 14px;
  background-color: var(--muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.schedule-days-section,
.schedule-slots-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-slots-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.helper-caption {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted-fg);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.day-chip {
  min-width: 44px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.day-chip:hover {
  border-color: var(--primary);
  color: var(--info);
  background-color: var(--info-bg);
}

.day-chip.is-active {
  background-color: var(--primary-btn-bg);
  border-color: var(--primary-btn-bg);
  color: var(--on-primary);
}

.day-chip.is-active:hover {
  background-color: var(--primary-btn-hover);
  border-color: var(--primary-btn-hover);
  color: var(--on-primary);
}

.schedule-empty-hint {
  margin: 0;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  background-color: var(--card);
  color: var(--muted-fg);
  font-size: 13px;
  text-align: center;
}

.schedule-slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-slot-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
}

.schedule-slot-card.is-invalid {
  border-color: var(--destructive);
}

.schedule-slot-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.schedule-slot-day {
  min-width: 122px;
  flex: 0 0 auto;
  font-weight: 600;
}

.schedule-slot-times {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  flex-wrap: wrap;
}

.time-picker-24h {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--card);
  padding: 2px 4px;
  gap: 1px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.time-picker-24h:focus-within {
  border-color: var(--focus-ring-color);
  box-shadow: 0 0 0 3px var(--focus-ring-soft);
}

.time-select-part {
  border: none;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  padding: 5px 4px;
  cursor: pointer;
  outline: none;
  min-width: 46px;
  text-align: center;
}

.time-select-part option {
  background-color: var(--card);
  color: var(--fg);
}

.time-colon {
  font-weight: 700;
  color: var(--muted-fg);
  padding: 0 1px;
  user-select: none;
}

.schedule-time-sep {
  font-size: 13px;
  color: var(--muted-fg);
  font-weight: 500;
}

.schedule-slot-remove {
  margin-left: auto;
  min-width: 36px;
  min-height: 36px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 150ms ease, color 150ms ease;
}

.schedule-slot-remove:hover {
  background-color: var(--destructive-bg);
  color: var(--destructive);
}

.slot-preset-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.slot-preset-label {
  font-size: 11.5px;
  color: var(--muted-fg);
  margin-right: 2px;
}

.slot-preset-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background-color: var(--muted);
  color: var(--muted-fg);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.slot-preset-chip:hover,
.slot-preset-chip.is-active {
  border-color: var(--primary);
  background-color: var(--info-bg);
  color: var(--info);
}

.schedule-slot-error {
  margin: 0;
  font-size: 12px;
  color: var(--destructive);
  font-weight: 500;
}

.schedule-raw-details {
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

.schedule-raw-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted-fg);
  cursor: pointer;
  user-select: none;
  flex-wrap: wrap;
  list-style: none;
}

.schedule-raw-summary::-webkit-details-marker {
  display: none;
}

.schedule-raw-summary-left {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.summary-chevron {
  transition: transform 150ms ease;
  flex-shrink: 0;
}

.schedule-raw-details[open] .summary-chevron {
  transform: rotate(90deg);
}

.schedule-raw-summary:hover {
  color: var(--fg);
}

.schedule-raw-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

/* Outside-class Radio Cards */
.fieldset-clean {
  border: none;
  padding: 0;
  margin: 0;
}

.fieldset-clean legend {
  margin-bottom: 8px;
}

.radio-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.radio-card {
  position: relative;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.radio-card-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--card);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.radio-card:hover .radio-card-box {
  border-color: var(--primary);
}

.radio-card input:checked + .radio-card-box {
  border-color: var(--primary);
  background-color: var(--info-bg);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.radio-card input:focus-visible + .radio-card-box {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: 2px;
}

.radio-card-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--fg);
}

.radio-card-desc {
  font-size: 12px;
  color: var(--muted-fg);
  line-height: 1.4;
}

/* Dry-run Modal */
.dry-run-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dry-run-controls .form-field {
  flex: 1;
  min-width: 220px;
}

.dry-run-btns {
  display: flex;
  gap: 8px;
  padding-bottom: 22px;
}

.dry-run-results {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.dry-run-meta {
  padding: 10px 14px;
  background-color: var(--muted);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dry-run-list {
  display: flex;
  flex-direction: column;
}

.dry-run-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dry-run-item:last-child {
  border-bottom: none;
}

.dry-run-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.dry-run-course {
  font-weight: 700;
  font-size: 14px;
  color: var(--fg);
}

.dry-run-detail {
  font-size: 13px;
  color: var(--muted-fg);
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
  width: calc(100vw - 32px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--fg);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  line-height: 1.45;
}

.toast-success {
  border-left: 4px solid var(--accent);
}

.toast-error {
  border-left: 4px solid var(--destructive-btn-bg);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-close {
  border: none;
  background: transparent;
  color: var(--muted-fg);
  padding: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.toast-close:hover {
  color: var(--fg);
}

/* ==========================================================================
   Responsive Design (1440px -> 1024px -> 768px -> 375px)
   ========================================================================== */
@media (max-width: 1023px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: min(280px, 84vw);
    box-shadow: var(--shadow-lg);
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .icon-btn.sidebar-close-btn {
    display: inline-flex;
  }

  .app-workspace {
    margin-left: 0;
  }

  .icon-btn.mobile-menu-btn {
    display: inline-flex;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .courses-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meta-item {
    border-bottom: 1px solid var(--border-subtle);
  }

  .form-grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .auth-split-card {
    grid-template-columns: 1fr;
    max-width: 500px;
  }

  .auth-hero {
    display: none;
  }

  .auth-form-pane {
    padding: 28px 22px;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 14px;
  }

  .workspace-main {
    padding: 16px 14px 40px;
  }

  /* >=44px mobile touch targets for icon-only buttons and interactive controls */
  .icon-btn,
  .input-eye-btn,
  .schedule-slot-remove {
    min-width: 44px;
    min-height: 44px;
  }

  .day-chip {
    min-width: 44px;
    min-height: 44px;
  }

  .clock-label {
    display: none;
  }

  .form-grid,
  .form-grid-3,
  .radio-card-grid,
  .target-users-list {
    grid-template-columns: 1fr;
  }

  .url-resolve-row {
    flex-direction: column;
  }

  .dry-run-btns {
    padding-bottom: 0;
    width: 100%;
  }

  .dry-run-btns .btn {
    flex: 1;
  }

  .context-select {
    min-width: 0;
    width: 100%;
  }

  .context-bar-left {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-item {
    border-right: none;
  }

  .course-detail-grid {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .course-detail-grid dt {
    font-size: 12px;
  }

  .course-detail-grid dd {
    margin-bottom: 6px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .btn {
    flex: 1 1 auto;
  }

  .topbar-title {
    font-size: 16px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
