/* ============================================================
   FGVTSSB Dashboard – Stylesheet
   ============================================================ */

/* FGV Transport look (shared with fgvquiz.gotogether.my): warm paper, ink
   text, FGV red / orange / maroon, Fraunces titles + Instrument Sans text.
   Every status colour below passes WCAG AA (4.5:1) on its card background in
   both themes - check contrast before changing any of them. */
@font-face { font-family: "Fraunces"; src: url(/static/fonts/fraunces-600.ttf) format("truetype"); font-weight: 600 800; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(/static/fonts/instrument-sans-400.ttf) format("truetype"); font-weight: 400 500; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url(/static/fonts/instrument-sans-600.ttf) format("truetype"); font-weight: 600 800; font-display: swap; }

:root, [data-theme="light"] {
  --bg:         #f8f5ee;      /* Paper */
  --bg-card:    #ffffff;
  --bg-card2:   #fbf8f2;
  --bg-muted:   #f3eee3;      /* Parchment */
  --border:     #e6dfd0;
  --border-strong: #d6cdba;
  --text:       #1c2422;      /* Ink */
  --text-muted: #5b5f59;
  --accent:     #c8202a;      /* FGV red (text-safe) */
  --accent2:    #b4540a;      /* FGV orange (text-safe) */
  --accent-rgb: 200, 32, 42;
  --brand-red:  #d7262d;      /* Decorative only - not for small text */
  --brand-orange: #f7941e;
  --maroon:     #40131b;
  --gold:       #e9b44c;
  --green:      #24734a;
  --red:        #c8202a;
  --yellow:     #8a5a00;      /* Amber text */
  --blue:       #1f4e79;
  --nav-bg:     #fbf8f2;
  --font:       "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --accent-dark: #f3eee3;
  --table-header-bg: #f5f0e6;
  --table-stripe-bg: #fbf8f2;
  --table-hover-bg: #f3eee3;
  --shadow:     0 1px 2px rgb(28 36 34 / .05), 0 0 0 1px rgb(28 36 34 / .03);
  --shadow-2:   0 4px 12px -2px rgb(28 36 34 / .10);
  --tint-red:   rgba(200, 32, 42, .08);
  --tint-amber: rgba(180, 84, 10, .09);
  --tint-green: rgba(36, 115, 74, .09);
  --radius:     12px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:         #14100e;      /* Night road */
  --bg-card:    #1d1816;
  --bg-card2:   #241e1b;
  --bg-muted:   #2a2320;
  --border:     #3a302b;
  --border-strong: #4b3f39;
  --text:       #f3eee3;
  --text-muted: #b5ab9e;
  --accent:     #f0636b;
  --accent2:    #f7a54a;
  --accent-rgb: 240, 99, 107;
  --green:      #6fcf97;
  --red:        #ff8a8a;
  --yellow:     #f2c14e;
  --blue:       #7fb2e5;
  --nav-bg:     #1a1412;
  --accent-dark: #241e1b;
  --table-header-bg: #221c19;
  --table-stripe-bg: #211b18;
  --table-hover-bg: #2a2320;
  --shadow:     0 1px 2px rgb(0 0 0 / .3);
  --shadow-2:   0 4px 14px -2px rgb(0 0 0 / .45);
  --tint-red:   rgba(255, 138, 138, .10);
  --tint-amber: rgba(242, 193, 78, .10);
  --tint-green: rgba(111, 207, 151, .10);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: calc(var(--topbar-h, 64px) + 12px); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* Numbers line up in columns everywhere */
table, .kpi-card, .kpi-actual-value, .kpi-value, .num { font-variant-numeric: tabular-nums; }
h1, h2, .page-title, .display-title { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; }

/* ---- GLOBAL TABLE OVERRIDES ---- */
.table {
  --bs-table-bg: var(--bg-card);
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: var(--table-stripe-bg);
  --bs-table-hover-bg: var(--table-hover-bg);
  --bs-table-active-bg: var(--table-stripe-bg);
  --bs-table-active-color: var(--text);
  color: var(--text);
  background: var(--bg-card);
}
.table > thead { background: var(--table-header-bg); }
.table > thead > tr > th { color: var(--text); background: var(--table-header-bg); }
.table > tbody > tr > td { color: var(--text); }
.table > tbody > tr.table-active > td { color: var(--text); background: var(--table-stripe-bg); }
.table .text-end { color: var(--text); }
.table .fw-bold { color: var(--text); }

/* Bootstrap warning table row - ensure text visibility */
.table > tbody > tr.table-warning > td {
  background: rgba(255, 193, 7, 0.15) !important;
  color: var(--text) !important;
}
[data-theme="light"] .table > tbody > tr.table-warning > td {
  background: rgba(255, 193, 7, 0.25) !important;
}

/* Text muted - ensure proper contrast */
.text-muted { color: var(--text-muted) !important; }
.small.text-muted, small.text-muted { color: var(--text-muted) !important; }

.period-badge {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding: 3px 8px;
  border-radius: 4px;
}

.lang-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
}
.lang-btn:hover { border-color: var(--accent); color: var(--text); }
.lang-btn .lang-en, .lang-btn .lang-my { transition: color .2s; }
.lang-btn .lang-en.active, .lang-btn .lang-my.active { color: #F47920; }
.lang-btn .divider { color: var(--border); margin: 0 3px; }

/* ---- KPI CARDS ---- */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  height: 100%;
  position: relative;
  overflow: hidden;
  transition: border-color .2s;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 12px 12px 0 0;
}
.kpi-card:hover { border-color: var(--accent); }

.kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.kpi-main-row {
  display: flex;
  gap: 20px;
  margin-bottom: 6px;
}
.kpi-sub-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 2px;
  white-space: nowrap;
}
.kpi-actual-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  line-height: 1.1;
}
.kpi-actual-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.kpi-sub-row {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.kpi-margin {
  font-weight: 600;
  color: var(--text);
  margin-left: 4px;
}
.kpi-var {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}
.kpi-var.positive { color: var(--green); }
.kpi-var.negative { color: var(--red); }
.kpi-var.neutral  { color: var(--text-muted); }

/* ---- YTD PERFORMANCE SCORECARD ---- */
.ytd-perf-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.ytd-perf-header {
  background: var(--maroon);
  border-bottom: 3px solid var(--brand-orange);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  padding: 10px 16px;
  letter-spacing: 0.4px;
}
.ytd-perf-table {
  font-size: 13px;
  margin-bottom: 0;
  color: var(--text);
  background: var(--bg-card);
}
.ytd-perf-table thead th {
  background: var(--table-header-bg);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 14px;
  white-space: nowrap;
}
.ytd-perf-table tbody td {
  border-color: var(--border);
  padding: 8px 14px;
  vertical-align: middle;
  color: var(--text);
  background: var(--bg-card);
}
.ytd-perf-table tbody tr:last-child td { border-bottom: none; }
.ytd-row-label {
  font-weight: 700;
  font-size: 12px;
  background: var(--table-stripe-bg);
  border-radius: 4px;
  white-space: nowrap;
  min-width: 120px;
}
.ytd-var-pos { color: var(--green); font-weight: 700; }
.ytd-var-neg { color: var(--red);   font-weight: 700; }
.ytd-var-nil { color: var(--text-muted); }
.ytd-ccp-header td {
  background: var(--bg-muted);
  padding-top: 10px;
  padding-bottom: 4px;
  border-top: 2px solid var(--border);
}
.ytd-ccp-sub td {
  font-size: 11px;
  padding-top: 2px;
  padding-bottom: 2px;
}
.ytd-ccp-sub .ytd-row-label {
  font-weight: 500;
  font-size: 11px;
}

/* ---- DASHBOARD CARDS ---- */
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.dash-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
}
.dash-card-header i { color: var(--accent); }
.subtitle-badge {
  font-size: 11px;
  color: var(--text);
  font-weight: 400;
  opacity: 0.8;
}

/* ---- CHART CONTAINERS ---- */
.chart-container {
  padding: 16px;
  height: 300px;
  position: relative;
}

