/* ═══════════════════════════════════════════════════════════════════════════
   SmartTZ Design System — Premium SaaS Dark Theme
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Elevation layers (dark theme, 5 levels) */
  --bg-base:       #0a0e1a;
  --bg-raised:     #0f1424;
  --bg-surface:    #151c30;
  --bg-overlay:    #1b2440;
  --bg-elevated:   #283050;

  /* Primary */
  --primary:       #4f7cff;
  --primary-hover: #6690ff;
  --primary-muted: rgba(79, 124, 255, 0.15);
  --primary-border:rgba(79, 124, 255, 0.35);
  --primary-glow:  rgba(79, 124, 255, 0.4);
  --gradient-primary: linear-gradient(135deg, #4f7cff, #7c5aff);

  /* Semantic */
  --success:       #34d058;
  --success-muted: rgba(52, 208, 88, 0.15);
  --success-border:rgba(52, 208, 88, 0.35);
  --warning:       #f0b429;
  --warning-muted: rgba(240, 180, 41, 0.15);
  --warning-border:rgba(240, 180, 41, 0.35);
  --error:         #e53e3e;
  --error-muted:   rgba(229, 62, 62, 0.15);
  --error-border:  rgba(229, 62, 62, 0.35);
  --info:          #4299e1;
  --info-muted:    rgba(66, 153, 225, 0.15);
  --info-border:   rgba(66, 153, 225, 0.35);

  /* Text */
  --text-primary:  #e8eaf4;
  --text-secondary:rgba(232, 234, 244, 0.65);
  --text-tertiary: rgba(232, 234, 244, 0.4);
  --text-inverse:  #0a0e1a;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default:rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.18);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  --text-xs:  0.6875rem;
  --text-sm:  0.8125rem;
  --text-base:0.875rem;
  --text-md:  0.9375rem;
  --text-lg:  1.0625rem;
  --text-xl:  1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --leading-tight:  1.3;
  --leading-normal: 1.5;
  --leading-relaxed:1.65;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold:600;
  --weight-bold:   700;

  /* Spacing (4px base) */
  --space-0:  0;
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Radius */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-sm:  0 2px 6px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.35);
  --shadow-lg:  0 8px 28px rgba(0,0,0,0.4);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.5);
  --shadow-glow:0 0 20px var(--primary-glow), 0 8px 24px rgba(79, 124, 255, 0.25);
  --shadow-glow-sm: 0 0 10px rgba(79, 124, 255, 0.2);

  /* Transitions */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:   150ms;
  --duration-normal: 250ms;
  --duration-slow:   350ms;
  --duration-spring: 400ms;

  /* Z-index scale */
  --z-base:     1;
  --z-dropdown: 100;
  --z-sticky:   200;
  --z-overlay:  300;
  --z-modal:    400;
  --z-popover:  500;
  --z-toast:    600;
  --z-tooltip:  700;
  --z-command:  800;

  /* Layout */
  --sidebar-width:    220px;
  --sidebar-collapsed: 64px;
  --topbar-height:    64px;
  --content-max:      1400px;
  --drawer-height:    240px;
}

