@import url('/fonts/fonts.css');

:root {
  /* Brand Tokens */
  --brand-navy: #0A2259;
  --brand-navy-text: #0A2259;
  --brand-cyan: #00C4CC;
  --brand-ink: #15213A;

  /* Surfaces & Borders (Light) */
  --bg-canvas: #FAFBFD;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F4F6FA;
  --border-hairline: #E6EAF2;
  --border-hairline-strong: #D1D8E5;

  /* Typography Colors (Light) */
  --text-primary: #15213A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-on-cyan: #0B1220;

  /* Class Pools Hierarchy */
  --class-a: rgba(10, 34, 89, 1.0);
  --class-b: rgba(10, 34, 89, 0.75);
  --class-c: rgba(10, 34, 89, 0.50);
  --class-d: rgba(10, 34, 89, 0.25);

  /* Status Colors */
  --status-ok-text: #059669;
  --status-ok-bg: #ECFDF5;
  --status-ok-border: #A7F3D0;

  --status-warn-text: #D97706;
  --status-warn-bg: #FFFBEB;
  --status-warn-border: #FDE68A;

  --status-bad-text: #DC2626;
  --status-bad-bg: #FEF2F2;
  --status-bad-border: #FECACA;

  /* Fonts */
  --font-display: 'Inter Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-arabic: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* 8-Point Grid Spacing */
  --space-0-5: 4px;
  --space-1: 8px;
  --space-1-5: 12px;
  --space-2: 16px;
  --space-2-5: 20px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  /* Type Scale */
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 20px;
  --font-size-2xl: 24px;
  --font-size-3xl: 32px;
  --font-size-hero: 40px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(11, 18, 32, 0.05);
  --shadow-md: 0 4px 12px rgba(11, 18, 32, 0.08);
  --shadow-lg: 0 8px 24px rgba(11, 18, 32, 0.12);
  --shadow-drawer: -4px 0 24px rgba(11, 18, 32, 0.12);
}

[data-theme="dark"] {
  --brand-navy-text: #C9D4EA;
  --bg-canvas: #0B1220;
  --bg-surface: #121A2B;
  --bg-surface-hover: #182338;
  --border-hairline: #1E2A40;
  --border-hairline-strong: #2D3D5A;

  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #6B7280;

  --class-a: rgba(201, 212, 234, 1.0);
  --class-b: rgba(201, 212, 234, 0.75);
  --class-c: rgba(201, 212, 234, 0.50);
  --class-d: rgba(201, 212, 234, 0.25);

  --status-ok-text: #34D399;
  --status-ok-bg: rgba(6, 78, 59, 0.35);
  --status-ok-border: rgba(5, 150, 105, 0.4);

  --status-warn-text: #FBBF24;
  --status-warn-bg: rgba(120, 53, 15, 0.35);
  --status-warn-border: rgba(217, 119, 6, 0.4);

  --status-bad-text: #F87171;
  --status-bad-bg: rgba(127, 29, 29, 0.35);
  --status-bad-border: rgba(220, 38, 38, 0.4);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-drawer: -4px 0 24px rgba(0, 0, 0, 0.6);
}

/* Reduced Motion Override */
@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;
  }
}

/* Base Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[dir="rtl"] body {
  font-family: var(--font-arabic);
  line-height: 1.6;
}

/* Utility to prevent flipping in RTL */
.flip-rtl { transition: transform 150ms ease; }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 120ms ease;
  white-space: nowrap;
}
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-sm { height: 28px; padding: 0 8px; font-size: var(--font-size-xs); }
.btn-md { height: 34px; padding: 0 14px; font-size: var(--font-size-base); }
.btn-lg { height: 40px; padding: 0 18px; font-size: var(--font-size-md); }

/* The single primary cyan button */
.btn-primary {
  background: var(--brand-cyan);
  color: var(--text-on-cyan);
  border-color: var(--brand-cyan);
}
.btn-primary:hover:not(:disabled) { filter: brightness(0.95); }
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-hairline);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-surface-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-surface-hover); color: var(--text-primary); }
.btn-destructive {
  background: var(--status-bad-bg);
  color: var(--status-bad-text);
  border-color: var(--status-bad-border);
}
.btn-destructive:hover:not(:disabled) { filter: brightness(0.95); }