/* ---- P&L TABLE ---- */
.dash-table {
  font-size: 12.5px;
  margin: 0;
  color: var(--text);
  background: var(--bg-card);
}
.dash-table thead th {
  background: var(--table-header-bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  border-color: var(--border);
  padding: 10px 12px;
  white-space: nowrap;
}
.dash-table tbody tr {
  border-color: var(--border);
  transition: background .15s;
  background: var(--bg-card);
}
.dash-table tbody tr:hover { background: var(--table-hover-bg); }
.dash-table td {
  padding: 8px 12px;
  border-color: var(--border);
  vertical-align: middle;
  color: var(--text);
}
.dash-table .row-section { background: var(--table-stripe-bg); font-weight: 600; }
.dash-table .row-total {
  background: var(--table-stripe-bg);
  font-weight: 700;
}
.dash-table .row-margin {
  background: var(--table-header-bg);
  font-style: italic;
  color: var(--text-muted);
}
.dash-table .row-subtotal { font-weight: 600; }
.dash-table .text-positive { color: var(--green) !important; font-weight: 600; }
.dash-table .text-negative { color: var(--red) !important; font-weight: 600; }
.dash-table .text-na { color: var(--text-muted); font-style: italic; }

/* ---- EMPTY STATE ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 64px;
  color: var(--text-muted);
}
.empty-state > i {
  font-size: 48px;
  color: var(--border);
  margin-bottom: 16px;
}
.empty-state h4 { color: var(--text); margin-bottom: 8px; font-size: 18px; }

/* Guide layout */
.guide-container { width: 100%; max-width: 920px; text-align: center; }
.guide-subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  text-align: left;
  margin-bottom: 20px;
}
@media (max-width: 640px) { .guide-grid { grid-template-columns: 1fr; } }
.guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.guide-section-header {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--accent-dark) 0%, rgba(var(--accent-rgb), 0.15) 100%);
  border-color: rgba(var(--accent-rgb), 0.4);
}
.guide-section-header .guide-section-title {
  font-size: 14px;
  margin-bottom: 6px;
}
.guide-section-header p {
  font-size: 13px;
  color: var(--text);
}
.guide-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 7px;
}
.guide-section p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.65;
}
.guide-section strong { color: var(--text); font-weight: 600; }
.guide-drill-badge {
  display: inline-block;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
  line-height: 16px;
}
.guide-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---- LOADING ---- */
.loading-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  font-size: 15px;
  color: var(--text);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- TABLE RESPONSIVE ---- */
/* No max-height: it used to clip the last rows of tables silently. Pages that
   need a scrolling table set their own height on that table's wrapper. */

/* ---- SEGMENT / COST CHART CONTAINER ---- */
.chart-container-seg {
  padding: 16px;
  height: 320px;
  position: relative;
}

/* ---- PIE CHART CONTAINER ---- */
.chart-container-pie {
  padding: 12px;
  height: 260px;
  position: relative;
}

/* BU disclaimer note */
.bu-note {
  font-size: 10px;
  color: var(--yellow);
  opacity: 0.8;
  font-weight: 400;
}

/* ---- TREND FILTER BAR ---- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  padding: 4px 2px;
}
.filter-group {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.year-pill, .period-pill {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.year-pill:hover, .period-pill:hover { border-color: var(--accent); color: var(--text); }
.year-pill.active, .period-pill.active {
  background: rgba(var(--accent-rgb), .2);
  border-color: var(--accent);
  color: var(--accent);
}
/* Global version of the Forecast/DO Summary month-pill look (previously only
   defined scoped to #forecastContent/#doSummaryContent) so any page's month
   selector - including self-contained pages like Truck P&L/Depot P&L - can
   use the exact same class and match their format. */
