/* ============================================================
   GBS Forecast v2 — premium SaaS chrome with sidebar layout
   Inspired by Causal / Mosaic / Pigment / Linear / Runway
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Brand */
  --brand-950: #0a1326;
  --brand-900: #0f1c35;
  --brand-800: #1B2A4A;
  --brand-700: #243a66;
  --brand-600: #344f86;
  --brand-100: #e8edf6;
  --brand-50:  #f4f6fb;

  /* Sidebar */
  --side-bg:    #0f1c35;
  --side-bg-2:  #14233f;
  --side-fg:    rgba(255,255,255,0.72);
  --side-fg-mute: rgba(255,255,255,0.44);
  --side-border: rgba(255,255,255,0.08);
  --side-active-bg: rgba(255,255,255,0.08);
  --side-active-bd: rgba(255,255,255,0.14);

  /* Accent */
  --accent-600: #3b82f6;
  --accent-500: #4f8df9;
  --accent-50:  #eef4ff;

  /* Semantic */
  --success-700: #15803d;
  --success-600: #16a34a;
  --success-100: #dcfce7;
  --success-50:  #f0fdf4;
  --danger-700:  #b91c1c;
  --danger-600:  #dc2626;
  --danger-50:   #fef2f2;
  --warning-700: #b45309;
  --warning-600: #d97706;
  --warning-50:  #fffbeb;
  --info-600:    #0284c7;
  --info-50:     #f0f9ff;

  /* Neutrals */
  --surface:    #ffffff;
  --canvas:     #f8fafc;
  --canvas-2:   #f1f5f9;
  --canvas-3:   #e2e8f0;
  --border:     #e5e9f0;
  --border-2:   #eef1f6;
  --border-3:   #f3f5f9;
  --ink-950:    #060912;
  --ink-900:    #0f172a;
  --ink-800:    #1e293b;
  --ink-700:    #334155;
  --ink-600:    #475569;
  --ink-500:    #64748b;
  --ink-400:    #94a3b8;
  --ink-300:    #cbd5e1;
  --ink-200:    #e2e8f0;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* Shadows — soft, layered, financial-feel */
  --shadow-xs: 0 1px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -8px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 1px 2px rgba(15, 23, 42, 0.04), 0 24px 48px -16px rgba(15, 23, 42, 0.18);

  /* Spacing */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px; --sp-7: 32px; --sp-8: 40px; --sp-9: 48px; --sp-10: 64px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --side-w: 240px;
  --side-w-collapsed: 64px;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-900);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01', 'ss03', 'cv02';
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}
.app-shell--collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }
.app-main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--canvas);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.side {
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--brand-950) 100%);
  color: var(--side-fg);
  border-right: 1px solid var(--side-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow: hidden;
}
.side__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--side-border);
  height: var(--header-h);
  min-width: 0; overflow: hidden;
}
.side__logo {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #fff 0%, #cfe6ff 100%);
  color: var(--brand-800);
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
  flex: 0 0 28px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4), 0 2px 6px rgba(0,0,0,0.25);
}
.side__brand-meta {
  display: flex; flex-direction: column; gap: 1px;
  min-width: 0; flex: 1 1 auto;
}
.side__brand-meta > span,
.side__brand-meta > small {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%; display: block;
}
.side__brand-meta small { color: var(--side-fg-mute); font-size: 11px; font-weight: 500; letter-spacing: 0.02em; }
.side__logo-img {
  height: 30px;
  width: auto;
  max-width: 170px;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
}

.side__group {
  padding: 14px 12px 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--side-fg-mute);
}
.side__nav {
  padding: 4px 10px;
  display: flex; flex-direction: column; gap: 1px;
}
.side__item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--side-fg);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, color 120ms ease;
  position: relative;
}
.side__item:hover {
  background: rgba(255,255,255,0.04);
  color: #fff;
}
.side__item.is-active {
  background: var(--side-active-bg);
  border-color: var(--side-active-bd);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.side__item.is-active::before {
  content: '';
  position: absolute;
  left: -10px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-500);
}
.side__item .ic { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.85; }
.side__item.is-active .ic { opacity: 1; }
.side__chip {
  margin-left: auto;
  font-size: 10.5px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--side-fg-mute);
}

