:root {
  /* Brand & Accent */
  --brand: #0A2259;
  --brand-hover: #13306f;
  --accent: #00C4CC;
  --accent-dark: #008f96;
  --accent-contrast: #0A2259;

  /* Surfaces */
  --surface: #f4f6fa;
  --surface-raised: #ffffff;
  --surface-alt: #f0f3f9;
  --surface-hover: #f8fafe;
  --surface-active: #e8eef8;

  /* Borders */
  --border: #dfe4ee;
  --border-subtle: #c9d2e6;
  --border-dashed: #c9d2e6;

  /* Typography */
  --text: #15213a;
  --text-muted: #505d7a;
  --text-inverse: #ffffff;
  --text-brand: #0A2259;
  --text-brand-contrast: #ffffff;

  /* Semantic Feedback */
  --success: #155c32;
  --success-bg: #e7f6ec;
  --success-border: #b7ecc9;
  --warning: #7c4a03;
  --warning-bg: #fff4e0;
  --warning-border: #f1d87a;
  --danger: #a51d24;
  --danger-bg: #fde8e6;
  --danger-border: #f9c2bd;
  --info: #00686d;
  --info-bg: #e8f8f9;
  --info-border: #b7ecef;
  --hs-brand: #d94826;
  --hs-brand-bg: #fff0eb;
  --hs-brand-border: #fed7cd;

  /* Form & Controls */
  --input-bg: #eef2ff;
  --input-readonly-bg: #eef1f6;
  --track-bg: #e6eaf3;

  /* Banners */
  --demo-bg: #fff3cd;
  --demo-text: #6b4f00;
  --demo-border: #f1d87a;
  --proposed-bg: #e8f8f9;
  --proposed-text: #0b5c60;
  --proposed-border: #b7ecef;
  --approved-bg: #e7f6ec;
  --approved-text: #155c32;
  --approved-border: #b7ecc9;

  /* Navigation & Sidebar */
  --topbar-bg: #ffffff;
  --topbar-border: #dfe4ee;
  --sidebar-bg: #0A2259;
  --sidebar-border: #13306f;
  --sidebar-text: #cfd8ea;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-hover-text: #ffffff;
  --sidebar-active-bg: #00C4CC;
  --sidebar-active-text: #0A2259;
  --overlay-bg: rgba(10, 34, 89, 0.5);

  /* Spacing */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* Radius */
  --r1: 8px;
  --r2: 12px;
  --r3: 16px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-1: 0 1px 3px rgba(10, 34, 89, 0.08), 0 1px 2px rgba(10, 34, 89, 0.05);
  --shadow-2: 0 4px 6px -1px rgba(10, 34, 89, 0.08), 0 10px 24px rgba(10, 34, 89, 0.08);

  /* Fonts */
  --font-en: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;

  /* Legacy aliases for backward compatibility */
  --navy: var(--brand);
  --navy-2: var(--brand-hover);
  --cyan: var(--accent);
  --cyan-dark: var(--accent-dark);
  --ink: var(--text);
  --muted: var(--text-muted);
  --bg: var(--surface);
  --card: var(--surface-raised);
  --line: var(--border);
  --ok: var(--success);
  --warn: var(--warning);
  --bad: var(--danger);
  --input: var(--input-bg);
  --radius: var(--r2);
  --shadow: var(--shadow-2);
  --transparent: transparent;
}