.filter-pill {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}
.filter-pill:hover { background: var(--bg-card); border-color: var(--accent); color: var(--text); }
.filter-pill.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.combined-pill {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.combined-pill:hover { border-color: var(--accent); color: var(--text); }
.combined-pill.active {
  background: rgba(var(--accent-rgb), .2);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- DRILL-DOWN ---- */
.dash-table tbody tr.drill-row { cursor: pointer; }
.dash-table tbody tr.drill-row:hover { background: rgba(var(--accent-rgb), .08) !important; }
.drill-indicator { font-size: 9px; color: var(--text-muted); margin-right: 4px; opacity:.6; }
.dash-table tbody tr.drill-row:hover .drill-indicator { color: var(--accent); opacity: 1; }

.drill-modal-content { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }
.drill-modal-header  { background: var(--bg-card2); border-bottom: 1px solid var(--border); padding: 12px 16px; display:flex; align-items:center; gap:8px; }
.drill-modal-body    { background: var(--bg-card); padding: 20px; }

.drill-breadcrumb { font-size: 13px; }
.drill-breadcrumb .breadcrumb-item.active { color: var(--text); }
.drill-breadcrumb .breadcrumb-item+.breadcrumb-item::before { color: var(--text-muted); }
.drill-bc-link { color: var(--accent); cursor: pointer; }
.drill-bc-link:hover { text-decoration: underline; }

.drill-back-btn { background: var(--bg-card2); border: 1px solid var(--border); color: var(--text-muted); font-size:12px; padding:4px 10px; border-radius:5px; white-space:nowrap; }
.drill-back-btn:hover { border-color: var(--accent); color: var(--text); }

.drill-contrib { color: var(--yellow); font-weight: 600; }
.drill-table { background: var(--bg-card); color: var(--text); }
.drill-table thead th { background: var(--table-header-bg); color: var(--text); }
.drill-table tbody td { color: var(--text); }
.drill-table tbody tr:hover { background: var(--table-hover-bg); }

/* ---- ALERTS ---- */
.alerts-list { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  border-left: 3px solid;
}
.alert-item.alert-danger  { background: rgba(239,68,68,.08);  border-color: var(--red);    }
.alert-item.alert-warning { background: rgba(245,158,11,.08); border-color: var(--yellow); }
.alert-icon { font-size: 14px; margin-top: 1px; flex-shrink: 0; }
.alert-item.alert-danger  .alert-icon { color: var(--red);    }
.alert-item.alert-warning .alert-icon { color: var(--yellow); }
.alert-title  { font-weight: 600; color: var(--text); line-height: 1.3; }
.alert-detail { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.alert-ok     { padding: 16px 12px; color: var(--green); font-size: 13px; font-weight: 600; }

/* ---- CLICKABLE ALERTS ---- */
.drill-alert { cursor: pointer; transition: background .15s; }
.alert-item.alert-danger.drill-alert:hover  { background: rgba(239,68,68,.16)  !important; }
.alert-item.alert-warning.drill-alert:hover { background: rgba(245,158,11,.16) !important; }

/* ---- BU CARDS ---- */
.bu-card {
  border: 1px solid var(--border);
  border-top: 3px solid var(--bu-accent, var(--accent));
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s;
  background: var(--bg-card2);
}
.bu-card:hover {
  box-shadow: 0 0 0 2px var(--bu-accent, var(--accent));
  border-color: var(--bu-accent, var(--accent));
}
.bu-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
}
.bu-card-name {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--text);
}
.bu-card-drill {
  font-size: 9px;
  color: var(--text-muted);
  opacity: .6;
  transition: opacity .2s, color .2s;
}
.bu-card:hover .bu-card-drill {
  color: var(--bu-accent, var(--accent));
  opacity: 1;
}
.bu-card-table {
  width: 100%;
  font-size: 0.78rem;
  border-collapse: collapse;
  background: var(--bg-card);
}
.bu-card-table th,
.bu-card-table td {
  padding: 3px 8px;
  white-space: nowrap;
  border: none;
  color: var(--text);
}
.bu-card-table thead th {
  color: var(--text);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  background: var(--table-header-bg);
}
.bu-card-table tbody tr:hover { background: var(--bu-hover, var(--table-hover-bg)); }
.bu-card-table .margin-row td {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.73rem;
  padding-top: 1px;
  padding-bottom: 1px;
}

/* ---- CUSTOM SCROLLBAR ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-card2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; border: 2px solid var(--bg-card2); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
::-webkit-scrollbar-corner { background: var(--bg-card2); }


/* ---- MAIN TABS ---- */
.main-tabs {
  margin-bottom: 1rem;
}
.main-tabs .nav-pills {
  gap: 0.5rem;
}
.main-tabs .nav-link {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}
.main-tabs .nav-link:hover {
  background: var(--bg-card2);
  color: var(--text);
}
.main-tabs .nav-link.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---- FORECAST CONTENT ---- */
#forecastContent .filter-bar {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}
#forecastContent .filter-pill {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
#forecastContent .filter-pill:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--text);
}
#forecastContent .filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#forecastContent .section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
#forecastContent .section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}
#forecastContent .section-title i {
  color: var(--accent);
}
#forecastContent .subtitle-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card2);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── DO Summary Content ───────────────────────────────────────── */
#doSummaryContent .filter-bar {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border);
}
#doSummaryContent .filter-pill {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s;
}
#doSummaryContent .filter-pill:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--text);
}
#doSummaryContent .filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
#doSummaryContent .section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
#doSummaryContent .section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}
#doSummaryContent .section-title i {
  color: var(--accent);
}
#doSummaryContent .subtitle-badge {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card2);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ── Intro Scene ────────────────────────────────────────────── */
.intro-scene {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px);
  background: var(--bg);
}

