/* PrepTip OKR Dashboard — pantry design system (Geist, stock-neutral palette, borders-over-shadows,
   color-is-earned) with PrepTip orange as the brand accent and green/red status meters (Domo-style).
   Plain CSS, no build. Mobile-first; grids widen at 720px. AA contrast (Lighthouse a11y ≥ 90). */
:root {
  --brand: #e8590c;
  --brand-dk: #c2410c;
  --brand-soft: #fff1e7;

  --white: #ffffff;
  --n50: #fafafa;
  --n100: #f5f5f5;
  --n200: #e5e5e5;
  --n300: #d4d4d4;
  --n500: #737373;
  --n700: #404040;
  --n900: #171717;

  --green-100: #dcfce7; --green-200: #bbf7d0; --green-500: #22c55e; --green-700: #15803d;
  --red-100: #fee2e2;   --red-200: #fecaca;   --red-500: #ef4444;   --red-700: #b91c1c;

  --radius-lg: 14px;
  --radius-md: 10px;
  --sans: "Geist Variable", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono Variable", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--n900);
  background: var(--n50); /* page is the secondary surface; cards are white and pop */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--n900); color: #fff; padding: 10px 14px; border-radius: 0 0 8px 0; z-index: 10;
}
.skip-link:focus { left: 0; }

/* Header */
.top { background: var(--white); border-bottom: 1px solid var(--n200); }
.top-inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; gap: 10px 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.logo { display: inline-flex; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 1.12rem; font-weight: 700; }
.brand-txt small { color: var(--n500); font-size: 0.78rem; }
.top-right { display: flex; align-items: center; gap: 12px; }

.btn {
  font: inherit; font-weight: 500; font-size: 0.9rem;
  color: var(--n900); background: var(--white);
  border: 1px solid var(--n200); border-radius: var(--radius-md);
  padding: 8px 16px; cursor: pointer; transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--n50); border-color: var(--n300); }

.updated { color: var(--n500); font-size: 0.85rem; white-space: nowrap; }
.updated.demo { color: var(--red-700); background: var(--red-100); border: 1px solid var(--red-200);
  padding: 3px 10px; border-radius: 999px; font-weight: 600; }

main.wrap { padding-top: 22px; padding-bottom: 44px; }

/* ---- At-a-glance: hero + KPI strip ---- */
.summary { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 24px; }
@media (min-width: 720px) { .summary { grid-template-columns: 1.25fr 2fr; align-items: stretch; } }

.hero {
  background: var(--white); border: 1px solid var(--n200); border-top: 3px solid var(--brand);
  border-radius: var(--radius-lg); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px;
}
.hero-over { margin: 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--brand-dk); }
.hero-row { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.hero-val { font-size: 3.2rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; color: var(--n900); }
.hero-label { margin: 2px 0 10px; font-size: 0.95rem; color: var(--n700); }
.hero-label .muted { color: var(--n500); }
.hero-note { margin: 8px 0 0; font-size: 0.85rem; color: var(--n500); }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.kpi {
  background: var(--white); border: 1px solid var(--n200); border-left: 3px solid var(--n300);
  border-radius: var(--radius-md); padding: 14px 16px;
}
.kpi.t-ok { border-left-color: var(--green-500); }
.kpi.t-low { border-left-color: var(--red-500); }
.kpi.t-wait { border-left-color: var(--n300); }
.kpi-label { margin: 0; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; color: var(--n500); }
.kpi-val { margin: 6px 0 2px; font-size: 1.9rem; font-weight: 700; line-height: 1; color: var(--n900); }
.kpi-val small { font-size: 0.95rem; font-weight: 600; color: var(--n500); }
.kpi-sub { margin: 0; font-size: 0.8rem; color: var(--n500); }

/* ---- Objective sections ---- */
.objective { margin: 0 0 20px; }
.obj-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 12px; flex-wrap: wrap; }
.obj-h { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.obj-tag {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--brand-dk); background: var(--brand-soft); padding: 3px 9px; border-radius: 999px;
}
.obj-sub { font-size: 0.82rem; color: var(--n500); white-space: nowrap; }

.grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr; } }