html[data-theme="dark"] {
  /* Brand & Accent */
  --brand: #60a5fa;
  --brand-hover: #93c5fd;
  --accent: #00e5ee;
  --accent-dark: #00C4CC;
  --accent-contrast: #0b1120;

  /* Surfaces */
  --surface: #0b1120;
  --surface-raised: #131d35;
  --surface-alt: #1a2644;
  --surface-hover: #1e2d52;
  --surface-active: #243560;

  /* Borders */
  --border: #233358;
  --border-subtle: #2e4372;
  --border-dashed: #3b528a;

  /* Typography */
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-inverse: #0b1120;
  --text-brand: #93c5fd;
  --text-brand-contrast: #0b1120;

  /* Semantic Feedback */
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.15);
  --success-border: rgba(52, 211, 153, 0.35);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.15);
  --warning-border: rgba(251, 191, 36, 0.35);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.15);
  --danger-border: rgba(248, 113, 113, 0.35);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.15);
  --info-border: rgba(56, 189, 248, 0.35);
  --hs-brand: #ff8f73;
  --hs-brand-bg: rgba(255, 122, 89, 0.2);
  --hs-brand-border: rgba(255, 122, 89, 0.4);

  /* Form & Controls */
  --input-bg: #1a2644;
  --input-readonly-bg: #10192e;
  --track-bg: #233358;

  /* Banners */
  --demo-bg: rgba(251, 191, 36, 0.2);
  --demo-text: #fde68a;
  --demo-border: rgba(251, 191, 36, 0.4);
  --proposed-bg: rgba(56, 189, 248, 0.18);
  --proposed-text: #bae6fd;
  --proposed-border: rgba(56, 189, 248, 0.35);
  --approved-bg: rgba(52, 211, 153, 0.18);
  --approved-text: #a7f3d0;
  --approved-border: rgba(52, 211, 153, 0.35);

  /* Navigation & Sidebar */
  --topbar-bg: #131d35;
  --topbar-border: #233358;
  --sidebar-bg: #0d172e;
  --sidebar-border: #233358;
  --sidebar-text: #94a3b8;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-hover-text: #f1f5f9;
  --sidebar-active-bg: #00e5ee;
  --sidebar-active-text: #0b1120;
  --overlay-bg: rgba(0, 0, 0, 0.7);

  /* Spacing */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* Radius */
  --r1: 8px;
  --r2: 12px;
  --r3: 16px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-1: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-2: 0 4px 6px -1px rgba(0, 0, 0, 0.6), 0 10px 24px rgba(0, 0, 0, 0.6);

  /* Fonts */
  --font-en: 'Inter', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;

  /* Legacy aliases */
  --navy: var(--brand);
  --navy-2: var(--brand-hover);
  --cyan: var(--accent);
  --cyan-dark: var(--accent-dark);
  --ink: var(--text);
  --muted: var(--text-muted);
  --bg: var(--surface);
  --card: var(--surface-raised);
  --line: var(--border);
  --ok: var(--success);
  --warn: var(--warning);
  --bad: var(--danger);
  --input: var(--input-bg);
  --radius: var(--r2);
  --shadow: var(--shadow-2);
  --transparent: transparent;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  overflow-x: hidden;
}
html[dir="rtl"] body { font-family: var(--font-ar); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { color: var(--text); margin: 0 0 var(--s2); line-height: 1.25; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.1rem; } h3 { font-size: 1rem; }
.hidden { display: none !important; }

/* Banners (Slim Bar under Header) */
.banners-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.banner {
  padding: var(--s2) var(--s4);
  font-size: 0.85rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
}
.banner.demo {
  background: var(--demo-bg);
  color: var(--demo-text);
  border-bottom: 1px solid var(--demo-border);
  font-weight: 600;
}
.banner.proposed {
  background: var(--proposed-bg);
  color: var(--proposed-text);
  border-bottom: 1px solid var(--proposed-border);
}
.banner.approved {
  background: var(--approved-bg);
  color: var(--approved-text);
  border-bottom: 1px solid var(--approved-border);
}

/* Header (Slim Top Bar) */
header.top {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  z-index: 40;
}
header.top .wrap {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s2) var(--s4);
  max-width: 1600px;
  margin: 0 auto;
}
header.top img.logo {
  height: 40px;
  width: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}
header.top .title {
  font-weight: 700;
  color: var(--text-brand);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
}
header.top .title small {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.75rem;
}
header.top .spacer { flex: 1; }
header.top .who {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0 var(--s2);
}

/* Policy Status Chip */
.chip-status {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-inline-start: var(--s2);
}
.chip-status.proposed {
  background: var(--proposed-bg);
  color: var(--proposed-text);
  border: 1px solid var(--proposed-border);
}
.chip-status.approved {
  background: var(--approved-bg);
  color: var(--approved-text);
  border: 1px solid var(--approved-border);
}