/* Button Spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
}
@keyframes btnSpin {
  to { transform: rotate(360deg); }
}

/* Inputs & Form Controls */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.input-field, .select-field {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.input-field:focus, .select-field:focus {
  border-color: var(--brand-navy-text);
  box-shadow: 0 0 0 2px rgba(10, 34, 89, 0.12);
}
[data-theme="dark"] .input-field:focus, [data-theme="dark"] .select-field:focus {
  box-shadow: 0 0 0 2px rgba(201, 212, 234, 0.2);
}
.input-field:disabled, .select-field:disabled {
  background: var(--bg-canvas);
  color: var(--text-muted);
  cursor: not-allowed;
}
.form-error {
  font-size: var(--font-size-xs);
  color: var(--status-bad-text);
}

/* Date Picker Wrap */
.date-picker-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.date-picker-wrap input { padding-left: 32px; }
[dir="rtl"] .date-picker-wrap input { padding-left: 10px; padding-right: 32px; }
.date-picker-icon {
  position: absolute;
  left: 10px;
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}
[dir="rtl"] .date-picker-icon { left: auto; right: 10px; }

/* Badges / Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok {
  color: var(--status-ok-text);
  background: var(--status-ok-bg);
  border-color: var(--status-ok-border);
}
.badge-warn {
  color: var(--status-warn-text);
  background: var(--status-warn-bg);
  border-color: var(--status-warn-border);
}
.badge-bad {
  color: var(--status-bad-text);
  background: var(--status-bad-bg);
  border-color: var(--status-bad-border);
}
.badge-neutral {
  color: var(--text-secondary);
  background: var(--bg-surface-hover);
  border-color: var(--border-hairline);
}
.badge-navy {
  color: var(--brand-navy-text);
  background: var(--bg-surface-hover);
  border-color: var(--border-hairline);
}

/* Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--brand-navy-text);
  letter-spacing: -0.01em;
}

/* KPI Tiles with Count-up */
.kpi-tile {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.kpi-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-val {
  font-family: var(--font-display);
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--brand-navy-text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi-sparkline {
  margin-top: 8px;
  height: 28px;
  width: 100%;
}

/* Dense 36px Data Table */
.data-table-container {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.data-table th {
  height: 32px;
  text-align: left;
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 10px;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 5;
  cursor: pointer;
  user-select: none;
}
[dir="rtl"] .data-table th { text-align: right; }
.data-table th:hover { color: var(--text-primary); }
.data-table td {
  height: 36px;
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 10px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table tr:hover td { background: var(--bg-surface-hover); }
.data-table tr.row-focused td {
  outline: 2px solid var(--brand-navy);
  outline-offset: -2px;
}
[data-theme="dark"] .data-table tr.row-focused td { outline-color: var(--brand-cyan); }
.data-table tr.row-selected td { background: rgba(0, 196, 204, 0.08); }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
[dir="rtl"] .num-col { text-align: left; }

/* Table Toolbar */
.table-toolbar {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-hairline);
  background: var(--bg-surface);
  gap: 12px;
}
.table-search-input {
  max-width: 260px;
  height: 30px;
  font-size: var(--font-size-xs);
  background: var(--bg-canvas);
}

/* Drawer Component (480px, starts below 54px top bar, scrim, Esc) */
.drawer-scrim {
  position: fixed;
  top: 54px;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 18, 32, 0.25);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.drawer-scrim.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 54px;
  bottom: 0;
  right: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-hairline);
  box-shadow: var(--shadow-drawer);
  z-index: 50;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}
[dir="rtl"] .drawer {
  right: auto;
  left: 0;
  border-left: none;
  border-right: 1px solid var(--border-hairline);
  box-shadow: 4px 0 24px rgba(11, 18, 32, 0.12);
  transform: translateX(-100%);
}
.drawer.open {
  transform: translateX(0);
}
.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 2;
}
.drawer-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--brand-navy-text);
}
.drawer-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawer-close:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.drawer-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Modal Dialog with Focus Trap */
.modal-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 18, 32, 0.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.modal-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 150ms cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal-container {
  transform: scale(1);
}
.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 18px;
}
.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-hairline);
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
[dir="rtl"] .toast-container { right: auto; left: 24px; }
.toast-item {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastSlideUp 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast-item.toast-success {
  background: var(--status-ok-bg);
  border: 1px solid var(--status-ok-border);
  color: var(--status-ok-text);
}
.toast-item.toast-error {
  background: var(--status-bad-bg);
  border: 1px solid var(--status-bad-border);
  color: var(--status-bad-text);
}
.toast-item.toast-info {
  background: var(--brand-navy);
  color: #FFFFFF;
}
[data-theme="dark"] .toast-item.toast-info {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--brand-navy-text);
}

