/* PMI Midwest Ops Hub. One stylesheet, tokens on :root, dark mode selected
   (not auto-inverted).

   BRAND (from the logo SVGs and Mark's email signature, Oct 2026):
     orange #FF6D00 · black #000 · white · typeface Poppins.
   Orange is a fill colour, not a text colour on white: black-on-orange is 7.4:1,
   white-on-orange only 2.8:1. So primary buttons are orange with BLACK text,
   and orange text on light surfaces uses the darker --brand-ink (4.9:1).
   Charts: single-series magnitude in brand orange; status colours stay reserved
   for state and always come with a dot + label. */

:root {
  color-scheme: light;
  --brand: #ff6d00;
  --brand-ink: #b84f00;          /* orange text on light surfaces (AA) */
  --on-brand: #0b0b0b;           /* text on orange fills */
  --brand-soft: #fff1e6;

  --bg: #f5f4f1;
  --surface-1: #ffffff;
  --surface-2: #ffffff;
  --border: #e4e2dd;
  --border-strong: #cfccc5;
  --text-primary: #0b0b0b;
  --text-secondary: #4f4d49;
  --text-muted: #75726b;

  /* sidebar is black in both modes, like the logo's dark lockup */
  --side-bg: #0b0b0b;
  --side-text: #e8e6e1;
  --side-muted: #8f8c84;
  --side-hover: #1d1c1a;
  --side-active: #2b1a0c;
  --side-border: #232220;

  --accent: var(--brand);
  --bar: var(--brand);
  --bar-track: #f0eeea;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;
  --critical-ink: #a32424;
  --warning-ink: #7a5200;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 1px rgba(0,0,0,.03);
  --radius: 10px;
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand-ink: #ff8a33;
    --brand-soft: #2b1a0c;
    --bg: #111110;
    --surface-1: #1a1a19;
    --surface-2: #20201f;
    --border: #2e2d2b;
    --border-strong: #42413e;
    --text-primary: #ffffff;
    --text-secondary: #c9c6bd;
    --text-muted: #9a978e;
    --side-bg: #070707;
    --side-border: #1c1b1a;
    --bar-track: #2a2927;
    --good-ink: #5fd35f;
    --critical-ink: #f08a8a;
    --warning-ink: #fab219;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-ink: #ff8a33;
  --brand-soft: #2b1a0c;
  --bg: #111110;
  --surface-1: #1a1a19;
  --surface-2: #20201f;
  --border: #2e2d2b;
  --border-strong: #42413e;
  --text-primary: #ffffff;
  --text-secondary: #c9c6bd;
  --text-muted: #9a978e;
  --side-bg: #070707;
  --side-border: #1c1b1a;
  --bar-track: #2a2927;
  --good-ink: #5fd35f;
  --critical-ink: #f08a8a;
  --warning-ink: #fab219;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text-primary);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  background: var(--side-bg);
  color: var(--side-text);
  border-right: 1px solid var(--side-border);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px 18px; }
.brand .logo { width: 132px; height: auto; display: block; margin-left: -6px; }
.brand .brand-sub {
  font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--side-muted); padding-left: 2px;
}
.nav-section { font-size: 10.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 14px 10px 5px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px;
  color: var(--side-text); text-decoration: none; border-left: 3px solid transparent;
}
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a[aria-current="page"] {
  background: var(--side-active); color: #fff; font-weight: 600; border-left-color: var(--brand);
}
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav a[aria-current="page"] .ico { color: var(--brand); opacity: 1; }
.nav .badge { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--brand); color: var(--on-brand); border-radius: 999px; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--side-border); font-size: 13px; }
.side-foot .who { font-weight: 600; color: #fff; }
.side-foot .muted { color: var(--side-muted); }
.side .linkish { color: var(--brand); }
.linkish { background: none; border: 0; padding: 0; color: var(--brand-ink); cursor: pointer; }

.main { min-width: 0; padding: 26px 30px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 23px; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--text-muted); margin-top: 2px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.topbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; transform: translateX(-100%); transition: transform .18s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
  .topbar {
    display: flex; align-items: center; gap: 12px; padding: 10px 16px;
    background: var(--side-bg); color: var(--side-text); border-bottom: 1px solid var(--side-border);
    position: sticky; top: 0; z-index: 20;
  }
  .topbar .logo { height: 30px; width: auto; display: block; }
  .topbar .brand-sub { font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); }
  .topbar .btn { background: transparent; color: var(--side-text); border-color: var(--side-border); }
  .main { padding: 16px 16px 40px; }
}