/* Buttons & Focus Rings (Step 1.5 & Step 1.6) */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn {
  border: 1px solid var(--border-hairline, #E6EAF2);
  background: var(--bg-surface, #FFFFFF);
  color: var(--text-primary, #15213A);
  padding: 0 12px;
  border-radius: var(--radius-md, 6px);
  cursor: pointer;
  height: 32px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-sizing: border-box;
  text-decoration: none;
  transition: all 0.12s ease;
}
.btn:hover {
  background: var(--bg-surface-hover, #F4F6FA);
}
.btn.secondary {
  background: var(--transparent);
  color: var(--text);
  border: 1px solid var(--border-subtle);
}
.btn.secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.btn.accent {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--text-inverse);
}
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--text-inverse);
}
.btn.small {
  padding: var(--s1) var(--s3);
  min-height: 40px;
  font-size: 0.85rem;
  box-sizing: border-box;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.full {
  width: 100%;
}
.theme-btn {
  font-size: 1rem;
  padding: var(--s1) var(--s2);
}

/* Icon button */
.btn-icon {
  background: var(--transparent);
  border: 0;
  color: var(--sidebar-text);
  cursor: pointer;
  padding: var(--s1);
  border-radius: var(--r1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
}
.btn-icon:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}
.mobile-menu-btn {
  display: none;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border-subtle);
  min-height: 36px;
  min-width: 36px;
  padding: var(--s1);
  border-radius: var(--r1);
}

/* Layout Shell: Sidebar + Main Content */
.app-layout {
  display: flex;
  min-height: calc(100vh - 60px);
  position: relative;
}

/* Desktop Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease, transform 0.25s ease;
  z-index: 30;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s3);
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s2);
  overflow-y: auto;
  flex: 1;
}
.sidebar-tabs button {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  padding: var(--s2) var(--s3);
  border-radius: var(--r1);
  background: var(--transparent);
  color: var(--sidebar-text);
  border: 0;
  cursor: pointer;
  min-height: 40px;
  font-size: 0.88rem;
  text-align: start;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.sidebar-tabs button svg {
  flex-shrink: 0;
}
.sidebar-tabs button:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}
.sidebar-tabs button.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
}

/* Collapsed Sidebar on Desktop */
.app-layout.collapsed .sidebar {
  width: 64px;
}
.app-layout.collapsed .sidebar .sidebar-title,
.app-layout.collapsed .sidebar .tab-label {
  display: none;
}
.app-layout.collapsed .sidebar .sidebar-header {
  justify-content: center;
}
.app-layout.collapsed .sidebar-tabs button {
  justify-content: center;
  padding: var(--s2);
}

/* Sidebar Footer (for mobile controls F1) */
.sidebar-footer {
  padding: var(--s3);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.sidebar-footer .sidebar-user {
  font-size: 0.85rem;
  color: var(--sidebar-text);
  font-weight: 600;
  margin-bottom: var(--s1);
}
.sidebar-footer .sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.sidebar-footer .sidebar-actions .btn {
  width: 100%;
  justify-content: flex-start;
}

/* Main Content Area */
.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--s4);
}
main {
  max-width: 1400px;
  margin: 0 auto;
}

/* Admin Dashboard Stack */
.admin-dashboard-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

/* 1. Hero Card */
.hero-card {
  padding: var(--s4);
}
.hero-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.hero-title-group {
  display: flex;
  align-items: baseline;
  gap: var(--s2);
  flex-wrap: wrap;
}
.hero-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-target-val {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}
.hero-track-wrap {
  margin: var(--s3) 0;
}
.hero-track {
  height: 18px;
  background: var(--track-bg);
  border-radius: var(--r-pill);
  position: relative;
  overflow: hidden;
}
.hero-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  border-radius: var(--r-pill);
  transition: width 0.3s ease;
}
.hero-bar.booked {
  background: var(--brand);
  z-index: 1;
}
.hero-bar.collected {
  background: var(--accent);
  z-index: 2;
}
.hero-bar.eligible {
  background: var(--success);
  z-index: 3;
}
.hero-markers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s3);
  margin-top: var(--s2);
}
.hero-marker {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border-radius: var(--r1);
  border: 1px solid var(--border);
}
.marker-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--r-pill);
  margin-top: 4px;
  flex-shrink: 0;
}
.marker-dot.brand { background: var(--brand); }
.marker-dot.accent { background: var(--accent); }
.marker-dot.success { background: var(--success); }
.marker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.marker-name {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.marker-num {
  font-size: 1.05rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.marker-pct {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: normal;
}

/* 2. KPI row (5 cards / 9 cards F2) */
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--shadow-1);
  padding: var(--s4);
}
.kpi .label { color: var(--text-muted); font-size: 0.8rem; }
.kpi .value { font-size: 1.35rem; font-weight: 700; color: var(--text-brand); margin-top: var(--s1); font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--text-muted); font-size: 0.78rem; margin-top: 2px; }
.kpi.accent { border-top: 4px solid var(--accent); }
.meter { height: 10px; background: var(--track-bg); border-radius: var(--r1); overflow: hidden; margin: var(--s1) 0; }
.meter > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); }