/* ── Light Theme ─────────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-base:       #f5f7fa;
  --bg-raised:     #ffffff;
  --bg-surface:    #ffffff;
  --bg-overlay:    #f0f2f5;
  --bg-elevated:   #e8ecf1;

  --primary:       #4f7cff;
  --primary-hover: #3d6ae8;
  --primary-muted: rgba(79, 124, 255, 0.1);
  --primary-border:rgba(79, 124, 255, 0.3);
  --primary-glow:  rgba(79, 124, 255, 0.25);

  --success:       #22a94e;
  --success-muted: rgba(34, 169, 78, 0.1);
  --success-border:rgba(34, 169, 78, 0.3);
  --warning:       #d4960a;
  --warning-muted: rgba(212, 150, 10, 0.1);
  --warning-border:rgba(212, 150, 10, 0.3);
  --error:         #d33030;
  --error-muted:   rgba(211, 48, 48, 0.1);
  --error-border:  rgba(211, 48, 48, 0.3);
  --info:          #3182ce;
  --info-muted:    rgba(49, 130, 206, 0.1);
  --info-border:   rgba(49, 130, 206, 0.3);

  --text-primary:  #1a202c;
  --text-secondary:rgba(26, 32, 44, 0.65);
  --text-tertiary: rgba(26, 32, 44, 0.4);
  --text-inverse:  #ffffff;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default:rgba(0, 0, 0, 0.12);
  --border-strong: rgba(0, 0, 0, 0.2);

  --shadow-xs:  0 1px 2px rgba(0,0,0,0.06);
  --shadow-sm:  0 2px 6px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 14px rgba(0,0,0,0.1);
  --shadow-lg:  0 8px 28px rgba(0,0,0,0.12);
  --shadow-xl:  0 16px 48px rgba(0,0,0,0.15);
  --shadow-glow:0 0 20px var(--primary-glow), 0 8px 24px rgba(79, 124, 255, 0.1);
  --shadow-glow-sm: 0 0 10px rgba(79, 124, 255, 0.1);
}

/* Light theme overrides for components with hardcoded rgba */
[data-theme="light"] .sidebar { background: #ffffff; border-right-color: rgba(0,0,0,0.08); }
[data-theme="light"] .topbar { background: rgba(255,255,255,0.85); border-bottom-color: rgba(0,0,0,0.08); }
[data-theme="light"] .nav-link:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .nav-link.active { background: var(--primary-muted); }
[data-theme="light"] .modal-close:hover { background: rgba(0,0,0,0.06); }
[data-theme="light"] .btn-secondary { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.12); color: var(--text-primary); }
[data-theme="light"] .btn-secondary:hover { background: rgba(0,0,0,0.08); }
[data-theme="light"] .btn-ghost:hover { background: rgba(0,0,0,0.05); }
[data-theme="light"] .form-input { background: #f5f7fa; border-color: rgba(0,0,0,0.12); color: var(--text-primary); }
[data-theme="light"] .form-input:focus { border-color: var(--primary); background: #ffffff; }
[data-theme="light"] .form-select { background-color: #f5f7fa; border-color: rgba(0,0,0,0.12); color: var(--text-primary); }
[data-theme="light"] .form-select:focus { border-color: var(--primary); background-color: #ffffff; }
[data-theme="light"] .card { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .card:hover { border-color: rgba(0,0,0,0.15); }
[data-theme="light"] .data-table th { background: #f0f2f5; color: var(--text-secondary); border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .data-table td { border-color: rgba(0,0,0,0.06); }
[data-theme="light"] .data-table tr:hover td { background: rgba(0,0,0,0.02); }
[data-theme="light"] .badge { border-color: rgba(0,0,0,0.1); }
[data-theme="light"] .chat-area { background: #f5f7fa; }
[data-theme="light"] .chat-message.bot .chat-bubble { background: #ffffff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .chat-message.user .chat-bubble { background: var(--primary); color: #fff; }
[data-theme="light"] .chat-input-bar { background: #ffffff; border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .chat-input { background: transparent; color: var(--text-primary); }
[data-theme="light"] .command-palette-inner { background: #ffffff; border-color: rgba(0,0,0,0.12); }
[data-theme="light"] .command-search { background: transparent; color: var(--text-primary); border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .command-item:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .log-drawer { background: #ffffff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .log-content { background: #f5f7fa; color: var(--text-primary); }
[data-theme="light"] .timeline-line { background: rgba(0,0,0,0.1); }
[data-theme="light"] .timeline-card { background: #ffffff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .stat-card { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .empty-state-icon { background: rgba(0,0,0,0.04); color: var(--text-tertiary); }
[data-theme="light"] .skeleton { background: rgba(0,0,0,0.06); }
[data-theme="light"] .kbd { background: #e8ecf1; border-color: rgba(0,0,0,0.12); color: var(--text-secondary); }
[data-theme="light"] .sidebar-footer { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .search-trigger { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.1); }
[data-theme="light"] .search-trigger:hover { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.15); }
[data-theme="light"] .avatar { background: var(--primary); color: #fff; }
[data-theme="light"] .integration-card { border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .score-gauge-bg { stroke: rgba(0,0,0,0.08); }

/* ── Base ─────────────────────────────────────────────────────────────────── */
body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-base);
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection {
  background: var(--primary-muted);
  color: var(--text-primary);
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }


/* ═══════════════════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--duration-normal) var(--ease-out);
}

.app.sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed) 1fr;
}

.main-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.content {
  flex: 1;
  padding: var(--space-6) var(--space-5) var(--space-16);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.sidebar {
  background: var(--bg-raised);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--duration-normal) var(--ease-out);
  z-index: var(--z-sticky);
}

/* Brand */
.sidebar-brand {
  padding: var(--space-5) var(--space-5) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  color: #fff;
  box-shadow: var(--shadow-glow-sm);
}

.sidebar-brand-text {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--duration-fast);
}

.sidebar-brand-name {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: var(--leading-tight);
}

.sidebar-brand-desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.sidebar-collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
}

/* Nav Groups */
.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-group {
  margin-bottom: var(--space-2);
}

.nav-group-label {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-collapsed .nav-group-label {
  opacity: 0;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: all var(--duration-fast);
  position: relative;
  white-space: nowrap;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-muted);
  color: var(--primary);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
  animation: slideInLeft var(--duration-normal) var(--ease-out);
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.nav-item-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}

.nav-item-label {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity var(--duration-fast);
}

.sidebar-collapsed .nav-item-label {
  opacity: 0;
  width: 0;
}

.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: var(--space-2);
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-shrink: 0;
}

.sidebar-footer-info {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-collapsed .sidebar-footer-info {
  opacity: 0;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  transition: all var(--duration-fast);
}

.sidebar-collapse-btn:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text-secondary);
}

.sidebar-collapse-btn svg {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-collapsed .sidebar-collapse-btn svg {
  transform: rotate(180deg);
}

.sidebar-collapse-label {
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-collapsed .sidebar-collapse-label {
  opacity: 0;
  width: 0;
}


/* Sidebar tooltip (collapsed mode) */
.nav-item[data-tooltip] {
  position: relative;
}

.sidebar-collapsed .nav-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  padding: var(--space-1) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
  box-shadow: var(--shadow-md);
  z-index: var(--z-tooltip);
}

.sidebar-collapsed .nav-item[data-tooltip]:hover::after {
  opacity: 1;
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════════════════════ */

.topbar {
  height: var(--topbar-height);
  padding: 0 var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}

.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}

.hamburger-btn:hover { background: rgba(255,255,255,0.06); }

.hamburger-btn svg { width: 20px; height: 20px; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  min-width: 0;
}

.breadcrumbs span { white-space: nowrap; }

.breadcrumb-sep {
  color: var(--text-tertiary);
  opacity: 0.5;
}

.breadcrumb-current {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Search trigger */
.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: rgba(255,255,255,0.03);
  color: var(--text-tertiary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
  min-width: 200px;
}

.search-trigger:hover {
  border-color: var(--border-strong);
  background: rgba(255,255,255,0.05);
}

.search-trigger svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-trigger-text {
  flex: 1;
}

kbd {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-default);
  background: rgba(255,255,255,0.06);
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.2;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.theme-toggle svg { width: 18px; height: 18px; }

/* User avatar / menu */
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: all var(--duration-fast);
}

.user-menu-btn:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border-default);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: #fff;
  flex-shrink: 0;
}

.user-menu-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  background: transparent;
  cursor: pointer;
  transition: all var(--duration-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  pointer-events: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Primary */
.btn-primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 124, 255, 0.3);
}

.btn-primary:hover, .btn.primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:active, .btn.primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(79, 124, 255, 0.25);
}

/* Secondary */
.btn-secondary, .btn.secondary {
  background: rgba(255,255,255,0.06);
  border-color: var(--border-strong);
}

.btn-secondary:hover, .btn.secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
}

/* Ghost */
.btn-ghost, .btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover, .btn.ghost:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

/* Danger */
.btn-danger, .btn.danger {
  background: var(--error-muted);
  border-color: var(--error-border);
  color: var(--error);
}

.btn-danger:hover, .btn.danger:hover {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}

/* Icon-only */
.btn-icon {
  padding: var(--space-2);
  min-width: 36px;
  min-height: 36px;
}

/* Sizes */
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-md);
  border-radius: var(--radius-lg);
}


/* ═══════════════════════════════════════════════════════════════════════════
   FORM INPUTS
   ═══════════════════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
}

.form-input,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="search"],
textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  transition: all var(--duration-fast);
}

.form-input:hover,
input:hover {
  border-color: var(--border-strong);
}

.form-input:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.15);
}

.form-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Select */
select, .form-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-base) url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23787e99' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--duration-fast);
}

select:hover { border-color: var(--border-strong); }

select option {
  background: var(--bg-overlay);
  color: var(--text-primary);
}

.form-helper {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Validation states */
.form-group.has-error .form-input,
.form-group.has-error input,
.form-group.has-error select {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-muted);
}

.form-group.has-error .form-helper {
  color: var(--error);
}

.form-group.has-success .form-input,
.form-group.has-success input {
  border-color: var(--success);
}

/* Form grid */
.form-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.form-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  margin-top: var(--space-4);
}

/* Legacy label styling */
label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}