.okr {
  background: var(--white); border: 1px solid var(--n200); border-left: 4px solid var(--n300);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.okr[data-status="on-track"] { border-left-color: var(--green-500); }
.okr[data-status="below"], .okr[data-status="error"] { border-left-color: var(--red-500); }
.okr[data-status="insufficient"], .okr[data-status="awaiting"] { border-left-color: var(--n300); }

.kr-h { margin: 0; font-size: 1rem; font-weight: 600; color: var(--n900); }
.kr-sub { margin: 4px 0 14px; color: var(--n500); font-size: 0.85rem; }
.kr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.kr-val { font-size: 2rem; font-weight: 700; letter-spacing: -0.01em; color: var(--n900); }
.kr-val small { font-size: 0.9rem; font-weight: 600; color: var(--n500); margin-left: 3px; }
.kr-cap { margin: 0; color: var(--n500); font-size: 0.85rem; }

/* ---- Badges (3-tier semantic) ---- */
.badge { display: inline-flex; align-items: center; font-size: 0.72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid; }
.badge.ok { background: var(--green-100); color: var(--green-700); border-color: var(--green-200); }
.badge.low { background: var(--red-100); color: var(--red-700); border-color: var(--red-200); }
.badge.wait { background: var(--n100); color: var(--n700); border-color: var(--n200); }

/* ---- Meter: status-toned fill + lighter same-ramp track + target tick ---- */
.bar { position: relative; height: 9px; border-radius: 999px; margin: 12px 0 10px; background: var(--n100); overflow: hidden; }
.bar.lg { height: 12px; margin: 10px 0; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--n300); transition: width 0.45s ease; }
.bar[data-tone="ok"] { background: var(--green-100); }
.bar[data-tone="ok"] i { background: var(--green-500); }
.bar[data-tone="low"] { background: var(--red-100); }
.bar[data-tone="low"] i { background: var(--red-500); }
.bar[data-tone="wait"] { background: var(--n100); }
.bar[data-tone="wait"] i { background: var(--n300); }
.bar .tick { position: absolute; top: -3px; width: 2px; height: 15px; background: var(--n700); opacity: 0.55; overflow: visible; }
.bar.lg .tick { top: -3px; height: 18px; }

.loading { color: var(--n500); font-size: 0.9rem; }
.foot-note { color: var(--n500); font-size: 0.82rem; margin: 6px 0 0; }
.page-foot { display: flex; gap: 8px; align-items: center; margin: 24px 0 8px; padding-top: 16px; border-top: 1px solid var(--n200); color: var(--n500); font-size: 0.8rem; }
.page-foot .dot { color: var(--n300); }
.foot-note code { font-family: var(--mono); color: var(--n700); background: var(--n100); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }

/* ---- Insight panels (tip performance, resource popularity) ---- */
.panel { background: var(--white); border: 1px solid var(--n200); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 16px; }
.panel-h { margin: 0; font-size: 1.05rem; font-weight: 700; }
.panel-sub { margin: 4px 0 14px; color: var(--n500); font-size: 0.85rem; }
.muted-note { margin: 0; color: var(--n500); font-size: 0.9rem; }