@media (min-width: 1100px) {
  .grid.kpis.kpis-5 {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}
@media (min-width: 900px) {
  .grid.kpis.kpis-6 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
  .grid.kpis.kpis-9 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}
@media (min-width: 1200px) {
  .grid.kpis.kpis-6 {
    grid-template-columns: repeat(6, 1fr) !important;
  }
}

/* 3. Money Flow Card */
.money-flow-card {
  padding: var(--s4);
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}
.card-header-row h3 {
  margin: 0;
}
.money-flow-body {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.flow-row {
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border-radius: var(--r1);
  border: 1px solid var(--border);
}
.flow-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s2);
  flex-wrap: wrap;
  gap: var(--s1);
}
.flow-title {
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.flow-weight {
  color: var(--text-muted);
  font-weight: normal;
}
.flow-pool {
  font-size: 0.95rem;
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}
.flow-track-wrap {
  margin-bottom: var(--s1);
}
.flow-track {
  height: 14px;
  background: var(--track-bg);
  border-radius: var(--r1);
  display: flex;
  overflow: hidden;
}
.flow-bar.ent {
  background: var(--brand);
  transition: width 0.3s ease;
}
.flow-bar.res {
  background: var(--border-subtle);
  transition: width 0.3s ease;
}
.flow-details {
  display: flex;
  gap: var(--s4);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: var(--s1);
  flex-wrap: wrap;
}
.flow-stat {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
}
.flow-stat .dot {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
}
.flow-stat.brand .dot { background: var(--brand); }
.flow-stat.muted .dot { background: var(--border-subtle); }
.money-flow-footer {
  margin-top: var(--s3);
  padding-top: var(--s2);
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* 4. Deadlines Timeline Card */
.timeline-card {
  padding: var(--s4);
}
.today-chip {
  font-size: 0.8rem;
}
.timeline-track-wrap {
  position: relative;
  padding: var(--s4) var(--s2) var(--s2);
}
.timeline-desktop-track {
  position: relative;
  padding: var(--s2) 0;
}
.timeline-line {
  position: absolute;
  top: 31px;
  inset-inline-start: var(--s5);
  inset-inline-end: var(--s5);
  height: 3px;
  background: var(--border-subtle);
  z-index: 1;
}
.timeline-nodes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--s2);
  position: relative;
  z-index: 2;
}
.timeline-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s1);
}
.node-marker {
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--surface-raised);
  border: 3px solid var(--brand);
  transition: transform 0.18s ease;
}
.timeline-node.solid .node-marker {
  border-color: var(--brand);
  background: var(--accent);
}
.timeline-node.past .node-marker {
  border-color: var(--border-subtle);
  background: var(--surface-alt);
}
.timeline-node.past {
  opacity: 0.65;
}
.node-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-top: var(--s1);
}
.node-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.timeline-today-marker {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 3;
  pointer-events: none;
}
.timeline-today-marker.clamped-start {
  transform: none;
}
[dir="rtl"] .timeline-today-marker {
  transform: translateX(50%);
}
[dir="rtl"] .timeline-today-marker.clamped-start {
  transform: none;
}
.today-pin {
  background: var(--brand);
  color: var(--text-inverse);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--r-pill);
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
.today-line {
  width: 2px;
  height: 22px;
  background: var(--brand);
}