/* ═══════════════════════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  transition: all var(--duration-normal) var(--ease-out);
  position: relative;
}

.card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.card-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
}

.card-actions {
  margin-top: var(--space-3);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Card grid */
.card-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.card-grid-2 {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Stat card */
.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
}

.stat-card-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* Clickable card */
.card-clickable {
  cursor: pointer;
}

.card-clickable:hover {
  border-color: var(--primary-border);
}


/* ═══════════════════════════════════════════════════════════════════════════
   PANELS (legacy compat + new)
   ═══════════════════════════════════════════════════════════════════════════ */

.panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  border: 1px solid var(--border-subtle);
}

.panel h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-4);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.panel-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

/* Section pages */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.section-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
}

.section-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}


/* ═══════════════════════════════════════════════════════════════════════════
   DATA TABLE
   ═══════════════════════════════════════════════════════════════════════════ */

.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.data-table th.sortable {
  cursor: pointer;
}

.data-table th.sortable:hover {
  color: var(--text-primary);
}

.data-table th .sort-icon {
  display: inline-block;
  margin-left: var(--space-1);
  opacity: 0.4;
}

.data-table th.sort-asc .sort-icon,
.data-table th.sort-desc .sort-icon {
  opacity: 1;
  color: var(--primary);
}

.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--duration-fast);
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr.selected {
  background: var(--primary-muted);
}