/* Empty State */
.empty-state {
  padding: 36px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.empty-icon {
  width: 44px;
  height: 44px;
  stroke: var(--brand-navy-text);
  stroke-width: 1.5;
  fill: none;
}
.empty-title {
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--brand-navy-text);
}
.empty-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  max-width: 320px;
}

/* Skeleton Loading */
.skeleton-box {
  background: linear-gradient(90deg, var(--bg-surface-hover) 25%, var(--border-hairline) 50%, var(--bg-surface-hover) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  margin: 16px 0;
}
.stepper-line {
  position: absolute;
  top: 14px;
  left: 20px;
  right: 20px;
  height: 2px;
  background: var(--border-hairline);
  z-index: 1;
}
.step-item {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  padding: 0 8px;
  font-size: var(--font-size-xs);
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface-hover);
  border: 2px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-muted);
}
.step-item.completed .step-dot {
  background: var(--brand-navy);
  border-color: var(--brand-navy);
  color: #FFFFFF;
}
[data-theme="dark"] .step-item.completed .step-dot {
  background: var(--brand-cyan);
  border-color: var(--brand-cyan);
  color: #0B1220;
}
.step-item.active .step-dot {
  background: var(--bg-surface);
  border-color: var(--brand-cyan);
  color: var(--brand-navy-text);
  box-shadow: 0 0 0 3px rgba(0, 196, 204, 0.2);
}

/* Charts: Sparkline & Bar */
.sparkline-svg {
  display: block;
  overflow: visible;
}
.bar-chart-wrap {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 100px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-hairline);
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}
.bar-fill {
  width: 100%;
  background: var(--brand-navy);
  border-radius: 2px 2px 0 0;
  transition: height 300ms ease;
}
[data-theme="dark"] .bar-fill { background: #C9D4EA; }
.bar-fill.accent { background: var(--brand-cyan); }

/* Command Palette Overlay */
.cmd-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 18, 32, 0.4);
  backdrop-filter: blur(2px);
  z-index: 250;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.cmd-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.cmd-container {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 540px;
  width: 100%;
  overflow: hidden;
}
.cmd-search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-hairline);
}
.cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: var(--font-size-md);
  color: var(--text-primary);
}
.cmd-list {
  max-height: 320px;
  overflow-y: auto;
  padding: 6px 0;
}
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  color: var(--text-primary);
}
.cmd-item:hover, .cmd-item.active {
  background: var(--bg-surface-hover);
  color: var(--brand-navy-text);
  font-weight: 600;
}
.cmd-badge {
  font-size: var(--font-size-xs);
  font-family: monospace;
  color: var(--text-muted);
  border: 1px solid var(--border-hairline);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
}

