/* Operations Hub dashboard. Mobile-first: the base rules are the phone layout, wider screens add to them. */
:root {
  --bg: #f4f6f9; --card: #ffffff; --ink: #121820; --muted: #566171; --line: #e1e5eb; --brand: #1d5fa3; --brand-ink: #ffffff; --soft: #eaf1f9;
  --good: #1f7a4d; --good-bg: #e2f3ea; --warn: #8a5d00; --warn-bg: #fdf1d0; --bad: #b3261e; --bad-bg: #fbe4e2; --info: #2a5f8f; --info-bg: #e3eef8;
  --series1: #1d5fa3; --series2: #8a94a3; --series3: #d9822b; --series4: #2a9d8f;
  --radius: 14px; --shadow: 0 1px 2px rgba(18, 24, 32, .06), 0 2px 8px rgba(18, 24, 32, .04);
  --nav-h: 62px; --head-h: 54px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1319; --card: #171d26; --ink: #e8edf3; --muted: #9aa6b5; --line: #29323f; --brand: #5aa0e6; --brand-ink: #0b1118; --soft: #1b2634;
    --good: #5fd39a; --good-bg: #14301f; --warn: #f0c35a; --warn-bg: #33290f; --bad: #ff8b82; --bad-bg: #3a1b19; --info: #7db6ee; --info-bg: #17283a;
    --series1: #5aa0e6; --series2: #8d98a8; --series3: #f0a050; --series4: #54c4b5; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1319; --card: #171d26; --ink: #e8edf3; --muted: #9aa6b5; --line: #29323f; --brand: #5aa0e6; --brand-ink: #0b1118; --soft: #1b2634;
  --good: #5fd39a; --good-bg: #14301f; --warn: #f0c35a; --warn-bg: #33290f; --bad: #ff8b82; --bad-bg: #3a1b19; --info: #7db6ee; --info-bg: #17283a;
  --series1: #5aa0e6; --series2: #8d98a8; --series3: #f0a050; --series4: #54c4b5; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; margin-bottom: 10px; } h3 { font-size: 1rem; }
a { color: var(--brand); }
button { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* header */
.head { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); height: var(--head-h); display: flex; align-items: center; gap: 10px; padding: 0 16px; padding-top: env(safe-area-inset-top); }
.brand { font-weight: 700; letter-spacing: -.01em; white-space: nowrap; font-size: .95rem; }
.brand small { display: block; font-weight: 500; font-size: .68rem; color: var(--muted); letter-spacing: 0; margin-top: -2px; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 9px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill.synthetic { background: var(--warn-bg); color: var(--warn); }
.pill.live { background: var(--good-bg); color: var(--good); }
.pill.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.spacer { flex: 1; }
.asof { font-size: .75rem; color: var(--muted); text-align: right; line-height: 1.2; white-space: nowrap; }
.theme { border: 1px solid var(--line); background: transparent; border-radius: 10px; min-width: 40px; min-height: 40px; cursor: pointer; }

/* navigation: bottom bar on phones */
.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--line); height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; }
.nav a, .nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: .7rem; font-weight: 600; background: none; border: 0; min-height: 48px; cursor: pointer; position: relative; }
.nav svg { width: 22px; height: 22px; }
.nav a[aria-current="page"], .nav button[aria-expanded="true"] { color: var(--brand); }
.nav .dot { position: absolute; top: 7px; right: calc(50% - 20px); width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid var(--card); }
.more { position: fixed; z-index: 29; left: 8px; right: 8px; bottom: calc(var(--nav-h) + 8px + env(safe-area-inset-bottom)); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0, 0, 0, .25); padding: 6px; display: none; }
.more.open { display: block; }
.more a { display: flex; align-items: center; gap: 12px; padding: 14px 12px; text-decoration: none; color: var(--ink); border-radius: 10px; min-height: 48px; font-weight: 600; }
.more a:active, .more a[aria-current="page"] { background: var(--soft); }

main { padding: 16px; max-width: 1120px; margin: 0 auto; }
.view-title { margin-bottom: 4px; }
.lede { color: var(--muted); margin: 4px 0 16px; font-size: .95rem; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 12px; }
.card.pad0 { padding: 0; overflow: hidden; }
.card h2 + .sub { margin-top: -6px; }
.sub { color: var(--muted); font-size: .85rem; margin: 0 0 10px; }
.sec { margin-top: 22px; }
.sec > h2 { margin-bottom: 6px; }