/* ------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; padding: 7px 13px;
  border: 1px solid var(--border-strong); background: var(--surface-2); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: var(--text-muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--critical-ink); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.input, select.input, textarea.input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2);
}
.input:focus, .btn:focus-visible, .nav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
textarea.input { min-height: 80px; resize: vertical; }
label.field { display: grid; gap: 4px; font-size: 13px; color: var(--text-secondary); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface-2); padding: 6px 13px; cursor: pointer; border-right: 1px solid var(--border); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--brand-soft); color: var(--text-primary); font-weight: 600; box-shadow: inset 0 -2px 0 var(--brand); }

/* ------------------------------------------------------------ cards + KPI */
.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px;
}
.card h2 { font-size: 14.5px; margin: 0 0 12px; font-weight: 600; }
.card h2 .muted { font-weight: 400; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); margin-top: 14px; }

.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; border-top: 3px solid transparent;
}
a.kpi:hover { border-color: var(--border-strong); border-top-color: var(--brand); }
.kpi .k-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.kpi .k-value { font-size: 28px; font-weight: 600; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-foot { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi.hero { border-top-color: var(--brand); }
.kpi.hero .k-value { font-size: 46px; line-height: 1.05; }

/* ------------------------------------------------------------ bar list
   Single-series horizontal bars: one hue (magnitude), value labeled in text
   ink next to each bar, 4px rounded data end, 2px gap between rows. The
   `title` on each row is the hover tooltip; the row text is the table view. */
.bars { display: grid; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(120px, 38%) 1fr auto; gap: 10px; align-items: center;
  padding: 5px 4px; border-radius: 6px;
}
.bar-row:hover { background: var(--bar-track); }
.bar-row .b-label { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .b-track { height: 10px; position: relative; }
.bar-row .b-fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-row .b-val { font-variant-numeric: tabular-nums; min-width: 3ch; text-align: right; font-weight: 500; }

/* ------------------------------------------------------------ status + badges */
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.good { color: var(--good-ink); }
.status.good::before { background: var(--good); }
.status.warn { color: var(--warning-ink); }
.status.warn::before { background: var(--warning); }
.status.bad { color: var(--critical-ink); }
.status.bad::before { background: var(--critical); }

.pill { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text-secondary); white-space: nowrap; }
.pill.p-urgent { border-color: var(--critical); color: var(--critical-ink); font-weight: 600; }
.pill.p-high { border-color: var(--serious); color: var(--text-primary); }
.pill.s-done { color: var(--good-ink); border-color: var(--good); }
.pill.s-blocked { color: var(--critical-ink); border-color: var(--critical); }
.pill.s-in_progress { color: var(--brand-ink); border-color: var(--brand); }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.t td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover { background: var(--bar-track); }
.overdue { color: var(--critical-ink); font-weight: 600; }

/* ------------------------------------------------------------ launcher */
.apps { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.app {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius);
  background: var(--surface-1); border: 1px solid var(--border); text-decoration: none; color: inherit; box-shadow: var(--shadow);
  position: relative;
}
.app:hover { border-color: var(--brand); }
.app .a-ico {
  flex: none; width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center;
  background: #0b0b0b; color: var(--brand); font-weight: 700; font-size: 15px;
}
.app .a-name { font-weight: 600; }
.app .a-desc { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.app .a-edit { position: absolute; top: 8px; right: 8px; }
.app.inactive { opacity: .5; }

/* ------------------------------------------------------------ drawer + dialog */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 41; overflow-y: auto;
  background: var(--surface-1); border-left: 3px solid var(--brand); padding: 20px; display: grid; gap: 14px; align-content: start;
}
.drawer-head { display: flex; gap: 10px; align-items: flex-start; }
.drawer-head .input { font-size: 17px; font-weight: 600; }
.history { display: grid; gap: 10px; }
.h-item { border-left: 2px solid var(--border-strong); padding: 2px 0 2px 10px; }
.h-item.handoff { border-left-color: var(--brand); }
.h-item.system { color: var(--text-muted); font-size: 13px; }
.h-meta { font-size: 12px; color: var(--text-muted); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #0b0b0b; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; max-width: calc(100vw - 32px);
  border-left: 3px solid var(--brand);
}
.empty { padding: 28px; text-align: center; color: var(--text-muted); }
.banner { border: 1px solid var(--border); border-left: 3px solid var(--warning); background: var(--surface-1); padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.banner.bad { border-left-color: var(--critical); }

/* ------------------------------------------------------------ sign in */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.signin .card { width: min(400px, 100%); padding: 30px; display: grid; gap: 16px; border-top: 4px solid var(--brand); }
.signin .logo { width: 170px; height: auto; display: block; margin: 0 auto 2px; }
.signin .brand-sub { text-align: center; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--text-muted); margin-top: -6px; }
.signin h1 { margin: 0; font-size: 20px; }

/* logo swaps: the black lockup on light surfaces, the white one on dark */
.logo-on-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block !important; }
}
:root[data-theme="dark"] .logo-on-light { display: none !important; }
:root[data-theme="dark"] .logo-on-dark { display: block !important; }