/* App Shell Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 230px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-hairline);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 150ms ease;
}
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border-hairline);
}
[data-theme="dark"] .sidebar { background: #0B1220; }

.sidebar.collapsed {
  width: 60px;
}
.sidebar.collapsed .brand-title,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .nav-label {
  display: none;
}
.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
}
.sidebar-brand {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-hairline);
  height: 54px;
}
.brand-title {
  font-weight: 700;
  font-size: var(--font-size-md);
  letter-spacing: -0.02em;
  color: var(--brand-navy-text);
  white-space: nowrap;
}
.sidebar-nav {
  padding: 14px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.nav-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: all 120ms ease;
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-surface-hover); color: var(--brand-navy-text); }
.nav-item.active {
  background: var(--bg-surface-hover);
  color: var(--brand-navy-text);
  font-weight: 600;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brand-cyan);
  border-radius: 0 2px 2px 0;
}
[dir="rtl"] .nav-item.active::before {
  left: auto;
  right: 0;
  border-radius: 2px 0 0 2px;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  min-width: 0;
}

/* Header Top Bar */
.top-bar {
  height: 54px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}
.breadcrumb-item.active {
  color: var(--brand-navy-text);
  font-weight: 600;
}
.top-search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  cursor: pointer;
  min-width: 240px;
}
.top-search-btn kbd {
  margin-left: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
}
[dir="rtl"] .top-search-btn kbd { margin-left: 0; margin-right: auto; }
.top-actions { display: flex; align-items: center; gap: 10px; position: relative; }

/* User Profile Menu & Dropdown */
.user-menu-wrap {
  position: relative;
}
.user-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  font-weight: 500;
  transition: all 120ms ease;
}
.user-profile-btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hairline-strong);
}
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--brand-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
[data-theme="dark"] .user-avatar {
  background: var(--brand-cyan);
  color: #0A2259;
}
.user-role-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 6px;
  min-width: 170px;
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
}
[dir="rtl"] .user-menu-dropdown {
  right: auto;
  left: 0;
}
.user-menu-dropdown.open {
  display: flex;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: var(--font-size-xs);
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 120ms ease;
}
[dir="rtl"] .dropdown-item {
  text-align: right;
}
.dropdown-item:hover {
  background: var(--bg-surface-hover);
}
.dropdown-item.text-danger {
  color: var(--status-bad-text);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 54px;
    bottom: 0;
    left: 0;
    z-index: 150;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  [dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .top-search-btn {
    min-width: auto;
  }
  .top-search-btn span, .top-search-btn kbd {
    display: none;
  }
}

/* --- Admin Dashboard & Sales Review Specialized Layouts --- */

/* 1. Hero Event Target Section */
.hero-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.hero-title-group { display: flex; align-items: baseline; gap: 12px; }
.hero-number {
  font-family: var(--font-display);
  font-size: var(--font-size-hero);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--brand-navy-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-unit { font-size: 18px; font-weight: 600; color: var(--text-muted); }
.hero-sub { font-size: var(--font-size-sm); color: var(--text-muted); }

/* Single Track with 3 Direct Thin Markers */
.track-container {
  margin-top: 14px;
  position: relative;
  padding-bottom: 30px;
}
.single-track {
  height: 8px;
  background: var(--bg-surface-hover);
  border-radius: 4px;
  position: relative;
  overflow: visible;
}
.track-fill-collected {
  height: 100%;
  width: 63.6%;
  background: var(--brand-cyan);
  border-radius: 4px;
}
.track-marker {
  position: absolute;
  top: -3px;
  height: 14px;
  width: 2px;
  background: var(--brand-navy);
  z-index: 2;
}
[data-theme="dark"] .track-marker { background: #C9D4EA; }
.marker-label {
  position: absolute;
  top: 16px;
  transform: translateX(-50%);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-secondary);
}
.marker-label span {
  font-weight: 400;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Horizontal Timeline with Today Marker */
.timeline-bar {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}
.timeline-track-line {
  position: absolute;
  top: 24px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-hairline);
  z-index: 1;
}
.timeline-node {
  position: relative;
  z-index: 2;
  background: var(--bg-surface);
  padding: 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-hairline-strong);
}
.timeline-node.today .timeline-dot {
  background: var(--brand-cyan);
  box-shadow: 0 0 0 3px rgba(0, 196, 204, 0.2);
}
.timeline-node.today .node-label {
  color: var(--brand-navy-text);
  font-weight: 700;
}

/* 2. Exactly 5 KPI Tiles in One Row at 1280 */
.kpi-row-5 {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
@media (max-width: 1024px) {
  .kpi-row-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .kpi-row-5 { grid-template-columns: 1fr; }
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.kpi-title {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-amount {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-navy-text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.kpi-desc { font-size: var(--font-size-xs); color: var(--text-muted); margin-top: 4px; }

/* 3. Attention Items (Quiet List) */
.attention-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.attention-header {
  font-size: var(--font-size-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.attention-list { display: flex; flex-direction: column; gap: 6px; }
.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-canvas);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}
.attention-left { display: flex; align-items: center; gap: 10px; }
.attention-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--brand-navy-text);
  font-variant-numeric: tabular-nums;
}
.attention-link {
  color: var(--brand-navy-text);
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.attention-link:hover { text-decoration: underline; }

/* 4. Class Pool Hierarchy Cards */
.class-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .class-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .class-grid { grid-template-columns: 1fr; } }
.class-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  transition: all 120ms ease;
}
.class-card:hover { border-color: var(--border-hairline-strong); background: var(--bg-surface-hover); }
.class-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.class-pill {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #FFFFFF;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.pill-a { background: var(--class-a); }
.pill-b { background: var(--class-b); }
.pill-c { background: var(--class-c); }
.pill-d { background: var(--class-d); }
[data-theme="dark"] .class-pill { color: #0B1220; }

/* 5. Bulk Action Toolbar */
.bulk-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-lg);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.bulk-count {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--brand-navy-text);
  font-size: var(--font-size-sm);
}

/* 6. POA Pricing Card */
.poa-approval-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.poa-input {
  height: 32px;
  padding: 0 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  outline: none;
}
.poa-input:focus { border-color: var(--brand-navy-text); }

/* 7. HubSpot Deal Chip */
.hubspot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFF7ED;
  color: #C2410C;
  border: 1px solid #FFEDD5;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-decoration: none;
}
[data-theme="dark"] .hubspot-chip {
  background: rgba(194, 65, 12, 0.2);
  border-color: rgba(194, 65, 12, 0.4);
  color: #FDBA74;
}

/* 8. Immutable Audit Log Entries */
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--font-size-xs);
}
.audit-entry {
  display: flex;
  gap: 8px;
  color: var(--text-secondary);
}
.audit-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-navy-text);
  margin-top: 5px;
  flex-shrink: 0;
}
.audit-time { font-family: monospace; color: var(--text-muted); }