.data-table-empty {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--text-tertiary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   BADGES / PILLS
   ═══════════════════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.6;
  white-space: nowrap;
}

.badge-default {
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--primary-muted);
  color: var(--primary);
}

.badge-success {
  background: var(--success-muted);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-muted);
  color: var(--warning);
}

.badge-error {
  background: var(--error-muted);
  color: var(--error);
}

.badge-info {
  background: var(--info-muted);
  color: var(--info);
}

/* Status dot */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}

/* Priority badges */
.priority-high {
  background: var(--error-muted);
  color: var(--error);
}

.priority-medium {
  background: var(--warning-muted);
  color: var(--warning);
}

.priority-low {
  background: var(--info-muted);
  color: var(--info);
}

/* Status badge (legacy) */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--success-muted);
  color: var(--success);
}

.status-badge.danger {
  background: var(--error-muted);
  color: var(--error);
}

.status-badge.warning {
  background: var(--warning-muted);
  color: var(--warning);
}

/* Count badge */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
}


/* ═══════════════════════════════════════════════════════════════════════════
   MODALS (dialog)
   ═══════════════════════════════════════════════════════════════════════════ */

dialog {
  border: none;
  padding: 0;
  background: transparent;
}

dialog[open] {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-xl);
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
}

.modal-wide {
  width: 640px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.modal-close:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  max-height: 60vh;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}


/* ═══════════════════════════════════════════════════════════════════════════
   TOASTS
   ═══════════════════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: slideInRight var(--duration-normal) var(--ease-out);
}

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.toast-content { flex: 1; min-width: 0; }

.toast-message {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.toast-dismiss {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.toast-dismiss:hover { color: var(--text-primary); }

.toast-success { border-left: 3px solid var(--success); }
.toast-success .toast-icon { color: var(--success); }

.toast-error { border-left: 3px solid var(--error); }
.toast-error .toast-icon { color: var(--error); }

.toast-warning { border-left: 3px solid var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }

.toast-info { border-left: 3px solid var(--info); }
.toast-info .toast-icon { color: var(--info); }

.toast.removing {
  animation: slideOutRight var(--duration-fast) var(--ease-out) forwards;
}


/* ═══════════════════════════════════════════════════════════════════════════
   CHAT UI
   ═══════════════════════════════════════════════════════════════════════════ */

.chat-container {
  display: flex;
  flex-direction: column;
  height: 500px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  background: var(--bg-base);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chat-bubble {
  max-width: 75%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  animation: fadeIn var(--duration-fast);
}

.chat-bubble-user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: var(--radius-sm);
}

.chat-bubble-bot {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: var(--radius-sm);
}

.chat-bubble-meta {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.chat-bubble-user .chat-bubble-meta {
  color: rgba(255,255,255,0.6);
}

/* Typing indicator */
.chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-3) var(--space-4);
  align-self: flex-start;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-tertiary);
  animation: typingBounce 1.4s infinite;
}

.chat-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Chat input area */
.chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-raised);
}

.chat-input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  resize: none;
  min-height: 40px;
  max-height: 120px;
}

.chat-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--duration-fast);
}

.chat-send-btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-glow-sm);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-send-btn svg { width: 18px; height: 18px; }

/* RAG Panel */
.rag-panel {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.rag-panel-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}


/* ═══════════════════════════════════════════════════════════════════════════
   TIMELINE STEPPER (Scenario A→Z)
   ═══════════════════════════════════════════════════════════════════════════ */

.timeline {
  position: relative;
  padding-left: var(--space-8);
}

.timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-default);
}

.timeline-step {
  position: relative;
  padding: var(--space-4) 0;
  padding-left: var(--space-6);
  transition: opacity var(--duration-fast);
}

.timeline-step:last-child {
  padding-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: calc(-1 * var(--space-8) + 8px);
  top: var(--space-5);
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-default);
  background: var(--bg-base);
  z-index: 1;
  transition: all var(--duration-normal) var(--ease-out);
}

.timeline-step.step-pending {
  opacity: 0.5;
}

.timeline-step.step-pending .timeline-dot {
  border-color: var(--border-default);
  background: var(--bg-base);
}

.timeline-step.step-running .timeline-dot {
  border-color: var(--warning);
  background: var(--warning);
  box-shadow: 0 0 12px var(--warning-muted);
  animation: pulse 1.5s infinite;
}

