/* South Oak Forecast & Allocation — light theme, dataviz reference palette */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-300: #6da7ec;
  --seq-400: #3987e5; --seq-500: #256abf; --seq-600: #184f95; --seq-700: #0d366b;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-text: #006300;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--page); color: var(--ink); font-size: 14px; }
h1,h2,h3 { font-weight: 650; margin: 0 0 .4em; }
h1 { font-size: 18px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
a { color: var(--series-1); }
button { font: inherit; cursor: pointer; }

/* layout */
#app { min-height: 100vh; display: flex; flex-direction: column; }
header.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: var(--surface-1); border-bottom: 1px solid var(--grid);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-weight: 700; letter-spacing: .02em; }
.topbar .brand small { display:block; font-weight: 400; color: var(--muted); font-size: 11px; }
nav.tabs { display: flex; gap: 2px; flex-wrap: wrap; align-items: center; }
nav.tabs button {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 6px;
  color: var(--ink-2); font-weight: 500;
}
nav.tabs button:hover { background: #f0efec; }
nav.tabs button.active { background: var(--seq-100); color: var(--seq-600); font-weight: 650; }
.navgroup { position: relative; }
.navgroup .grpbtn .caret { font-size: 10px; color: var(--muted); }
.navgroup .menu {
  display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(11,11,11,.12); padding: 6px; min-width: 200px;
}
.navgroup.open .menu { display: block; }
.navgroup .menu button { display: block; width: 100%; text-align: left; white-space: nowrap; }

/* dashboard hero */
.hero {
  position: relative; border-radius: 10px; overflow: hidden; margin-bottom: 16px;
  background: url('hero.jpg') center 62% / cover no-repeat; min-height: 190px;
  display: flex; align-items: flex-end; border: 1px solid var(--border);
}
.hero .scrim {
  width: 100%; padding: 40px 24px 16px;
  background: linear-gradient(180deg, rgba(11,11,11,0) 0%, rgba(11,11,11,.62) 78%);
  color: #fff;
}
.hero h1 { color: #fff; font-size: 22px; margin: 0; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.hero .sub { color: #e8e7e2; font-size: 12px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* dashboard section cards */
.section-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-bottom: 16px; }
.section-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; }
.section-card:hover { border-color: var(--seq-400); box-shadow: 0 1px 6px rgba(42,120,214,.18); }
.section-card h3 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.section-card h3 .go { color: var(--series-1); font-size: 12px; font-weight: 500; }
.section-card .stat { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.section-card .stat:last-child { border-bottom: 0; }
.section-card .stat .v { font-weight: 650; font-variant-numeric: tabular-nums; }
.topbar .spacer { flex: 1; }
.topbar .asof { color: var(--muted); font-size: 12px; text-align: right; }
main { flex: 1; padding: 20px; max-width: 1500px; width: 100%; margin: 0 auto; }
main.wide { max-width: none; }
.topbar img.logo { height: 40px; width: auto; display: block; }
.login-box img.logo { height: 110px; width: auto; margin: 0 auto 10px; display: block; }

/* cards & tiles */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.tile-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile.click, tr.click { cursor: pointer; }
.tile.click:hover { border-color: var(--seq-400); box-shadow: 0 1px 4px rgba(42,120,214,.18); }

/* collapsible alert groups */
details.alert-group { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 8px; background: var(--surface-1); }
details.alert-group > summary { cursor: pointer; padding: 10px 12px; font-weight: 650; list-style: none; display: flex; align-items: center; gap: 8px; }
details.alert-group > summary::-webkit-details-marker { display: none; }
details.alert-group > summary .caret { margin-left: auto; color: var(--muted); transition: transform .15s; font-weight: 400; }
details.alert-group[open] > summary .caret { transform: rotate(90deg); }
details.alert-group .body { padding: 0 12px 10px; }
.count-badge { display: inline-block; min-width: 22px; text-align: center; padding: 1px 7px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.count-badge.critical { background: #fbe9e9; color: #8f1f1f; }
.count-badge.serious { background: #fceee7; color: #8f3a15; }
.count-badge.warning { background: #fdf3dc; color: #7a5200; }
.count-badge.good { background: #edf7ed; color: var(--good-text); }
.tile .label { color: var(--ink-2); font-size: 12px; margin-bottom: 4px; }
.tile .value { font-size: 24px; font-weight: 650; }
.tile .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* tables — all large tables live inside .scrolltable containers that scroll
   themselves (both axes); headers stick to the container top, not the page */
.scrolltable { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--grid); border-radius: 6px; background: var(--surface-1); }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
table.data th {
  text-align: right; font-size: 11px; color: var(--muted); font-weight: 600;
  padding: 6px 8px; border-bottom: 1px solid var(--baseline);
  background: var(--surface-1); white-space: nowrap; cursor: pointer;
}
.scrolltable table.data th { position: sticky; top: 0; z-index: 10; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th.txt, table.data td.txt { text-align: left; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; background: var(--surface-1); }
table.data tr.brandrow td { background: #f0efec; font-weight: 650; text-align: left; font-size: 12px; letter-spacing: .04em; }
table.data tr:hover td { background: #f6f9fe; }
table.data tr.expand-detail td { background: #fafbfd; white-space: normal; }

/* frozen left columns (Brand / Grp / Model line) for wide tables */
table.data .fz1, table.data .fz2, table.data .fz3 { position: sticky; z-index: 5; }
table.data th.fz1, table.data th.fz2, table.data th.fz3 { z-index: 15; }
table.data .fz1 { left: 0; min-width: 72px; max-width: 72px; overflow: hidden; text-overflow: ellipsis; }
table.data .fzfull { position: sticky; left: 0; z-index: 5; }
.expand-detail .fzwrap, .brandrow .fzwrap { position: sticky; left: 12px; display: inline-block; max-width: min(1200px, calc(100vw - 140px)); text-align: left; }
table.data .fz2 { left: 72px; min-width: 40px; }
table.data .fz3 { left: 128px; min-width: 190px; max-width: 230px; overflow: hidden; text-overflow: ellipsis; box-shadow: 4px 0 6px -4px rgba(11,11,11,.18); }
.num-strong { font-weight: 650; }
.dim { color: var(--muted); }

/* status chips — always icon + label, never color alone */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; border: 1px solid var(--border); }
.chip.good { color: var(--good-text); background: #edf7ed; }
.chip.warning { color: #7a5200; background: #fdf3dc; }
.chip.serious { color: #8f3a15; background: #fceee7; }
.chip.critical { color: #8f1f1f; background: #fbe9e9; }
.chip.neutral { color: var(--ink-2); background: #f0efec; }

/* alerts */
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: 6px; margin-bottom: 8px; border: 1px solid var(--border); align-items: baseline; }
.alert .ico { font-weight: 700; }
.alert.critical { background: #fbe9e9; } .alert.critical .ico { color: var(--critical); }
.alert.serious { background: #fceee7; } .alert.serious .ico { color: var(--serious); }
.alert.warning { background: #fdf3dc; } .alert.warning .ico { color: #7a5200; }
.alert.good { background: #edf7ed; } .alert.good .ico { color: var(--good-text); }

/* forms */
input, select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--baseline);
  border-radius: 6px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--seq-200); border-color: var(--seq-400); }
input.inline-num { width: 64px; padding: 3px 6px; text-align: right; }
.btn {
  background: var(--seq-500); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 16px; font-weight: 600;
}
.btn:hover { background: var(--seq-600); }
.btn.secondary { background: #f0efec; color: var(--ink); border: 1px solid var(--baseline); }
.btn.secondary:hover { background: #e8e7e2; }
.btn.danger { background: var(--critical); }
.btn:disabled { opacity: .5; cursor: default; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--page); }
.login-box { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 32px; width: 340px; text-align: center; }
.login-box input { width: 100%; text-align: center; font-size: 20px; letter-spacing: .3em; margin: 16px 0; }
.login-box .err { color: var(--critical); font-size: 12px; min-height: 16px; }

/* import zone */
.dropzone {
  border: 2px dashed var(--baseline); border-radius: 10px; padding: 32px;
  text-align: center; color: var(--ink-2); background: #fff; transition: border-color .15s;
}
.dropzone.over { border-color: var(--seq-400); background: #f6f9fe; }
.import-log { font-size: 12px; margin-top: 10px; }
.import-log li { margin-bottom: 3px; }

/* sparkline & bars */
.spark { vertical-align: middle; }
.meter { display: inline-block; height: 8px; border-radius: 4px; background: var(--seq-100); position: relative; vertical-align: middle; }
.meter > i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.meter > i.over { background: var(--serious); }

/* aging heat cells */
td.heat0 { background: transparent; }
td.heat1 { background: var(--seq-100); }
td.heat2 { background: var(--seq-200); }
td.heat3 { background: var(--seq-300); color: #fff0; color: var(--ink); }
td.heat4 { background: var(--seq-400); color: #fff; }
td.heat5 { background: var(--seq-600); color: #fff; }

/* fmv cards */
.fmv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
.fmv-card h3 { display: flex; justify-content: space-between; align-items: baseline; }
.fmv-table { width: 100%; font-size: 12px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.fmv-table th { text-align: left; color: var(--muted); font-size: 11px; padding: 3px 6px; border-bottom: 1px solid var(--baseline); }
.fmv-table td { padding: 3px 6px; border-bottom: 1px solid var(--grid); }
.gapbar { display: flex; align-items: center; gap: 6px; }
.gapbar .bar { height: 8px; border-radius: 4px; }

/* misc */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.pill-note { font-size: 12px; color: var(--muted); }
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 8px; z-index: 200; opacity: 0; transition: opacity .2s;
}
.toast.show { opacity: 1; }
details.grp-detail { margin: 4px 0; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.footer-note { color: var(--muted); font-size: 11px; padding: 12px 20px; text-align: center; }
@media (max-width: 800px) {
  main { padding: 10px; }
  table.data { font-size: 12px; }
}
@media print {
  header.topbar, .toolbar, .btn { display: none !important; }
}