.intro-nav {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.intro-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.5rem 2.5rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text);
}

.intro-nav-btn:hover:not(.disabled) {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.2);
}

.intro-nav-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.intro-nav-btn i {
  font-size: 2rem;
  color: var(--accent);
}

.intro-nav-btn span {
  font-size: 1rem;
  font-weight: 600;
}

.intro-content {
  flex: 1;
  padding: 2rem;
  display: flex;
  justify-content: center;
}

.intro-content .guide-container {
  max-width: 900px;
}



/* ============================================================
   SHELL (topbar, brand band, sidebar) – FGV look shared with fgvquiz
   ============================================================ */
:root { --stripe-h: 8px; --bar-h: 58px; --topbar-h: calc(var(--stripe-h) + var(--bar-h)); --sidebar-w: 248px; }
body { padding-top: var(--topbar-h); }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 2000; background: var(--bg-card); color: var(--text); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 12px; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }

.brand-stripe { position: fixed; top: 0; left: 0; right: 0; height: var(--stripe-h); background: var(--maroon); z-index: 1041; }
.brand-stripe::after { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 2px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 22px, transparent 22px 40px); }

.topbar { position: fixed; top: var(--stripe-h); left: 0; right: 0; height: var(--bar-h); padding: 0; z-index: 1040;
  background: var(--nav-bg) !important; border-bottom: 1px solid var(--border); flex-wrap: nowrap; }
.topbar-inner { display: flex; align-items: center; gap: 8px; width: 100%; height: 100%; padding: 0 14px 0 12px; min-width: 0; }
.topbar-spacer { flex: 1; min-width: 4px; }
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.navbar-brand, #nav-title { font: 600 16px var(--font); color: var(--text) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
/* FGV's hanging logo tab, as on fgvholdings.com / fgvquiz */
.logo-tab { align-self: flex-start; background: #fff; padding: 6px 12px 16px; margin: 0 6px 0 2px; box-shadow: var(--shadow-2);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 80%); display: flex; position: relative; z-index: 2; }
.logo-tab img { height: 34px; width: 34px; border-radius: 50%; }

#sidebarToggle, .icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text);
  min-width: 36px; height: 36px; border-radius: 10px; display: inline-flex; padding: 0 9px;
  align-items: center; justify-content: center; flex: none; cursor: pointer; font-size: 16px;
}
#sidebarToggle { font-size: 20px; }
#sidebarToggle:hover, .icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn kbd, .sb-foot kbd { font: 600 10.5px var(--font); background: var(--bg-muted); color: var(--text-muted); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.user-btn { border: 1px solid var(--border); color: var(--text); border-radius: 10px; height: 36px; display: inline-flex; align-items: center; background: transparent; }
.user-btn:hover, .user-btn.show { border-color: var(--accent); color: var(--accent); background: transparent; }
.lang-btn { height: 36px; border-radius: 10px; background: transparent; }
.lang-btn .lang-en.active, .lang-btn .lang-my.active { color: var(--accent); }
.dropdown-menu { background: var(--bg-card); border-color: var(--border); box-shadow: var(--shadow-2); border-radius: 12px; }
.dropdown-item { color: var(--text); font-size: 13.5px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--bg-muted); color: var(--text); }

#sidebarBackdrop { position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(20,16,14,.45); z-index: 1025; display: none; }
#sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--sidebar-w); background: var(--bg-card);
  border-right: 1px solid var(--border); overflow-y: auto; z-index: 1030; padding: 18px 10px 14px;
  transform: translateX(-100%); transition: transform .18s ease; display: flex; flex-direction: column; }