.side__sep {
  margin: 8px 16px;
  height: 1px;
  background: var(--side-border);
}

.side__foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--side-border);
}
.side__user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.side__user:hover { background: rgba(255,255,255,0.04); }
.side__avatar {
  width: 30px; height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f0c084 0%, #cf8d3e 100%);
  color: #fff; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
  flex: 0 0 30px;
}
.side__user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side__user-meta strong { color: #fff; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side__user-meta small { color: var(--side-fg-mute); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.side__sync {
  margin: 0 14px 12px;
  padding: 12px 12px;
  border: 1px solid var(--side-border);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.025);
  font-size: 11.5px;
}
.side__sync-row { display: flex; align-items: center; gap: 8px; }
.side__sync-row + .side__sync-row { margin-top: 6px; }
.side__sync-label { color: var(--side-fg-mute); flex: 1; }
.side__sync-value { color: #fff; font-family: var(--font-mono); font-size: 11px; }

/* ============================================================
   PAGE HEADER (top bar inside main)
   ============================================================ */
.page-head {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex; align-items: center; gap: var(--sp-4);
  position: sticky; top: 0; z-index: 30;
}
.page-head > div:first-child { min-width: 0; flex: 1 1 auto; }
.page-head__title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink-900);
  margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-head__crumbs {
  color: var(--ink-500);
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-head__crumbs .sep { color: var(--ink-300); }
.page-head__right {
  margin-left: auto;
  display: flex; align-items: center; gap: var(--sp-3);
  flex: 0 0 auto;
}
@media (max-width: 1100px) {
  .page-head__search input { width: 200px; }
}
@media (max-width: 980px) {
  .page-head__crumbs { display: none; }
  .page-head__search input { width: 160px; }
  .page-head__kbd { display: none; }
}

.page-head__search {
  position: relative;
}
.page-head__search input {
  height: 34px;
  width: 280px;
  padding: 0 12px 0 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--canvas);
  font: 400 13px var(--font-sans);
  color: var(--ink-900);
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}
.page-head__search input:focus {
  outline: none;
  background: #fff;
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.14);
}
.page-head__search .ic {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-400);
}
.page-head__kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-400);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  background: #fff;
}

.iconbtn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-700);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  position: relative;
}
.iconbtn:hover { background: var(--canvas-2); color: var(--ink-900); }
.iconbtn__dot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 999px;
  background: var(--danger-600);
  border: 1.5px solid var(--surface);
}

/* ============================================================
   PAGE BODY
   ============================================================ */