/* Mobile Timeline (Fix F5: vertical list) */
.timeline-mobile-list {
  display: none;
}
@media (max-width: 767px) {
  .timeline-desktop-track {
    display: none;
  }
  .timeline-mobile-list {
    display: flex;
    flex-direction: column;
    gap: var(--s2);
    margin-top: var(--s2);
  }
  .timeline-mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s2) var(--s3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r1);
    gap: var(--s2);
  }
  .timeline-mobile-row.today-row {
    background: var(--surface-alt);
    border-color: var(--brand);
  }
  .tm-date-col {
    display: flex;
    align-items: center;
    gap: var(--s2);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
  }
  .tm-marker {
    width: 12px;
    height: 12px;
    border-radius: var(--r-pill);
    background: var(--accent);
    border: 2px solid var(--brand);
    flex-shrink: 0;
  }
  .tm-marker.today {
    background: var(--brand);
    border-color: var(--brand);
  }
  .timeline-mobile-row.past .tm-marker {
    background: var(--surface-alt);
    border-color: var(--border-subtle);
  }
  .timeline-mobile-row.past {
    opacity: 0.7;
  }
  .tm-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: end;
  }
}

/* 5. Needs Attention Card */
.attention-card {
  padding: var(--s4);
}
.attention-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin-top: var(--s2);
}
.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s2) var(--s3);
  border-radius: var(--r1);
  background: var(--surface);
  border: 1px solid var(--border);
  gap: var(--s2);
}
.attention-label-group {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.attention-text {
  font-size: 0.9rem;
  color: var(--text);
}
.icon-tick {
  color: var(--success);
  font-weight: bold;
  font-size: 1.1rem;
  line-height: 1;
}
.text-clean {
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 600;
}

/* 6. Tables (Zebra + Sticky Header) */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r1); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; white-space: nowrap; }
th { background: var(--surface-alt); color: var(--text-brand); font-weight: 600; position: sticky; top: 0; z-index: 5; }
td.num, th.num { text-align: end; font-variant-numeric: tabular-nums; }
table tbody tr:nth-child(even) td { background: var(--surface-alt); }
table tbody tr:hover td { background: var(--surface-hover); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--s2);
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  vertical-align: middle;
}
.pill-icon {
  font-size: 0.88em;
  font-weight: 700;
  line-height: 1;
}
.pill.ok { background: var(--success-bg); color: var(--success); }
.pill.warn { background: var(--warning-bg); color: var(--warning); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.muted { background: var(--surface-alt); color: var(--text-muted); }

/* Forms & Inputs (Step 1.5) */
.form { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form label { display: flex; flex-direction: column; gap: var(--s1); font-size: 0.85rem; color: var(--text-muted); }
.form input, .form select, .form textarea, .filters input, .filters select {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r1);
  background: var(--input-bg);
  min-height: 42px;
  color: var(--text);
  width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus, .filters input:focus, .filters select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.form .row,
.form .full.row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s2);
}

/* Personal Gate Card (Step 1.4) */
.gate-card {
  padding: var(--s4);
}
.gate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s2);
}
.gate-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.gate-track {
  height: 16px;
  background: var(--track-bg);
  border-radius: var(--r-pill);
  overflow: hidden;
  position: relative;
  margin: var(--s2) 0;
}
.gate-fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--r-pill);
  transition: width 0.18s ease;
}
.gate-fill.ok {
  background: var(--success);
}
.gate-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Commission Calculation Breakdown Card (Step 1.4) */
.calc-breakdown {
  padding: 0 !important;
  overflow: hidden;
}
.calc-breakdown summary {
  padding: var(--s3) var(--s4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  user-select: none;
  background: var(--surface-alt);
  color: var(--text);
  transition: background 0.18s ease;
}
.calc-breakdown summary:hover {
  background: var(--surface-hover);
}
.calc-breakdown summary h3 {
  margin: 0;
  font-size: 0.95rem;
}
.calc-breakdown-body {
  padding: var(--s4);
  border-top: 1px solid var(--border);
}
.band-chip {
  display: inline-block;
  padding: 2px 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r1);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  margin-inline-end: 4px;
}