body.sidebar-open #sidebar { transform: translateX(0); }
#mainArea { transition: margin-left .18s ease; outline: none; min-height: calc(100vh - var(--topbar-h)); }
body.sidebar-open #mainArea { margin-left: var(--sidebar-w); }
.sb-group { padding: 12px 0 2px; }
.sb-group-title { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--accent);
  padding: 0 12px 6px; }
.sb-link { display: flex; align-items: center; gap: 11px; padding: 8px 12px; margin: 1px 0; border-radius: 10px;
  color: var(--text); text-decoration: none; font-size: 13.5px; font-weight: 500; position: relative; }
.sb-link:hover { background: var(--bg-muted); color: var(--text); }
.sb-link.active { background: rgba(var(--accent-rgb), .09); color: var(--accent); font-weight: 600; }
.sb-link.active::before { content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 4px; border-radius: 0 4px 4px 0; background: var(--accent); }
.sb-link i { width: 18px; text-align: center; flex: none; font-size: 15px; }
.sb-top { margin-bottom: 4px; }
.sb-foot { margin-top: auto; padding: 14px 12px 0; font-size: 11.5px; color: var(--text-muted); }
@media (max-width: 991.98px) {
  body.sidebar-open #mainArea { margin-left: 0; }
  body.sidebar-open #sidebarBackdrop { display: block; }
  #sidebar { box-shadow: var(--shadow-2); }
}
@media (max-width: 767.98px) {
  :root { --bar-h: 54px; }
  .topbar-inner { padding: 0 8px; gap: 6px; }
  .topbar-actions { display: none; }          /* admin sync buttons are desktop-only */
  .topbar-title .period-badge { display: none; }
  .logo-tab { padding: 5px 9px 14px; margin: 0; }
  .logo-tab img { height: 28px; width: 28px; }
  .navbar-brand, #nav-title { font-size: 14px; }
  .freshness-slot .fb-label { display: none; }
}

/* ---- Freshness badge ("Data as of …") ---- */
.freshness-slot { position: relative; display: flex; align-items: center; min-width: 0; }
.freshness-badge { display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--font); white-space: nowrap;
  color: var(--green); background: var(--tint-green); border: 1px solid transparent; border-radius: 20px; padding: 4px 10px; cursor: pointer; }