.timeline-step.step-ok .timeline-dot {
  border-color: var(--success);
  background: var(--success);
  box-shadow: 0 0 8px var(--success-muted);
}

.timeline-step.step-fail .timeline-dot {
  border-color: var(--error);
  background: var(--error);
}

.timeline-step.step-running,
.timeline-step.step-ok,
.timeline-step.step-fail {
  opacity: 1;
}

.timeline-step-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-4) var(--space-5);
  transition: all var(--duration-normal);
}

.timeline-step.step-running .timeline-step-content {
  border-color: var(--warning-border);
  background: rgba(240, 180, 41, 0.04);
}

.timeline-step.step-ok .timeline-step-content {
  border-color: var(--success-border);
}

.timeline-step.step-fail .timeline-step-content {
  border-color: var(--error-border);
}

.timeline-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.timeline-step-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.timeline-step-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.timeline-step-status {
  margin-left: auto;
  font-size: var(--text-lg);
}

.timeline-step-desc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  line-height: var(--leading-relaxed);
}

.timeline-step-result {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SCORE GAUGE (SVG circular progress)
   ═══════════════════════════════════════════════════════════════════════════ */

.gauge-container {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-2);
}

.gauge {
  position: relative;
  width: 120px;
  height: 120px;
}

.gauge svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--border-default);
  stroke-width: 8;
}

.gauge-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease-out);
}

.gauge-fill.success { stroke: var(--success); }
.gauge-fill.warning { stroke: var(--warning); }
.gauge-fill.error   { stroke: var(--error); }

.gauge-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gauge-number {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.gauge-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SKELETON LOADERS
   ═══════════════════════════════════════════════════════════════════════════ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-overlay) 25%,
    var(--bg-elevated) 50%,
    var(--bg-overlay) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--space-2);
}

.skeleton-text:last-child {
  width: 60%;
}

.skeleton-card {
  height: 120px;
  border-radius: var(--radius-lg);
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

.skeleton-row {
  height: 48px;
  margin-bottom: var(--space-2);
}


/* ═══════════════════════════════════════════════════════════════════════════
   EMPTY STATES
   ═══════════════════════════════════════════════════════════════════════════ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--text-tertiary);
}

.empty-state-icon svg { width: 28px; height: 28px; }

.empty-state-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  max-width: 360px;
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}


/* ═══════════════════════════════════════════════════════════════════════════
   COMMAND PALETTE
   ═══════════════════════════════════════════════════════════════════════════ */

.command-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-command);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-fast);
}

.command-overlay.open {
  opacity: 1;
  visibility: visible;
}

.command-palette {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 560px;
  max-width: 90vw;
  max-height: 420px;
  overflow: hidden;
  transform: scale(0.95) translateY(-10px);
  transition: transform var(--duration-normal) var(--ease-out);
}

.command-overlay.open .command-palette {
  transform: scale(1) translateY(0);
}

.command-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.command-input-wrap svg {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.command-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  outline: none;
}

.command-input::placeholder {
  color: var(--text-tertiary);
}

.command-results {
  overflow-y: auto;
  max-height: 340px;
  padding: var(--space-2);
}

.command-group-label {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.command-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.command-item:hover,
.command-item.active {
  background: rgba(255,255,255,0.06);
}

.command-item-icon {
  width: 20px;
  height: 20px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.command-item-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  flex: 1;
}

.command-item-shortcut {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   LOG DRAWER
   ═══════════════════════════════════════════════════════════════════════════ */

.log-drawer {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-width);
  right: 0;
  z-index: var(--z-overlay);
  background: var(--bg-raised);
  border-top: 1px solid var(--border-default);
  transform: translateY(calc(100% - 40px));
  transition: transform var(--duration-normal) var(--ease-out),
              left var(--duration-normal) var(--ease-out);
}

.sidebar-collapsed ~ .main-wrapper .log-drawer,
.app.sidebar-collapsed .log-drawer {
  left: var(--sidebar-collapsed);
}

.log-drawer.open {
  transform: translateY(0);
}

.log-drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  user-select: none;
  border: none;
  background: transparent;
  width: 100%;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.log-drawer-toggle:hover {
  background: rgba(255,255,255,0.03);
}

.log-drawer-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--duration-fast);
}

.log-drawer.open .log-drawer-toggle svg {
  transform: rotate(180deg);
}

.log-drawer-content {
  height: var(--drawer-height);
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
}

.log-line {
  padding: 2px 0;
  color: var(--text-secondary);
}

.log-line.success { color: var(--success); }
.log-line.error { color: var(--error); }
.log-line.warning { color: var(--warning); }
.log-line.info { color: var(--info); }


/* ═══════════════════════════════════════════════════════════════════════════
   LEGACY LISTS
   ═══════════════════════════════════════════════════════════════════════════ */