.page-body { padding: 24px 28px 64px; min-width: 0; }
.page-body--flush { padding: 0; }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--ink-900);
}
.section-head p { margin: 0; color: var(--ink-500); font-size: 13.5px; }
.section-head__right { display: flex; align-items: center; gap: var(--sp-3); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 80ms ease, box-shadow 120ms ease, background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .ic { width: 14px; height: 14px; }

.btn--primary {
  background: var(--brand-800);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 1px 2px rgba(15,23,42,0.18), 0 6px 14px -6px rgba(27,42,74,0.5);
}
.btn--primary:hover {
  background: var(--brand-700);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 2px 4px rgba(15,23,42,0.2), 0 12px 22px -8px rgba(27,42,74,0.55);
}
.btn--accent {
  background: var(--accent-600);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.20), 0 1px 2px rgba(59,130,246,0.20), 0 6px 14px -6px rgba(59,130,246,0.55);
}
.btn--accent:hover { background: #2f74e6; }
.btn--success {
  background: var(--success-600);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.20), 0 1px 2px rgba(22,163,74,0.18), 0 6px 14px -6px rgba(22,163,74,0.5);
}
.btn--success:hover { background: var(--success-700); }
.btn--secondary {
  background: var(--surface);
  color: var(--ink-800);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover { border-color: var(--ink-300); background: var(--canvas-2); }
.btn--ghost { background: transparent; color: var(--ink-700); }
.btn--ghost:hover { background: var(--canvas-2); }
.btn--sm { padding: 6px 10px; font-size: 12px; }
.btn--lg { padding: 11px 18px; font-size: 14px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.card--hover:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.card__header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
}
.card__title {
  font-family: var(--font-display);
  font-size: 14px; font-weight: 700;
  letter-spacing: -0.005em;
  margin: 0;
  color: var(--ink-900);
}
.card__sub { font-size: 12px; color: var(--ink-500); margin-top: 3px; }
.card__body { padding: 22px; }
.card__body--flush { padding: 0; }

/* ============================================================
   SEGMENTED CONTROL (month tabs)
   ============================================================ */
.segmented {
  display: inline-flex;
  background: var(--canvas-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 1px;
}
.segmented button {
  padding: 6px 14px;
  border: 0; background: transparent;
  border-radius: var(--r-pill);
  font: 500 12.5px var(--font-sans);
  color: var(--ink-500);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
  letter-spacing: 0.01em;
}
.segmented button:hover { color: var(--ink-900); }
.segmented button.is-active {
  background: var(--surface);
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.segmented--lg button { padding: 8px 16px; font-size: 13px; }
.segmented--full { display: flex; }
.segmented--full button { flex: 1; }

/* ============================================================
   TOOLBAR / ACTION BAR
   ============================================================ */
.actionbar {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 16px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.actionbar__group { display: flex; gap: var(--sp-2); align-items: center; }
.actionbar__sep { width: 1px; height: 22px; background: var(--border); }
.actionbar__spacer { flex: 1; }

.statuspill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--canvas-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--ink-700);
  font-family: var(--font-sans);
}
.statuspill .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--success-600); }
.statuspill .dot--idle { background: var(--ink-300); }
.statuspill .dot--warn { background: var(--warning-600); }
.statuspill .dot--info { background: var(--accent-600); }
.statuspill--mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ============================================================
   GRID PAGE — table
   ============================================================ */