.freshness-badge.stale { color: var(--yellow); background: var(--tint-amber); }
.freshness-badge:hover { border-color: currentColor; }
.freshness-pop { position: absolute; top: calc(100% + 8px); left: 0; z-index: 1050; min-width: 280px; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-2); padding: 10px 12px; }
.fp-title { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.fp-row { display: flex; justify-content: space-between; gap: 16px; font-size: 12.5px; padding: 4px 0; border-top: 1px solid var(--border); }
.fp-row:first-of-type { border-top: 0; }
.fp-row .fp-date { font-weight: 600; color: var(--green); white-space: nowrap; }
.fp-row.stale .fp-date { color: var(--yellow); }

/* ---- Toasts + error banners (replace alert()) ---- */
.toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.fgv-toast { display: flex; align-items: flex-start; gap: 10px; background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-left: 4px solid var(--green); border-radius: 12px; box-shadow: var(--shadow-2); padding: 11px 12px; font-size: 13.5px;
  animation: toastIn .2s ease; transition: opacity .3s, transform .3s; white-space: pre-line; }
.fgv-toast > i { font-size: 16px; color: var(--green); margin-top: 1px; }
.fgv-toast-error { border-left-color: var(--red); } .fgv-toast-error > i { color: var(--red); }
.fgv-toast-warning { border-left-color: var(--yellow); } .fgv-toast-warning > i { color: var(--yellow); }
.fgv-toast-info { border-left-color: var(--blue); } .fgv-toast-info > i { color: var(--blue); }
.fgv-toast-msg { flex: 1; }
.fgv-toast-x { background: none; border: 0; color: var(--text-muted); padding: 0 2px; min-width: 24px; min-height: 24px; }
.fgv-toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fgv-error-banner { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin: 0 0 14px; border-radius: 12px;
  background: var(--tint-red); border: 1px solid rgba(var(--accent-rgb), .35); color: var(--text); }
.fgv-error-banner > i { color: var(--red); font-size: 18px; }
.fgv-error-detail { color: var(--text-muted); }
/* Uses Bootstrap's button variables so .btn:hover can't blank it out */
.btn-fgv { --bs-btn-bg: var(--accent); --bs-btn-color: #fff; --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: #a91a23; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #a91a23;
  --bs-btn-active-bg: #a91a23; --bs-btn-active-color: #fff; border-radius: 10px; font-weight: 600; }
[data-theme="dark"] .btn-fgv { --bs-btn-color: #14100e; --bs-btn-hover-color: #14100e; --bs-btn-active-color: #14100e;
  --bs-btn-hover-bg: #ff7c83; --bs-btn-hover-border-color: #ff7c83; --bs-btn-active-bg: #ff7c83; }

/* ---- Ctrl+K page finder ---- */
.cmdk { position: fixed; inset: 0; background: rgba(20,16,14,.45); z-index: 3000; display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
.cmdk[hidden] { display: none; }
.cmdk-box { width: min(560px, calc(100vw - 32px)); background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-2); overflow: hidden; }
.cmdk-in { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.cmdk-in input { flex: 1; border: 0; outline: none; background: transparent; color: var(--text); font: 16px var(--font); }
.cmdk-in kbd { font: 600 11px var(--font); background: var(--bg-muted); color: var(--text-muted); border-radius: 5px; padding: 2px 6px; }
.cmdk-list { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.cmdk-list li { display: flex; justify-content: space-between; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.cmdk-list li[aria-selected="true"] { background: rgba(var(--accent-rgb), .09); color: var(--accent); }
.cmdk-g { color: var(--text-muted); font-size: 12px; }
.cmdk-empty { color: var(--text-muted); }

/* ---- Loading ---- */
.loading-overlay { background: rgba(248,245,238,.72); backdrop-filter: blur(2px); }
[data-theme="dark"] .loading-overlay { background: rgba(20,16,14,.72); }
.loading-card { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-2); padding: 18px 26px; font-weight: 600; color: var(--text); }
.loading-truck { height: 46px; width: auto; animation: truckIdle 1.2s ease-in-out infinite; }
@keyframes truckIdle { 0%, 100% { transform: translateX(-6px); } 50% { transform: translateX(6px) translateY(-1px); } }
@media (prefers-reduced-motion: reduce) { .loading-truck, .fgv-toast { animation: none !important; } * { transition: none !important; } }

/* ============================================================
   SHARED PAGE COMPONENTS (used by _components.html macros and
   the report pages that used to copy-paste their own panel CSS)
   ============================================================ */
.page-wrap { padding: 22px 26px 40px; max-width: 1680px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 18px; margin-bottom: 16px; }
.page-head h1, .page-title { font-size: 28px; line-height: 1.15; margin: 0; color: var(--text); }
.page-eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.page-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; max-width: 880px; }
.dash-card, .kpi-card, .ytd-perf-card, .section-card, .guide-section { box-shadow: var(--shadow); }
.kpi-card::before { background: linear-gradient(90deg, var(--brand-red), var(--brand-orange)); }
.dash-card-header { background: transparent; font-size: 14px; }
.dash-card-header i { color: var(--accent2); }
details.about-data { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 0; margin: 0 0 16px; }
details.about-data > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 13px; color: var(--text-muted); list-style: none; display: flex; align-items: center; gap: 8px; }
details.about-data > summary::-webkit-details-marker { display: none; }
details.about-data > summary::before { content: '\F431'; font-family: bootstrap-icons; color: var(--accent2); }
details.about-data[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
details.about-data > .about-body { padding: 12px 16px; font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.partial-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--yellow);
  background: var(--tint-amber); border-radius: 20px; padding: 3px 10px; }
.alerts-more { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 12.5px; padding: 6px 12px 10px; text-align: left; }
.alerts-more:hover { text-decoration: underline; }

/* Bootstrap form controls follow the theme */
.form-control, .form-select { background-color: var(--bg-card); border-color: var(--border-strong); color: var(--text); border-radius: 10px; }
.form-control:focus, .form-select:focus { background-color: var(--bg-card); color: var(--text); border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(247,148,30,.2); }
.form-control::placeholder { color: var(--text-muted); opacity: .8; }
.modal-content { background: var(--bg-card); color: var(--text); border-color: var(--border); border-radius: 16px; }
.modal-header, .modal-footer { border-color: var(--border); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.card { background: var(--bg-card); border-color: var(--border); color: var(--text); border-radius: var(--radius); }
.card-header { background: var(--bg-card2); border-color: var(--border); color: var(--text); }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #a91a23; --bs-btn-hover-border-color: #a91a23; --bs-btn-active-bg: #a91a23; }
[data-theme="dark"] .btn-primary { --bs-btn-color: #14100e; --bs-btn-hover-color: #14100e; --bs-btn-hover-bg: #ff7c83; --bs-btn-hover-border-color: #ff7c83; }
.btn-outline-secondary { --bs-btn-color: var(--text); --bs-btn-border-color: var(--border-strong); --bs-btn-hover-bg: var(--bg-muted); --bs-btn-hover-color: var(--text); --bs-btn-hover-border-color: var(--accent); }
.text-success { color: var(--green) !important; } .text-danger { color: var(--red) !important; } .text-warning { color: var(--yellow) !important; }

/* ---- Tables: sticky header, frozen first column, scroll cue ---- */
.table-responsive { position: relative; }
.dash-table thead th, .table-sticky thead th { position: sticky; top: 0; z-index: 2; }
@media (max-width: 767.98px) {
  .page-wrap { padding: 14px 12px 32px; }
  .page-head h1, .page-title { font-size: 22px; }
  .table-responsive, .table-scroll { -webkit-overflow-scrolling: touch;
    background: linear-gradient(to right, var(--bg-card) 30%, transparent) left / 24px 100% no-repeat local,
                linear-gradient(to left, var(--bg-card) 30%, transparent) right / 24px 100% no-repeat local,
                radial-gradient(farthest-side at 0 50%, rgba(0,0,0,.18), transparent) left / 10px 100% no-repeat scroll,
                radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.18), transparent) right / 10px 100% no-repeat scroll; }
  .dash-table td:first-child, .dash-table th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-card); }
  .dash-table thead th:first-child { z-index: 3; background: var(--table-header-bg); }
  .col-low { display: none !important; }
  .chart-container, .chart-container-seg { height: 240px; padding: 8px; }
}

/* ---- Print / PDF ---- */
@media print {
  .brand-stripe, .topbar, #sidebar, #sidebarBackdrop, .toast-host, .cmdk, .loading-overlay, .skip-link,
  .filter-bar, .topbar-actions, .no-print, button { display: none !important; }
  body { padding-top: 0; background: #fff; color: #000; font-size: 11px; }
  body.sidebar-open #mainArea, #mainArea { margin-left: 0 !important; }
  .dash-card, .kpi-card, .panel { break-inside: avoid; box-shadow: none !important; border-color: #ccc !important; }
  .table-responsive { max-height: none !important; overflow: visible !important; }
  a[href]::after { content: none; }
}

/* ---- P&L "what changed" summary ---- */
.pnl-narrative { display: flex; gap: 12px; align-items: flex-start; background: var(--bg-card); border: 1px solid var(--border);
  border-left: 4px solid var(--brand-orange); border-radius: var(--radius); padding: 12px 16px; font-size: 14px; line-height: 1.6; box-shadow: var(--shadow); }
.pnl-narrative > i { color: var(--accent2); font-size: 18px; margin-top: 2px; }
.pnl-narrative .narr-note { display: block; font-size: 11.5px; color: var(--text-muted); }
.sb-badge { margin-left: auto; font-size: 11px; font-weight: 700; min-width: 22px; text-align: center; border-radius: 20px; padding: 1px 7px;
  background: var(--tint-amber); color: var(--yellow); }
.sb-badge.crit { background: var(--accent); color: #fff; }
[data-theme="dark"] .sb-badge.crit { color: #14100e; }
/* numbers never wrap mid-value */
.dash-table td.text-end, .dash-table th.text-end, .table td.text-end { white-space: nowrap; }
.csv-btn { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; background: transparent; border: 1px solid var(--border);
  color: var(--text-muted); border-radius: 8px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; min-height: 26px; }
.csv-btn:hover { color: var(--accent); border-color: var(--accent); }
.dash-card-header .csv-btn ~ .csv-btn { display: none; }
#pnlTable td:first-child { white-space: nowrap; }