.list {
  margin-top: var(--space-3);
  display: grid;
  gap: var(--space-2);
}

.list-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-raised);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  transition: all var(--duration-fast);
}

.list-item:hover {
  border-color: var(--border-default);
  background: var(--bg-surface);
}

.list-item button {
  padding: var(--space-1) var(--space-3);
}

/* Code block */
.code {
  margin-top: var(--space-3);
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border-subtle);
  max-height: 320px;
  overflow: auto;
  color: var(--text-secondary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SECTION VISIBILITY
   ═══════════════════════════════════════════════════════════════════════════ */

.section {
  display: none;
}

.section.active {
  display: block;
  animation: fadeIn var(--duration-normal) var(--ease-out);
}


/* ═══════════════════════════════════════════════════════════════════════════
   OVERVIEW DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════ */

.dashboard-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.dashboard-hero {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-subtle);
  padding: var(--space-8);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dashboard-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(79, 124, 255, 0.08), transparent 70%);
  pointer-events: none;
}

.dashboard-hero-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
  position: relative;
}

.dashboard-hero-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto var(--space-6);
  line-height: var(--leading-relaxed);
  position: relative;
}


/* ═══════════════════════════════════════════════════════════════════════════
   PROGRESS BAR
   ═══════════════════════════════════════════════════════════════════════════ */

.progress-wrap {
  margin-bottom: var(--space-4);
}

.progress-bar-track {
  height: 6px;
  background: var(--border-default);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-2);
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-out);
  width: 0%;
}

.progress-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   SCENARIO SUMMARY
   ═══════════════════════════════════════════════════════════════════════════ */

.scenario-summary {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
  border: 1px solid var(--success-border);
  background: var(--success-muted);
  flex-wrap: wrap;
}

.summary-icon {
  font-size: 36px;
  flex-shrink: 0;
}

.summary-text {
  flex: 1;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.summary-actions {
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════════════════
   MISC / UTILITIES
   ═══════════════════════════════════════════════════════════════════════════ */

.muted { color: var(--text-tertiary); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.hidden { display: none !important; }

/* Hint (legacy) */
.hint {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

.hint.success { color: var(--success); }
.hint.error { color: var(--error); }
.hint.info { color: var(--info); }

/* Res tags from scenario */
.res-ok { color: var(--success); }
.res-error { color: var(--error); }

.req-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: var(--space-1);
}

.req-tag {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: var(--weight-semibold);
}

.req-tag.ok {
  background: var(--success-muted);
  color: var(--success);
}

.req-tag.bad {
  background: var(--warning-muted);
  color: var(--warning);
}

.verify-detail {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--warning);
  opacity: 0.85;
}

.btn-download {
  margin-top: var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-border);
  background: var(--primary-muted);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.btn-download:hover {
  background: rgba(79, 124, 255, 0.25);
}

/* Detail panel for requirements */
.detail-panel {
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-5);
  margin-top: var(--space-4);
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.detail-field-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-field-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
}


/* ═══════════════════════════════════════════════════════════════════════════
   INTEGRATION CARDS
   ═══════════════════════════════════════════════════════════════════════════ */

.integration-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  transition: all var(--duration-fast);
}

.integration-card:hover {
  border-color: var(--border-default);
}

.integration-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-xl);
}

.integration-info {
  flex: 1;
  min-width: 0;
}

.integration-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.integration-status {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* Sync status */
.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

.sync-badge.synced {
  background: var(--success-muted);
  color: var(--success);
}

.sync-badge.pending {
  background: var(--warning-muted);
  color: var(--warning);
}

.sync-badge.error {
  background: var(--error-muted);
  color: var(--error);
}


/* ═══════════════════════════════════════════════════════════════════════════
   TRACE GRAPH (simplified visual)
   ═══════════════════════════════════════════════════════════════════════════ */

.trace-visual {
  background: var(--bg-base);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  padding: var(--space-6);
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trace-node {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-border);
  background: var(--primary-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.trace-edge {
  width: 40px;
  height: 2px;
  background: var(--border-strong);
  position: relative;
}

.trace-edge::after {
  content: '';
  position: absolute;
  right: -4px;
  top: -4px;
  width: 0;
  height: 0;
  border-left: 6px solid var(--border-strong);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}


/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS / KEYFRAMES
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-8px) translateY(-50%); }
  to   { opacity: 1; transform: translateX(0) translateY(-50%); }
}