/* question cards on the overview */
.q { display: block; text-decoration: none; color: inherit; }
.q .qn { font-size: .72rem; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.q .big { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; margin: 4px 0 2px; }
.q .ask { font-weight: 650; }
.q .why { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.q:active { background: var(--soft); }
.tag-modeled { background: var(--info-bg); color: var(--info); }

.chip { display: inline-block; border-radius: 8px; padding: 2px 8px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); } .chip.warn { background: var(--warn-bg); color: var(--warn); } .chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); } .chip.mute { background: var(--soft); color: var(--muted); }

.banner { border-radius: var(--radius); padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); background: var(--card); }
.banner.bad { background: var(--bad-bg); border-color: transparent; } .banner.good { background: var(--good-bg); border-color: transparent; } .banner.warn { background: var(--warn-bg); border-color: transparent; }
.banner h3 { margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 10px; }
.kv .k { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kv .v { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; }

/* tables turn into stacked rows on phones */
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; } .tbl .nowrap { white-space: nowrap; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.row > :last-child { flex-shrink: 0; text-align: right; }
.row .t { font-weight: 650; min-width: 0; }
.banner .row { flex-wrap: wrap; align-items: center; }
.asof-line { font-size: .78rem; color: var(--muted); margin: 0 0 8px; } .row .m { color: var(--muted); font-size: .85rem; }
.li-btn { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 12px 14px; cursor: pointer; min-height: 48px; border-bottom: 1px solid var(--line); }
.li-btn:active { background: var(--soft); }
.li-btn:last-child { border-bottom: 0; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
select, input[type="search"], input[type="text"] { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; max-width: 100%; }
input[type="search"] { flex: 1 1 200px; }
input[type="range"] { width: 100%; min-height: 36px; accent-color: var(--brand); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.seg button { background: none; border: 0; padding: 10px 14px; min-height: 44px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; font-weight: 650; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.more-btn { margin: 10px auto 0; display: block; }

/* charts */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: inherit; }
.chart .axis { stroke: var(--line); stroke-width: 1; } .chart .grid-l { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.strip { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 2px; }
.strip i { display: block; width: 100%; aspect-ratio: 1; border-radius: 2px; background: var(--good); opacity: .85; min-width: 4px; }
.strip i.a { background: #e0a800; opacity: 1; } .strip i.r { background: var(--bad); opacity: 1; }

/* overlay sheet (SKU detail) */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .45); display: none; }
.sheet-bg.open { display: block; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; top: 24px; background: var(--bg); border-radius: 18px 18px 0 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet-head { position: sticky; top: 0; background: var(--bg); padding: 14px 0 10px; display: flex; gap: 10px; align-items: flex-start; z-index: 2; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.sheet-head .x { margin-left: auto; min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 1.2rem; }

.note { font-size: .82rem; color: var(--muted); }
.foot { margin: 28px 0 8px; font-size: .8rem; color: var(--muted); text-align: center; }
.empty { padding: 20px; text-align: center; color: var(--muted); }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px; z-index: 99; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

/* wider screens */
@media (min-width: 700px) {
  main { padding: 24px; }
  .grid.c2 { grid-template-columns: repeat(2, 1fr); } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); }
  .kv { grid-template-columns: repeat(4, 1fr); }
  .sheet { left: auto; width: min(680px, 100%); top: 0; border-radius: 0; box-shadow: -8px 0 30px rgba(0, 0, 0, .25); }
}
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .head { padding: 0 24px; }
  .nav { position: sticky; top: var(--head-h); bottom: auto; height: 48px; padding: 0 24px; gap: 4px; justify-content: flex-start; border-top: 0; border-bottom: 1px solid var(--line); overflow-x: auto; z-index: 19; }
  .nav a { flex: 0 0 auto; flex-direction: row; gap: 8px; padding: 0 14px; font-size: .88rem; border-radius: 10px; min-height: 40px; }
  .nav a[aria-current="page"] { background: var(--soft); }
  .nav .more-toggle { display: none; }
  .nav .dot { top: 8px; right: 6px; }
  .more { display: none !important; }
  .grid.c3d { grid-template-columns: repeat(3, 1fr); } .grid.c4d { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) { .only-mobile { display: none !important; } }
@media (max-width: 899px) { .only-desktop { display: none !important; } }
@media (prefers-reduced-motion: no-preference) { .card, .chip { transition: background .15s; } }

[hidden] { display: none !important; }