.grid-frame {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.grid-table {
  width: 100%;
  border-collapse: separate; border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.grid-table thead.grid-head--top th {
  background: var(--canvas);
  color: var(--ink-500);
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border-2);
  position: sticky; top: 0; z-index: 2;
}
.grid-table thead.grid-head--top th.is-label { text-align: left; }
.grid-table thead.grid-head--top th.is-group {
  text-align: center;
  background: var(--canvas-2);
  color: var(--ink-700);
  font-weight: 700;
  border-bottom-color: var(--border-2);
}
.grid-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-3);
  border-right: 1px solid var(--border-3);
  text-align: right;
  color: var(--ink-800);
  background: #fff;
}
.grid-table td.is-label {
  text-align: left;
  color: var(--ink-900);
  font-weight: 500;
  position: sticky; left: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  min-width: 240px;
  z-index: 1;
}
.grid-table tr.is-group td {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-700);
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.grid-table tr.is-group td .ic {
  width: 12px; height: 12px;
  vertical-align: -1px;
  margin-right: 6px;
  color: var(--ink-400);
}
.grid-table tr.is-total td {
  background: var(--canvas);
  color: var(--ink-900);
  font-weight: 700;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.grid-table tr.is-total td.is-label { background: var(--canvas); }
.grid-table tr.is-total td.is-label::before {
  content: '∑';
  font-family: var(--font-mono);
  color: var(--ink-400);
  margin-right: 8px;
  font-weight: 400;
}
.grid-table td.is-zero { color: var(--ink-300); font-weight: 400; }
.grid-table td.is-empty { background: #fcfcfd; }
.grid-table td.col-actual {
  background: var(--accent-50);
  color: var(--brand-800);
  font-weight: 600;
}
.grid-table td.col-vs--up { color: var(--success-700); font-weight: 600; background: #f5fbf7; }
.grid-table td.col-vs--down { color: var(--danger-700); font-weight: 600; background: #fef7f7; }
.grid-table td.col-fy {
  background: #f6f9ff;
  color: var(--brand-800);
  font-weight: 700;
}
.grid-table td.col-pct { color: var(--ink-500); font-size: 12px; }
.grid-table tbody tr:hover td:not(.is-label) { background: #fafcff; }
.grid-table tbody tr.is-group:hover td { background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%); }
.grid-table tbody tr.is-total:hover td { background: var(--canvas); }
.grid-table tbody tr:hover td.col-actual { background: var(--accent-50); }
.grid-table tbody tr:hover td.col-vs--up { background: #ecf7f0; }
.grid-table tbody tr:hover td.col-vs--down { background: #fdeded; }
.grid-table tbody tr:hover td.col-fy { background: #eef3fc; }

.grid-foot {
  display: flex; gap: var(--sp-5); align-items: center;
  padding: 14px 22px;
  background: var(--canvas);
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--ink-500);
}
.grid-legend { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.grid-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.grid-legend__sw { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }

/* ============================================================
   DASHBOARD
   ============================================================ */
.dash-row { display: grid; gap: 20px; }
.dash-row--kpi { grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; }
.dash-row--charts { grid-template-columns: 1fr 1fr; margin-bottom: 20px; }
.dash-row--split { grid-template-columns: 2fr 1fr; }

.kpi {
  position: relative;
  padding: 20px 22px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  overflow: hidden;
}
.kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.kpi__header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi__label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.kpi__icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-50);
  color: var(--brand-800);
  display: grid; place-items: center;
}
.kpi__icon--accent { background: var(--accent-50); color: var(--accent-600); }
.kpi__icon--success { background: var(--success-50); color: var(--success-600); }
.kpi__icon--warn { background: var(--warning-50); color: var(--warning-600); }
.kpi__value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-900);
  line-height: 1.05;
}
.kpi__row {
  margin-top: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.kpi__delta {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.kpi__delta--up { background: var(--success-50); color: var(--success-700); }
.kpi__delta--down { background: var(--danger-50); color: var(--danger-700); }
.kpi__hint { font-size: 11.5px; color: var(--ink-400); font-variant-numeric: tabular-nums; }
.kpi__spark { margin-top: 16px; height: 40px; }
.kpi__progress {
  margin-top: 14px;
  height: 6px;
  border-radius: 999px;
  background: var(--canvas-2);
  overflow: hidden;
  position: relative;
}
.kpi__progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-700), var(--accent-500));
  border-radius: 999px;
}
.kpi__progress-bar--success { background: linear-gradient(90deg, var(--success-700), var(--success-600)); }

/* charts */
.chart-axis text {
  fill: var(--ink-400);
  font: 11px var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.chart-grid line { stroke: var(--border-2); }
.chart-grid line.zero { stroke: var(--border); }
.chart-tooltip {
  position: absolute; pointer-events: none;
  background: var(--ink-900); color: #fff;
  padding: 8px 11px; border-radius: 8px;
  font-size: 11.5px;
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, -120%);
  white-space: nowrap;
  z-index: 5;
}

.legend-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--canvas-2);
  font-size: 11.5px; color: var(--ink-700);
  font-weight: 500;
}
.legend-chip__sw { width: 8px; height: 8px; border-radius: 999px; }

/* ============================================================
   SETTINGS
   ============================================================ */