.perf-cols { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 640px) { .perf-cols { grid-template-columns: 1fr 1fr; } }
.perf-h { margin: 0 0 8px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--n500); }
.perf-list { list-style: none; margin: 0; padding: 0; }
.perf-list li { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-top: 1px solid var(--n100); }
.perf-list li:first-child { border-top: 0; }
.perf-name { flex: 1; min-width: 0; font-size: 0.9rem; color: var(--n900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perf-val { font-weight: 700; font-size: 0.95rem; }
.perf-val.t-ok { color: var(--green-700); }
.perf-val.t-low { color: var(--red-700); }
.perf-n { font-size: 0.75rem; color: var(--n500); white-space: nowrap; }

.pop-list { list-style: none; margin: 0; padding: 0; }
.pop-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.pop-name { width: 38%; min-width: 110px; font-size: 0.88rem; color: var(--n900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-bar { flex: 1; height: 8px; background: var(--n100); border-radius: 999px; overflow: hidden; }
.pop-bar i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.pop-n { font-size: 0.85rem; font-weight: 600; color: var(--n700); min-width: 22px; text-align: right; }

/* ---- In-page nav (the page is long now) ---- */
html { scroll-behavior: smooth; }
.page-nav { position: sticky; top: 0; z-index: 4; background: var(--white); border-bottom: 1px solid var(--n200); }
.page-nav .wrap { display: flex; gap: 4px; overflow-x: auto; padding-top: 6px; padding-bottom: 6px; scrollbar-width: none; }
.page-nav .wrap::-webkit-scrollbar { display: none; }
.page-nav a { flex: none; font-size: 0.82rem; font-weight: 600; color: var(--n700); text-decoration: none; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.page-nav a:hover { background: var(--n100); color: var(--n900); }
.summary, .objective, .panel { scroll-margin-top: 56px; }
.obj-h, .panel-h { scroll-margin-top: 56px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ---- How each number is measured ---- */
.how > summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; color: var(--n900); }
.how[open] > summary { margin-bottom: 12px; }
.how-list { margin: 0; display: grid; gap: 4px 0; }
.how-list dt { margin-top: 10px; font-size: 0.86rem; font-weight: 700; color: var(--n900); }
.how-list dd { margin: 0; font-size: 0.85rem; color: var(--n500); }
.how-list code { font-family: var(--mono); font-size: 0.85em; color: var(--n700); background: var(--n100); padding: 1px 6px; border-radius: 6px; }

/* ---- Error log ---- */
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 2px; background: var(--n100); border-radius: 999px; gap: 2px; }
.seg-btn { font: inherit; font-size: 0.8rem; font-weight: 600; color: var(--n500); background: none; border: 0; border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.seg-btn.on { background: var(--white); color: var(--n900); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); }

.mini-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
@media (min-width: 720px) { .mini-row { grid-template-columns: repeat(4, 1fr); } }
.mini { background: var(--n50); border: 1px solid var(--n200); border-radius: var(--radius-md); padding: 12px 14px; }
.mini-val { margin: 4px 0 2px; font-size: 1.6rem; font-weight: 700; line-height: 1; color: var(--n900); }

.err-cols { display: grid; grid-template-columns: 1fr; gap: 20px; margin-bottom: 18px; }
@media (min-width: 720px) { .err-cols { grid-template-columns: 3fr 2fr; } }
.trend { display: grid; gap: 2px; align-items: end; height: 84px; border-bottom: 1px solid var(--n200); }
.tcol { display: flex; align-items: flex-end; height: 100%; }
.tcol i { display: block; width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; }
.tcol i.zero { background: var(--n200); border-radius: 0; }
.trend-axis { display: flex; justify-content: space-between; margin-top: 4px; font-size: 0.72rem; color: var(--n500); }

.issues-h { margin-top: 4px; }
.table-wrap { overflow-x: auto; }
.err-table { width: 100%; min-width: 580px; border-collapse: collapse; font-size: 0.86rem; } /* narrower screens scroll the table sideways instead of crushing the Issue column */
.err-table th { text-align: left; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--n500); padding: 6px 10px 6px 0; border-bottom: 1px solid var(--n200); white-space: nowrap; }
.err-table td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--n100); vertical-align: top; color: var(--n900); }
.err-table .num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 14px; }
.err-table .nowrap { white-space: nowrap; color: var(--n500); }
.issue-text { display: block; margin-top: 4px; }
.issue-cat { display: block; margin-top: 2px; font-size: 0.75rem; color: var(--n500); }
.badge.rep { background: var(--brand-soft); color: var(--brand-dk); border-color: #f6c3a5; }
.muted-note.small { font-size: 0.8rem; margin-top: 10px; }
.muted-note code { font-family: var(--mono); font-size: 0.85em; color: var(--n700); background: var(--n100); padding: 1px 6px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

a:focus-visible, button:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .bar i { transition: none; } }

/* ---- Dark mode: deliberate dark steps (follows the OS setting), PrepTip orange kept as accent ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --white: #1a1d23;   /* card surface */
    --n50: #0f1115;     /* page */
    --n100: #262a31; --n200: #2c313a; --n300: #3a414c;
    --n500: #9aa1ad; --n700: #c3c8d0; --n900: #eceef2;
    --brand-dk: #ff9a5a; /* legible on dark for the OBJECTIVE tag + hero overline */
    --brand-soft: #3a2415;
    --green-100: #14321f; --green-200: #1f6b3b; --green-500: #34d27f; --green-700: #86e9b0;
    --red-100: #3a1a1c;   --red-200: #7a2e32;   --red-500: #f87171;   --red-700: #fca5a5;
  }
  .btn:hover { background: #22262e; }
}