/* 9. Fixed Floating Shortcut Hint */
.shortcut-hint {
  position: fixed;
  bottom: 12px;
  right: 16px;
  z-index: 10;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  font-size: 10px;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  opacity: 0.85;
}
.shortcut-hint:hover { opacity: 1; }
[dir="rtl"] .shortcut-hint { right: auto; left: 16px; }

/* 10. Disabled Row / Tooltip */
.row-disabled {
  opacity: 0.75;
}

/* Filter Chips: .badge style pills with a count, active one navy text on surface-hover */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-surface);
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all 120ms ease;
}
.filter-chip:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.filter-chip.active {
  background: var(--bg-surface-hover);
  color: var(--brand-navy-text);
  border-color: var(--border-hairline-strong);
  font-weight: 600;
}
.filter-chip .chip-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  color: var(--text-muted);
}
.filter-chip.active .chip-count {
  color: var(--brand-navy-text);
  background: var(--bg-surface);
}

/* Ghost User Menu */
.user-ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  transition: all 120ms ease;
}
.user-ghost-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}
.user-ghost-btn .user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-navy);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}
[data-theme="dark"] .user-ghost-btn .user-avatar {
  background: #C9D4EA;
  color: #0B1220;
}
.user-ghost-btn .user-email {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-theme="dark"] .user-ghost-btn .user-email {
  color: var(--text-primary);
}