.set-grid { display: grid; grid-template-columns: 220px 1fr; gap: 32px; }
.set-nav {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: flex-start;
  display: flex; flex-direction: column; gap: 1px;
}
.set-nav__item {
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--ink-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
  text-decoration: none;
}
.set-nav__item:hover { background: var(--canvas-2); color: var(--ink-900); }
.set-nav__item.is-active {
  background: var(--surface);
  color: var(--brand-800);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

.set-section + .set-section { margin-top: 36px; }
.set-section__title {
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
}
.set-section__sub { color: var(--ink-500); font-size: 13.5px; margin: 0 0 18px; max-width: 64ch; }

.sync-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  align-items: center;
}
.sync-card + .sync-card { margin-top: 12px; }
.sync-card__head { display: flex; align-items: center; gap: 10px; }
.sync-card__head .ic { color: var(--ink-500); }
.sync-card__title { font-family: var(--font-display); font-size: 14.5px; font-weight: 700; letter-spacing: -0.005em; }
.sync-card__sub { color: var(--ink-500); font-size: 12px; margin-top: 4px; font-family: var(--font-mono); letter-spacing: -0.01em; }
.sync-card__row { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.badge--success { background: var(--success-50); color: var(--success-700); }
.badge--info { background: var(--accent-50); color: var(--accent-600); }
.badge--idle { background: var(--canvas-2); color: var(--ink-500); }
.badge--warn { background: var(--warning-50); color: var(--warning-700); }
.badge--danger { background: var(--danger-50); color: var(--danger-700); }

/* Form */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--ink-700); letter-spacing: 0.005em; }
.field__hint { font-size: 11.5px; color: var(--ink-400); }
.input {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font: 400 13.5px var(--font-sans);
  color: var(--ink-900);
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}
.input:focus {
  outline: none;
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.14);
}
.input--mono { font-family: var(--font-mono); letter-spacing: -0.01em; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { width: 76px; text-align: center; }
.input-suffix { color: var(--ink-500); font-size: 13px; }

.toggle {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; user-select: none;
}
.toggle input { display: none; }
.toggle__track {
  width: 36px; height: 20px;
  border-radius: 999px;
  background: var(--ink-300);
  position: relative;
  transition: background 160ms ease;
}
.toggle__thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff; border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform 160ms ease;
}
.toggle input:checked + .toggle__track { background: var(--accent-600); }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(16px); }
.toggle__label { font-size: 13px; color: var(--ink-700); font-weight: 500; }

/* ============================================================
   FORECASTER PORTAL
   ============================================================ */
.fp-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.fp-side {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 8px;
  max-height: calc(100vh - 140px);
  overflow: auto;
}
.fp-side__group {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink-400);
  padding: 12px 10px 6px;
}
.fp-side__item {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--ink-700);
  cursor: pointer;
  border: 1px solid transparent;
}
.fp-side__item:hover { background: var(--canvas-2); }
.fp-side__item.is-active {
  background: var(--accent-50);
  color: var(--brand-800);
  font-weight: 600;
  border-color: #d6e4fc;
}
.fp-side__chip {
  font-size: 10px; font-family: var(--font-mono);
  padding: 1px 6px; border-radius: 999px;
  background: var(--canvas-2); color: var(--ink-500);
}
.fp-side__item.is-active .fp-side__chip { background: var(--brand-800); color: #fff; }

.fp-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.fp-table thead th {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-500);
  background: var(--canvas);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.fp-table thead th:first-child { text-align: left; }
.fp-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-3); text-align: right; color: var(--ink-700); }
.fp-table tbody td:first-child { text-align: left; color: var(--ink-900); font-weight: 500; }
.fp-table tbody tr:hover td { background: #fafcff; }
.fp-input {
  width: 100%; padding: 6px 10px;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; text-align: right;
  font: 400 13px var(--font-sans);
  font-variant-numeric: tabular-nums;
  color: var(--ink-900);
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.fp-input:hover { background: #fafcff; border-color: var(--border-2); }
.fp-input:focus { outline: none; background: #fff; border-color: var(--accent-600); box-shadow: 0 0 0 3px rgba(59,130,246,0.14); }
.fp-input.is-edited { background: var(--accent-50); border-color: var(--accent-600); color: var(--accent-600); font-weight: 600; }

.fp-foot {
  position: sticky; bottom: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 10px;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--canvas);
}
.login-aside {
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(59, 130, 246, 0.30) 0%, transparent 60%),
    radial-gradient(80% 60% at 0% 100%, rgba(22, 163, 74, 0.20) 0%, transparent 60%),
    linear-gradient(135deg, var(--brand-950) 0%, var(--brand-700) 100%);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column;
  position: relative;
  overflow: hidden;
}
.login-aside::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  mask: radial-gradient(60% 60% at 50% 50%, black 30%, transparent 80%);
}
.login-aside__brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 14px;
  position: relative;
}
.login-aside__brand .side__logo { width: 30px; height: 30px; font-size: 13px; }
.login-aside__hero {
  margin-top: auto;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.05;
  max-width: 480px;
  position: relative;
}
.login-aside__hero em { color: #93c5fd; font-style: normal; }
.login-aside__sub { margin-top: 20px; color: rgba(255,255,255,0.7); font-size: 14.5px; max-width: 460px; line-height: 1.6; position: relative; }
.login-aside__stats {
  margin-top: 32px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  position: relative;
}
.login-aside__stat {
  border-left: 1px solid rgba(255,255,255,0.14);
  padding-left: 14px;
}
.login-aside__stat strong {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.login-aside__stat span { display: block; color: rgba(255,255,255,0.6); font-size: 12px; margin-top: 2px; }

.login-form-wrap { display: grid; place-items: center; padding: 48px; }
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 36px;
}
.login-card h1 { font-family: var(--font-display); margin: 0 0 4px; font-size: 22px; letter-spacing: -0.02em; font-weight: 700; }
.login-card p.lead { margin: 0 0 24px; color: var(--ink-500); font-size: 13px; }
.login-card .field + .field { margin-top: 14px; }
.login-card .btn--primary { width: 100%; padding: 11px 16px; }
.login-card__foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border-2); font-size: 12px; color: var(--ink-500); display: flex; justify-content: space-between; }