@keyframes slideInUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--primary);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* Tablet (<1024px) */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: var(--sidebar-collapsed) 1fr;
  }

  .sidebar {
    width: var(--sidebar-collapsed);
  }

  .sidebar-brand-text,
  .nav-group-label,
  .nav-item-label,
  .sidebar-footer-info,
  .sidebar-collapse-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .nav-item {
    justify-content: center;
    padding: var(--space-2);
  }

  .nav-item.active::before { display: none; }

  .sidebar-collapse-btn { display: none; }

  .search-trigger { min-width: auto; }
  .search-trigger-text { display: none; }

  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .content {
    padding: var(--space-5) var(--space-4) var(--space-12);
  }

  .topbar {
    padding: 0 var(--space-4);
  }

  .log-drawer {
    left: var(--sidebar-collapsed);
  }
}

/* Mobile (<640px) */
@media (max-width: 640px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-out);
    z-index: var(--z-modal);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Restore text when sidebar is open on mobile */
  .sidebar.mobile-open .sidebar-brand-text,
  .sidebar.mobile-open .nav-group-label,
  .sidebar.mobile-open .nav-item-label,
  .sidebar.mobile-open .sidebar-footer-info,
  .sidebar.mobile-open .sidebar-collapse-label {
    opacity: 1;
    width: auto;
  }

  .sidebar.mobile-open .nav-item {
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: calc(var(--z-modal) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-fast);
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    visibility: visible;
  }

  .hamburger-btn {
    display: flex;
  }

  .topbar {
    padding: 0 var(--space-4);
  }

  .content {
    padding: var(--space-4) var(--space-4) var(--space-12);
  }

  .search-trigger { display: none; }

  .modal {
    width: 100%;
    max-width: 100vw;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .card-grid,
  .card-grid-2,
  .dashboard-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .chat-container {
    height: 400px;
  }

  .chat-bubble {
    max-width: 90%;
  }

  .command-palette {
    width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .log-drawer {
    left: 0;
  }

  .topbar-right {
    gap: var(--space-1);
  }

  .user-menu-name {
    display: none;
  }

  .breadcrumbs {
    font-size: var(--text-xs);
  }

  .timeline {
    padding-left: var(--space-6);
  }

  .timeline::before {
    left: 11px;
  }
}

/* Desktop (>1024px) full sidebar visible by default */
@media (min-width: 1025px) {
  .sidebar-backdrop {
    display: none !important;
  }
}

/* Print */
@media print {
  .sidebar, .topbar, .log-drawer, .toast-container, .command-overlay { display: none; }
  .app { grid-template-columns: 1fr; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════════════════════ */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  overflow: hidden;
}

/* Ambient glow background */
.login-bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  animation: glowPulse 8s ease-in-out infinite;
}

.login-bg-glow-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(79, 124, 255, 0.18) 0%, transparent 70%);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.login-bg-glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(127, 90, 240, 0.12) 0%, transparent 70%);
  bottom: -80px;
  right: -80px;
  animation-delay: 3s;
}

.login-bg-glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(79, 124, 255, 0.08) 0%, transparent 70%);
  top: 50%;
  left: 60%;
  animation-delay: 5s;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Card */
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: var(--space-8);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(79, 124, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: loginCardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin: var(--space-4);
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Logo */
.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-7);
  justify-content: center;
}

.login-logo-mark {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #4f7cff 0%, #3a5fd9 100%);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  box-shadow: 0 8px 28px rgba(79, 124, 255, 0.45);
  flex-shrink: 0;
}

.login-logo-text {
  display: flex;
  flex-direction: column;
}

.login-brand {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.6px;
  line-height: 1.1;
}

.login-tagline {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}

/* Heading */
.login-heading {
  text-align: center;
  margin-bottom: var(--space-6);
}

.login-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.login-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px var(--space-4);
  font-size: var(--text-md);
  font-weight: 600;
  margin-top: var(--space-1);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #4f7cff 0%, #3a5fd9 100%);
  box-shadow: 0 4px 16px rgba(79, 124, 255, 0.3);
  transition: box-shadow var(--transition), transform var(--transition), opacity var(--transition);
}

.login-btn:hover:not(:disabled) {
  box-shadow: 0 6px 24px rgba(79, 124, 255, 0.45);
  transform: translateY(-1px);
}

.login-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

/* Error */
.login-error {
  padding: var(--space-3) var(--space-4);
  background: rgba(229, 62, 62, 0.1);
  border: 1px solid rgba(229, 62, 62, 0.3);
  border-radius: var(--radius);
  color: var(--error);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* Spinner */
.login-spinner {
  width: 16px;
  height: 16px;
  animation: spin 0.8s linear infinite;
}

.login-spinner.hidden { display: none; }

/* Advanced toggle */
.login-advanced-toggle {
  display: block;
  margin: var(--space-3) auto 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--text-xs);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius);
  transition: color var(--transition);
}

.login-advanced-toggle:hover {
  color: var(--text-secondary);
}