/* What-If Slide-Over Panel (Step 1.4 & Fix F9) */
.slide-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  width: min(560px, 100vw);
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface-raised);
  border-inline-start: 1px solid var(--border);
  box-shadow: var(--shadow-2);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.18s ease;
  overflow: hidden;
}
[dir="rtl"] .slide-panel {
  transform: translateX(-100%);
}
.slide-panel.open {
  transform: translateX(0);
}
.slide-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.slide-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.slide-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
}
.slide-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
}
.slide-panel-body {
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.slide-panel .form-actions {
  position: sticky;
  bottom: 0;
  background: var(--surface-raised);
  padding: var(--s2) 0;
  border-top: 1px solid var(--border);
  z-index: 10;
  margin-top: auto;
}
.form .full { grid-column: 1 / -1; }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.filters { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.filters > * { flex: 1 1 150px; }
.msg { padding: var(--s2) var(--s3); border-radius: var(--r1); margin: var(--s2) 0; font-size: 0.9rem; }
.msg.ok { background: var(--success-bg); color: var(--success); }
.msg.bad { background: var(--danger-bg); color: var(--danger); }
.msg.info { background: var(--info-bg); color: var(--info); }
.help { color: var(--text-muted); font-size: 0.82rem; }
.lineform { border: 1px dashed var(--border-dashed); border-radius: var(--r1); padding: var(--s3); margin-bottom: var(--s2); }

/* Charts & Bars (Fix F3 Compact Empty State) */
.bars { display: grid; gap: var(--s1); }
.bar { display: grid; grid-template-columns: minmax(120px, 35%) 1fr auto; gap: var(--s2); align-items: center; font-size: 0.82rem; }
.bar .track { height: 12px; background: var(--track-bg); border-radius: var(--r1); overflow: hidden; }
.bar .track > span { display: block; height: 100%; background: var(--brand); }
.bar .track > span.alt { background: var(--accent); }
.bar .val { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s3);
  color: var(--text-muted);
  font-size: 0.88rem;
  min-height: 48px;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  text-align: center;
  line-height: 1.4;
}
.empty-state span {
  white-space: normal;
  word-break: break-word;
  overflow-wrap: break-word;
}
td.empty-state-cell, td:has(.empty-state) {
  white-space: normal !important;
}
.empty-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Login */
.login {
  max-width: 420px;
  width: calc(100% - var(--s4) * 2);
  margin: var(--s6) auto;
  box-sizing: border-box;
}
.login img { height: 80px; width: auto; display: block; margin: 0 auto var(--s4); }
.manual h3 { margin-top: var(--s4); } .manual p, .manual li { font-size: 0.92rem; }
.toast {
  position: fixed;
  bottom: var(--s4);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: var(--text-inverse);
  padding: var(--s2) var(--s4);
  border-radius: var(--r1);
  z-index: 60;
  box-shadow: var(--shadow-2);
}
html[dir="rtl"] .toast { transform: translateX(50%); }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }

td form.row { flex-wrap: nowrap; gap: var(--s1); }
td input, td select { min-height: 34px; padding: var(--s1) var(--s2); }

/* Policy Page */
.pform h3 { margin: var(--s5) 0 var(--s2); padding-bottom: var(--s1); border-bottom: 2px solid var(--accent); }
.pgrid { display: grid; gap: var(--s3) var(--s5); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: var(--s2); }
.pfield label { display: block; font-weight: 600; color: var(--text); font-size: 0.9rem; margin-bottom: var(--s1); }
.pfield input, .pfield select {
  width: 100%;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r1);
  background: var(--input-bg);
  min-height: 44px;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  color: var(--text);
}
.pfield input[readonly] { background: var(--input-readonly-bg); color: var(--text-muted); }
.pinput.unit { position: relative; }
.pinput.unit .adorn { position: absolute; inset-inline-end: var(--s3); top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.85rem; pointer-events: none; }
.pinput.unit input { padding-inline-end: 3.2rem; }
.phelp { margin: var(--s1) 0 0; font-size: 0.8rem; line-height: 1.45; color: var(--text-muted); }
.ptier { border: 1px dashed var(--border-dashed); border-radius: var(--r2); padding: var(--s3) var(--s3) var(--s2); margin-bottom: var(--s2); }