/* ============================================================
   UTIL
   ============================================================ */
.muted { color: var(--ink-500); }
.mono { font-family: var(--font-mono); letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }
.up { color: var(--success-700); }
.down { color: var(--danger-700); }
.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }
.scroll-x { overflow-x: auto; }
.display { font-family: var(--font-display); letter-spacing: -0.015em; }

.ic {
  width: 14px; height: 14px;
  display: inline-block;
  vertical-align: -2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ic--lg { width: 16px; height: 16px; }

/* Density */
body[data-density="compact"] .grid-table tbody td { padding: 7px 14px; }
body[data-density="compact"] .fp-table tbody td { padding: 8px 14px; }
body[data-density="compact"] .kpi { padding: 16px 18px; }
body[data-density="compact"] .kpi__value { font-size: 26px; }
body[data-density="roomy"] .grid-table tbody td { padding: 14px 14px; }
body[data-density="roomy"] .fp-table tbody td { padding: 14px 14px; }
body[data-density="roomy"] .kpi { padding: 26px 28px; }
body[data-density="roomy"] .kpi__value { font-size: 34px; }

/* ============================================================
   HANDSONTABLE OVERRIDES — preserved verbatim
   ============================================================ */
.handsontable { overflow: visible !important; }
.handsontable th { background: #1B2A4A !important; color: #fff !important; font-weight: 600; font-size: 12px; }
.handsontable td { font-size: 12px; }
.header-row td { background: #1B2A4A !important; color: #fff !important; font-weight: 700 !important; }
.calculated-row td { background: #f0f4f8 !important; font-weight: 600 !important; }
.spacer-row td { background: #fff !important; height: 8px !important; }
.actual-cell { background: #e8f5e9 !important; }
.readonly-cell { background: #f5f5f5 !important; color: #666 !important; }
.clickable-label { cursor: pointer !important; color: #1B2A4A !important; text-decoration: underline !important; }
.handsontable td.monthly-override { background-color: #FFF8E1 !important; color: #7B5800 !important; }
.monthly-revert-btn {
  position: absolute; top: 1px; right: 2px;
  background: rgba(123,88,0,0.15); border: none; border-radius: 3px;
  color: #7B5800; font-size: 10px; font-weight: 700; padding: 0 3px;
  cursor: pointer; line-height: 14px; z-index: 1;
}
.monthly-revert-btn:hover { background: rgba(123,88,0,0.3); }
.handsontable td.yearly-cell { background-color: #E3F2FD !important; color: #1565C0 !important; font-weight: 600 !important; }

/* Allow HoT to manage its own overflow within the grid frame */
.grid-frame { overflow: visible; }
.grid-frame .ht_master { border-radius: 0 0 var(--r-lg) var(--r-lg); }
