/* Shared CMM ops-site styles.
   Palette merges the live dashboard tokens with the house print style
   (render_schedule.py): maroon brand #8B2E2E on cream #FAF8F3.

   Dark mode: assets/theme.js stamps data-theme="dark"|"light" on <html>
   before first paint (localStorage override, else prefers-color-scheme).
   Everything below keys off that attribute — no @media query needed here
   since theme.js already resolved the OS preference into the attribute. */
:root {
  color-scheme: light;
  --bg: #faf8f3;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --line: #e7e2d8;
  --card: #ffffff;
  --card-alt: #fcfbf8;
  --brand: #8b2e2e;
  --brand-dark: #6e2222;
  --brand-soft: #f6e3e3;
  --accent: #b8431a;
  --accent-soft: #f6e1d4;
  --good: #2f7d4f;
  --good-soft: #e6f2ea;
  --warn: #b8893b;
  --warn-soft: #fff9db;
  --bad: #b83a26;
  --bad-soft: #fde9e3;
  --shadow: rgba(26,26,26,.08);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17130f;
  --fg: #ece6dc;
  --muted: #a49a8b;
  --line: #3a3128;
  --card: #221c16;
  --card-alt: #2a231c;
  --brand: #c85a58;
  --brand-dark: #9e3f3d;
  --brand-soft: #3a2323;
  --accent: #e08a55;
  --accent-soft: #3a2a1c;
  --good: #5fbf85;
  --good-soft: #1c3427;
  --warn: #d9ab5f;
  --warn-soft: #3a3018;
  --bad: #e2685a;
  --bad-soft: #3a2220;
  --shadow: rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--fg);
  min-height: 100vh;
}

/* ---- shared top nav (nav.js) ---- */
.cmm-nav {
  display: flex; align-items: center; gap: 18px;
  padding: 8px 20px;
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.cmm-nav-brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; letter-spacing: .14em; white-space: nowrap;
}
.cmm-nav-brand img { height: 22px; width: 22px; border-radius: 50%; background: #fff; }
.cmm-nav-loc { color: #e8d3d3; font-weight: 400; letter-spacing: .08em; }
.cmm-nav-links { display: flex; gap: 2px; margin-left: 8px; flex-wrap: wrap; }
.cmm-nav-links a {
  color: #f2e2e2; text-decoration: none; font-size: 13px;
  padding: 5px 10px; border-radius: 6px;
}
.cmm-nav-links a:hover { background: rgba(255,255,255,.12); color: #fff; }
.cmm-nav-links a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.cmm-nav-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.cmm-nav-user { font-size: 12px; color: #e8d3d3; }
.cmm-nav-signout {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  padding: 4px 10px; border-radius: 6px; font: inherit; font-size: 12px; cursor: pointer;
}
.cmm-nav-signout:hover { background: rgba(255,255,255,.12); }
.cmm-nav-signin {
  margin-left: auto; color: #f2e2e2; text-decoration: none; font-size: 12px;
  border: 1px solid rgba(255,255,255,.35); padding: 4px 10px; border-radius: 6px;
}
.cmm-nav-signin:hover { background: rgba(255,255,255,.12); color: #fff; }
.cmm-nav + header.top h1 .sub { display: none; } /* avoid double branding on index */
.cmm-theme-toggle {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  width: 28px; height: 28px; border-radius: 6px; font: inherit; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  line-height: 1; flex: none;
}
.cmm-theme-toggle:hover { background: rgba(255,255,255,.12); }

/* ---- mobile / iOS: brand + account on row 1, page links as a swipe strip ---- */
@media (max-width: 720px) {
  .cmm-nav {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 12px;
  }
  .cmm-nav-brand { font-size: 11px; letter-spacing: .1em; }
  .cmm-nav-loc { display: none; }              /* drop "· TYLER, TX" to save width */
  .cmm-nav-right { margin-left: auto; }        /* toggle + account pinned right on row 1 */
  .cmm-nav-links {
    order: 3;                                   /* push the links onto their own row */
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;                          /* one line, scroll instead of wrap */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    scrollbar-width: none;                      /* hide scrollbar (Firefox) */
  }
  .cmm-nav-links::-webkit-scrollbar { display: none; }   /* hide scrollbar (iOS/WebKit) */
  .cmm-nav-links a {
    flex: none;                                 /* don't shrink; keep tap targets */
    white-space: nowrap;
    padding: 6px 12px;
  }
}

/* ---- shared building blocks for the new pages ---- */
main.page { padding: 16px 20px 60px; max-width: 1400px; margin: 0 auto; }
section.section { margin-bottom: 24px; }
section h2 {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin: 0 0 10px;
}
.grid { display: grid; gap: 12px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.grid.split-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .grid.split-2 { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.card h3 { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.kpi .value { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.kpi .delta { font-size: 12px; margin-top: 4px; color: var(--muted); }
table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th, table.simple td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.simple th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  padding: 6px 12px; font-size: 13px; font-family: inherit; cursor: pointer; border-radius: 6px;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.err {
  padding: 14px; background: var(--bad-soft); border: 1px solid #f0b8a8; border-radius: 8px;
  color: var(--bad); font-size: 13px; white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", monospace;
}
.pill-good { background: var(--good-soft); color: var(--good); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.pill-warn { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.pill-bad  { background: var(--bad-soft);  color: var(--bad);  border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }

/* ---- login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: 0 6px 30px var(--shadow);
}
.login-head {
  background: linear-gradient(90deg, var(--brand), var(--brand-dark));
  color: #fff; padding: 22px 24px;
}
.login-head .brand { font-size: 12px; font-weight: 700; letter-spacing: .14em; }
.login-head h1 { margin: 8px 0 0; font-size: 20px; font-weight: 700; }
.login-body { padding: 22px 24px 26px; }
.login-body label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.login-body input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--bg);
}
.login-body input:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.login-body button { width: 100%; margin-top: 18px; padding: 10px; font-size: 14px; }
.login-err { margin-top: 12px; }
.login-note { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

@media print {
  .cmm-nav, .no-print { display: none !important; }
  body { background: #fff; }
}