/* Footer */
.login-footer {
  text-align: center;
  margin-top: var(--space-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
  opacity: 0.6;
}

/* Light theme overrides for login */
[data-theme="light"] .login-screen {
  background: #f0f2f8;
}

[data-theme="light"] .login-card {
  background: #ffffff;
  border-color: #e2e8f0;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.12),
    0 0 0 1px rgba(79, 124, 255, 0.06);
}

[data-theme="light"] .login-bg-glow-1 {
  background: radial-gradient(circle, rgba(79, 124, 255, 0.10) 0%, transparent 70%);
}

[data-theme="light"] .login-bg-glow-2 {
  background: radial-gradient(circle, rgba(127, 90, 240, 0.07) 0%, transparent 70%);
}

/* Responsive */
@media (max-width: 480px) {
  .login-card {
    padding: var(--space-6) var(--space-5);
    border-radius: 16px;
  }
  .login-logo-mark {
    width: 44px;
    height: 44px;
    font-size: 17px;
    border-radius: 12px;
  }
  .login-brand {
    font-size: 20px;
  }
}/* тХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХР
   Rich UI Components тАФ Detail, Verification, RAG, Trace, Integrations
   тХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХРтХР */
/* тФАтФА badge-error тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.badge-error {
  background: var(--error-muted);
  color: var(--error);
  border: 1px solid var(--error-border);
}
/* тФАтФА .mono helper тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.mono { font-family: var(--font-mono); font-size: var(--text-xs); }
/* тФАтФА Requirement detail fields тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.req-detail-wrap { padding: var(--space-4) 0; }
.detail-fields { display: grid; gap: 0; }
.detail-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-2) var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 3px;
}
.detail-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.55;
  word-break: break-word;
}
.criteria-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-1);
}
.criteria-list li {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-overlay);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--primary);
  line-height: 1.5;
}
/* тФАтФА Output panel container тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.output-panel { min-height: 0; }
/* тФАтФА Scope impact rows тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.impact-changes {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.impact-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}
.impact-added    { background: var(--success-muted); color: var(--success); border-left: 2px solid var(--success); }
.impact-removed  { background: var(--error-muted);   color: var(--error);   border-left: 2px solid var(--error); }
.impact-modified { background: var(--warning-muted); color: var(--warning); border-left: 2px solid var(--warning); }
/* тФАтФА Verification cards тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.verify-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  transition: border-color 0.15s;
}
.verify-card.verify-pass { border-left: 3px solid var(--success); }
.verify-card.verify-fail { border-left: 3px solid var(--error); }
.verify-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.verify-icon { font-size: 16px; flex-shrink: 0; }
.verify-title {
  font-size: var(--text-sm);
  font-weight: 600;
  flex: 1;
  color: var(--text-primary);
}
.violations-list {
  list-style: none;
  margin-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.violations-list li {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  background: var(--error-muted);
  border-radius: var(--radius-sm);
  border-left: 2px solid var(--error);
  line-height: 1.4;
}
/* тФАтФА RAG results тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.rag-results-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.rag-result-card {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  transition: border-color 0.15s;
}
.rag-result-card:hover { border-color: var(--primary-border); }
.rag-result-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.rag-result-num {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  min-width: 22px;
}
.rag-result-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}
.rag-score {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  background: var(--primary-muted);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-weight: 600;
  flex-shrink: 0;
}
.rag-result-desc {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}
/* тФАтФА Result banners тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.result-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
}
.result-banner.result-success { background: var(--success-muted); border-color: var(--success-border); }
.result-banner.result-info    { background: var(--info-muted);    border-color: var(--info-border); }
.result-banner.result-warning { background: var(--warning-muted); border-color: var(--warning-border); }
.result-banner-icon  { font-size: 22px; flex-shrink: 0; }
.result-banner-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.result-banner-desc  { font-size: var(--text-xs); color: var(--text-secondary); margin-top: 2px; }
/* тФАтФА Syncs list тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
.syncs-list { display: flex; flex-direction: column; gap: 2px; }
.sync-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  flex-wrap: wrap;
}
.sync-system { font-weight: 500; color: var(--text-primary); flex: 1; min-width: 80px; }
.sync-count  { font-size: var(--text-xs); color: var(--text-secondary); }
.sync-time   { font-size: var(--text-xs); font-family: var(--font-mono); color: var(--text-tertiary); }
/* тФАтФА Light theme overrides тФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФАтФА */
[data-theme="light"] .verify-card      { background: #fff; }
[data-theme="light"] .rag-result-card  { background: #fff; }
[data-theme="light"] .sync-row         { background: #fff; }
[data-theme="light"] .criteria-list li { background: #f5f7ff; }
[data-theme="light"] .result-banner.result-success { background: rgba(52, 208, 88, 0.08); }
[data-theme="light"] .result-banner.result-info    { background: rgba(66, 153, 225, 0.08); }
[data-theme="light"] .result-banner.result-warning { background: rgba(240, 180, 41, 0.08); }