/* Mobile (< 768px) and Slide-in Menu (Fix F1) */
@media (max-width: 767px) {
  .mobile-menu-btn {
    display: inline-flex !important;
  }
  .collapse-btn {
    display: none !important;
  }
  .topbar-desktop-only {
    display: none !important;
  }
  .title-desktop {
    display: none !important;
  }
  .title-mobile {
    display: inline-block !important;
    font-weight: 700;
    color: var(--text-brand);
    font-size: 1rem;
  }
  .sidebar-footer {
    display: flex !important;
  }
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 270px;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: var(--shadow-2);
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  .app-layout.mobile-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 90;
  }
  .app-layout.mobile-open .sidebar-overlay {
    display: block;
  }
  header.top .title small { display: none; }
  header.top .title { font-size: 0.85rem; }
  header.top .wrap { gap: var(--s2); padding: var(--s2); }
  header.top img.logo { height: 36px; }
  .main-content { padding: var(--s2); }
  .card { padding: var(--s3); }
  .login { margin: var(--s4) auto; width: calc(100% - var(--s3) * 2); }
  th, td { padding: var(--s1) var(--s2); }
  .pgrid { grid-template-columns: 1fr; }
  .phelp { font-size: 0.82rem; }
  .timeline-nodes {
    grid-template-columns: 1fr;
    gap: var(--s3);
    align-items: flex-start;
  }
  .timeline-line {
    display: none;
  }
  .timeline-node {
    flex-direction: row;
    align-items: center;
    gap: var(--s3);
    text-align: start;
  }
}

/* HubSpot Integration Styles */
.chip-hs {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--s2);
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--hs-brand-bg);
  color: var(--hs-brand);
  border: 1px solid var(--hs-brand-border);
  margin-inline-start: var(--s1);
  vertical-align: middle;
}
.chip-hs-warn {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--s2);
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
  margin-inline-start: var(--s1);
  vertical-align: middle;
}
.hs-conn-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s3);
}
.hs-conn-status {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.hs-conn-details {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s4);
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: var(--s2) 0;
  border-top: 1px solid var(--border);
}
.hs-conn-actions {
  display: flex;
  gap: var(--s2);
  align-items: center;
  flex-wrap: wrap;
}
.hs-preview-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-bottom: var(--s3);
}

/* Collapsible card (Fix F7) */
.collapsible-card {
  transition: all 0.2s ease;
}
.collapsible-card summary.collapsible-header {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
.collapsible-card summary.collapsible-header::-webkit-details-marker {
  display: none;
}
.collapsible-card summary.collapsible-header h3 {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
}
.collapsible-card .collapse-icon {
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}
.collapsible-card[open] .collapse-icon {
  transform: rotate(180deg);
}
.collapsible-body {
  margin-top: var(--s3);
  padding-top: var(--s3);
  border-top: 1px solid var(--border);
}

/* HubSpot Mobile Table Horizontal Scroll with First Column Sticky (Fix F8) */
@media (max-width: 767px) {
  .hs-sticky-first th:first-child,
  .hs-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 6;
    background: var(--surface-raised);
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
  }
  .hs-sticky-first th:first-child {
    background: var(--surface-alt);
    z-index: 8;
  }
  .hs-sticky-first tr:nth-child(even) td:first-child {
    background: var(--surface-alt);
  }
  .hs-sticky-first tr:hover td:first-child {
    background: var(--surface-hover);
  }
  html[dir="rtl"] .hs-sticky-first th:first-child,
  html[dir="rtl"] .hs-sticky-first td:first-child {
    left: auto;
    right: 0;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.08);
  }
}

@media (min-width: 768px) {
  .mobile-menu-btn {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .title-mobile {
    display: none !important;
  }
  .sidebar-footer {
    display: none !important;
  }
}

.calc-container {
  display: grid;
  gap: var(--s4);
  grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
  align-items: start;
}
@media (max-width: 900px) {
  .calc-container {
    grid-template-columns: 1fr;
  }
}
.table-compact td,
.table-compact th {
  padding: var(--s2) var(--s1);
}

/* Loading skeletons & indicators */
.skeleton-view {
  display: flex;
  flex-direction: column;
  gap: var(--s3, 1rem);
  width: 100%;
}
.skeleton {
  background: linear-gradient(90deg, var(--surface, #ffffff) 25%, var(--border, #e2e8f0) 50%, var(--surface, #ffffff) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s infinite ease-in-out;
  border-radius: var(--r2, 8px);
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.loading-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}


