/* Meridian Auto & Energy Group Ltd — demo dashboards
   Tokens per design specification §3. Newsreader / Libre Franklin / Courier Prime only. */

:root {
  --petrol-900: #0C2E2A;
  --petrol-700: #11453E;
  --petrol-100: #DCE8E4;
  --solar-500: #E8A33D;
  --paper: #F4F6F4;
  --surface: #FFFFFF;
  --ink: #182420;
  --ink-soft: #55645E;
  --rule: #D8DEDA;
  --good: #2166C7;
  --bad: #C7531B;
  --chart-grey: #B9C2BD;
  --branch-ikeja: #0072B2;
  --branch-abuja: #009E73;
  --branch-phc: #E69F00;
  --branch-kano: #CC79A7;
  --age-0: #DCE8E4;
  --age-1: #A9C6BC;
  --age-2: #6E9A8C;
  --age-3: #38685A;
  --age-4: #11453E;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Libre Franklin", Helvetica, Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
}
.mono { font-family: "Courier Prime", "Courier New", monospace; }
a { color: var(--petrol-700); }
a:focus-visible, button:focus-visible, select:focus-visible, input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--solar-500);
  outline-offset: 2px;
}
button { font-family: inherit; cursor: pointer; }

/* ---------- Top band ---------- */
.topband {
  background: var(--petrol-900);
  color: #fff;
  padding: 14px 24px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 24px;
}
.topband .wordmark {
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.375rem; font-weight: 600; letter-spacing: 0.01em;
  color: #fff; text-decoration: none;
}
.topband .tagline { color: #BFD3CC; font-size: 0.8125rem; }
.topband .spacer { flex: 1; }
.section-switch { display: flex; gap: 4px; }
.section-switch a {
  color: #DCE8E4; text-decoration: none; font-weight: 600; font-size: 0.875rem;
  padding: 6px 14px; border: 1px solid #3D665E; border-radius: 4px;
}
.section-switch a[aria-current="true"] { background: #fff; color: var(--petrol-900); border-color: #fff; }
.demo-badge {
  background: var(--solar-500); color: var(--petrol-900); font-weight: 700;
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 8px; border-radius: 4px;
}
.asof-stamp { color: #BFD3CC; font-size: 0.75rem; width: 100%; }

/* ---------- Section nav ---------- */
.section-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: 0 24px;
  display: flex; gap: 4px; overflow-x: auto;
}
.section-nav a {
  color: var(--ink-soft); text-decoration: none; font-size: 0.875rem; font-weight: 500;
  padding: 10px 12px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.section-nav a:hover { color: var(--ink); }
.section-nav a[aria-current="page"] { color: var(--petrol-900); font-weight: 700; border-bottom-color: var(--solar-500); }

/* ---------- Layout ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 24px 24px 48px; }
.zone { margin-bottom: 32px; }

/* ---------- Context bar ---------- */
.context-bar {
  display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: 12px 16px; margin-bottom: 16px;
}
.context-bar .field { display: flex; flex-direction: column; gap: 4px; }
.context-bar label { font-size: 0.75rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.context-bar select, .context-bar input[type="date"], .context-bar input[type="search"], .context-bar input[type="text"] {
  font: inherit; font-size: 0.875rem; padding: 7px 10px;
  border: 1px solid var(--rule); border-radius: 4px; background: #fff; color: var(--ink);
  min-height: 38px;
}
.context-bar .reset-btn {
  background: none; border: none; color: var(--petrol-700); font-weight: 600;
  font-size: 0.875rem; padding: 8px 4px; text-decoration: underline;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--petrol-100); color: var(--petrol-900);
  font-size: 0.8125rem; font-weight: 600; padding: 4px 6px 4px 12px; border-radius: 4px;
}
.chip button {
  background: var(--petrol-700); color: #fff; border: none; border-radius: 4px;
  width: 22px; height: 22px; font-size: 0.875rem; line-height: 1;
}
.filters-toggle { display: none; }

/* ---------- Headlines & panels ---------- */
.takeaway {
  font-family: "Newsreader", Georgia, serif;
  font-size: 2.25rem; line-height: 1.25; font-weight: 500; color: var(--petrol-900);
  margin: 8px 0 6px; max-width: 60ch;
}
.basis { color: var(--ink-soft); font-size: 0.875rem; margin: 0 0 4px; }
.panel {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: 20px 24px;
}
.panel h2, .panel-title {
  font-size: 1.125rem; font-weight: 700; color: var(--petrol-900); margin: 0 0 4px;
}
.panel .panel-sub { color: var(--ink-soft); font-size: 0.8125rem; margin: 0 0 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.attention { border-left: 4px solid var(--solar-500); }
.attention ul { margin: 8px 0 0; padding-left: 20px; }
.attention li { margin-bottom: 8px; }
.disclaimer { color: var(--ink-soft); font-size: 0.8125rem; font-style: italic; margin-top: 12px; }
.scope-caption {
  background: var(--petrol-100); border-radius: 4px; padding: 12px 16px;
  font-weight: 600; color: var(--petrol-900); margin-bottom: 24px;
}
.red-flag { border-left: 4px solid var(--bad); }
.red-flag h2 { color: var(--bad); }

/* ---------- KPI strip ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.kpi-strip.six { grid-template-columns: repeat(3, 1fr); }
.kpi {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: 16px 18px; text-align: left; width: 100%;
}
button.kpi, a.kpi { text-decoration: none; color: inherit; display: block; }
button.kpi:hover, a.kpi:hover { border-color: var(--petrol-700); }
.kpi .kpi-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 6px; }
.kpi .kpi-value { font-family: "Newsreader", Georgia, serif; font-size: 2rem; line-height: 1.15; font-weight: 500; color: var(--petrol-900); margin: 0; }
.kpi .kpi-sub { font-size: 0.8125rem; color: var(--ink-soft); margin: 6px 0 0; }
.kpi .kpi-sub .sub-value { font-family: "Newsreader", Georgia, serif; font-size: 1.125rem; color: var(--petrol-900); }
.delta-up { color: var(--good); font-weight: 700; }
.delta-down { color: var(--bad); font-weight: 700; }

/* ---------- Charts ---------- */
.chart-title {
  font-family: "Newsreader", Georgia, serif; font-size: 1.625rem; font-weight: 500;
  color: var(--petrol-900); margin: 0 0 2px; line-height: 1.3;
}
.chart-sub { color: var(--ink-soft); font-size: 0.8125rem; margin: 0 0 16px; }
.chart-wrap { width: 100%; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-actions { margin: 12px 0 0; }
svg text { font-family: "Libre Franklin", Helvetica, Arial, sans-serif; }
svg .axis-label { fill: var(--ink-soft); font-size: 12px; }
svg .value-label { fill: var(--ink); font-size: 12.5px; font-weight: 600; }
svg .series-label { font-size: 13px; font-weight: 700; }
.backing-link { font-size: 0.8125rem; font-weight: 600; }

/* ---------- Tables ---------- */
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 10px; flex-wrap: wrap; }
.table-tools .count-note { color: var(--ink-soft); font-size: 0.8125rem; }
.csv-btn {
  background: var(--petrol-700); color: #fff; border: none; border-radius: 4px;
  font-size: 0.8125rem; font-weight: 600; padding: 8px 14px; min-height: 36px;
}
.csv-btn:hover { background: var(--petrol-900); }
.table-scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 4px; background: var(--surface); }
table.data { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
table.data th {
  font-weight: 600; text-align: left; padding: 10px 12px; color: var(--petrol-900);
  border-bottom: 2px solid var(--rule); background: #fff; white-space: nowrap;
}
table.data th.sortable { cursor: pointer; }
table.data th.sortable:hover { background: var(--petrol-100); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--petrol-100); }
table.data tfoot td { font-weight: 700; border-top: 2px solid var(--rule); border-bottom: none; }
table.data td:first-child, table.data th:first-child { position: sticky; left: 0; background: inherit; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 10px; font-size: 0.875rem; }
.pager button {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: 7px 14px; font-weight: 600; min-height: 36px;
}
.pager button:disabled { opacity: 0.45; cursor: default; }
.status-chip {
  display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 2px 8px;
  border-radius: 4px; background: var(--petrol-100); color: var(--petrol-900); white-space: nowrap;
}
.status-chip.sea { background: var(--petrol-700); color: #fff; }
.status-chip.port { background: var(--solar-500); color: var(--petrol-900); }
.status-chip.grey { background: #E4E8E5; color: var(--ink-soft); }
.status-chip.overdue { background: var(--bad); color: #fff; }
.status-chip.withheld { background: #fff; border: 1.5px dashed var(--petrol-700); color: var(--petrol-700); }
.branch-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.incell-bar { position: relative; }
.incell-bar .bar-bg { position: absolute; inset: 0 auto 0 0; background: var(--petrol-100); z-index: 0; }
.incell-bar .bar-val { position: relative; z-index: 1; }
.cover-low { background: #FBEED3; }
.cover-cell { font-weight: 700; }

/* Heatmap */
table.heatmap td.cell { text-align: center; font-weight: 700; color: var(--ink); cursor: pointer; }
table.heatmap td.cell:hover { outline: 2px solid var(--solar-500); outline-offset: -2px; }
table.heatmap td.cell.light { color: #fff; }
table.heatmap td.total, table.heatmap th.total { font-weight: 700; background: #EDF1EE; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--rule); margin-bottom: 16px; }
.tabs button {
  background: none; border: none; font-size: 0.9375rem; font-weight: 600; color: var(--ink-soft);
  padding: 10px 16px; border-bottom: 3px solid transparent; margin-bottom: -2px; min-height: 44px;
}
.tabs button[aria-selected="true"] { color: var(--petrol-900); border-bottom-color: var(--solar-500); }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(12, 46, 42, 0.45); z-index: 40;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 100vw;
  background: var(--surface); z-index: 41; overflow-y: auto; padding: 24px;
  box-shadow: -8px 0 24px rgba(12, 46, 42, 0.25);
}
.drawer h2 { font-family: "Newsreader", Georgia, serif; font-size: 1.625rem; font-weight: 500; color: var(--petrol-900); margin: 0 40px 4px 0; }
.drawer .drawer-sub { color: var(--ink-soft); font-size: 0.875rem; margin: 0 0 16px; }
.drawer-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
  border: 1px solid var(--rule); border-radius: 4px; background: #fff; font-size: 1.125rem;
}
.fact-list { margin: 0 0 16px; }
.fact-list div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--rule); }
.fact-list dt { color: var(--ink-soft); font-size: 0.875rem; }
.fact-list dd { margin: 0; font-weight: 600; text-align: right; }
details.tech { border: 1px solid var(--rule); border-radius: 4px; padding: 10px 14px; margin-top: 16px; }
details.tech summary { font-weight: 600; font-size: 0.875rem; cursor: pointer; }
details.tech p { font-size: 0.8125rem; color: var(--ink-soft); }
[hidden] { display: none !important; }

/* ---------- Landing ---------- */
.landing-hero { padding: 48px 0 8px; }
.landing-hero h1 {
  font-family: "Newsreader", Georgia, serif; font-size: 2.25rem; font-weight: 500;
  color: var(--petrol-900); line-height: 1.25; margin: 0 0 12px; max-width: 26ch;
}
.landing-hero p { font-size: 1.0625rem; color: var(--ink-soft); max-width: 62ch; margin: 0 0 24px; }
.enter-btn {
  display: inline-block; background: var(--petrol-900); color: #fff; text-decoration: none;
  font-weight: 700; padding: 12px 22px; border-radius: 4px; min-height: 48px;
}
.section-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin: 32px 0; }
.section-cards .panel h2 { font-family: "Newsreader", Georgia, serif; font-size: 1.625rem; font-weight: 500; }
.section-cards ul { margin: 8px 0 16px; padding-left: 20px; color: var(--ink-soft); }
.section-cards .live-state { font-size: 0.8125rem; color: var(--ink-soft); border-top: 1px solid var(--rule); padding-top: 10px; }

/* ---------- Footer / tab bar ---------- */
.site-footer {
  border-top: 1px solid var(--rule); padding: 20px 24px 32px; color: var(--ink-soft);
  font-size: 0.8125rem; max-width: 1440px; margin: 0 auto;
}
.bottom-tabs { display: none; }
.bottom-tabs button.tab-more {
  flex: 1; background: none; border: none; color: #DCE8E4; font: inherit;
  font-size: 0.6875rem; font-weight: 600; padding: 8px 2px; min-height: 44px;
  display: flex; align-items: center; justify-content: center; border-radius: 4px;
}
.bottom-tabs button.tab-more.current { background: #fff; color: var(--petrol-900); }
/* "More" sheet — the bottom tab bar holds four pages; every other page lives here (§10.6). */
.more-sheet {
  position: fixed; inset: 0; z-index: 60; background: rgba(12, 46, 42, 0.45);
  display: flex; align-items: flex-end;
}
.more-sheet[hidden] { display: none; }
.more-panel {
  background: var(--surface); width: 100%; max-height: 80vh; overflow-y: auto;
  padding: 20px; border-radius: 8px 8px 0 0;
}
.more-panel .more-title { font-weight: 700; color: var(--petrol-900); margin: 0 0 8px; }
.more-panel a {
  display: block; padding: 13px 8px; min-height: 48px; font-weight: 600;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule);
}
.more-panel a[aria-current="page"] { background: var(--petrol-100); color: var(--petrol-900); }
.more-close {
  margin-top: 12px; width: 100%; min-height: 48px; background: var(--petrol-700);
  color: #fff; border: none; border-radius: 4px; font-weight: 700; font-size: 0.9375rem;
}
.loading { padding: 64px 24px; text-align: center; color: var(--ink-soft); font-size: 1rem; }
.error-box { background: #FDF0E8; border: 1px solid var(--bad); border-radius: 4px; padding: 16px 20px; margin: 24px; }

/* ---------- Mobile (390px design) ---------- */
@media (max-width: 900px) {
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .section-cards { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 16px 14px 96px; }
  .topband { padding: 12px 14px; }
  .section-nav { display: none; }
  .takeaway { font-size: 1.75rem; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .kpi-strip .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi .kpi-value { font-size: 1.625rem; }
  .panel { padding: 16px; }
  .filters-toggle {
    display: block; width: 100%; background: var(--petrol-700); color: #fff; border: none;
    border-radius: 4px; font-weight: 700; padding: 12px; min-height: 48px; margin-bottom: 12px;
  }
  .context-bar { display: none; }
  .context-bar.open {
    display: flex; position: fixed; inset: 0; z-index: 50; overflow-y: auto;
    flex-direction: column; align-items: stretch; border-radius: 0; margin: 0; padding: 20px;
  }
  .context-bar.open .field { width: 100%; }
  .drawer { width: 100vw; }
  table.data { font-size: 0.8125rem; }
  /* Touch targets ≥ 44px on mobile (§10.6, review S4) */
  .csv-btn, .pager button { min-height: 44px; }
  .chip { padding: 2px 2px 2px 12px; }
  .chip button { width: 44px; height: 44px; }
  .section-switch a { padding: 11px 14px; }
  .drawer-close { width: 44px; height: 44px; }
  .context-bar select, .context-bar input[type="date"], .context-bar input[type="search"], .context-bar input[type="text"] { min-height: 44px; }
  .context-bar .reset-btn { min-height: 44px; }
  table.data th { padding-top: 12px; padding-bottom: 12px; }
  table.data td { padding-top: 12px; padding-bottom: 12px; }
  .bottom-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--petrol-900); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-tabs a {
    flex: 1; color: #DCE8E4; text-decoration: none; text-align: center;
    font-size: 0.6875rem; font-weight: 600; padding: 8px 2px; min-height: 44px;
    display: flex; align-items: center; justify-content: center; border-radius: 4px;
  }
  .bottom-tabs a[aria-current="page"] { background: #fff; color: var(--petrol-900); }
  .landing-hero { padding-top: 24px; }
  .landing-hero h1 { font-size: 1.875rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
