/* QMAIC dashboard.
   Light palette on :root; only tokens are redefined for dark, so no colour has
   its sole definition inside a media query. */

:root {
  color-scheme: light dark;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --border: #e3e1dd;
  --text: #1c1b19;
  --text-dim: #6b6862;
  --accent: #2b6cb0;

  /* Control limits and specification are deliberately different hues,
     weights and styles. Never unify these. */
  --control: #c53030;      /* voice of the process */
  --spec: #b7791f;         /* voice of the customer */
  --centre: #2f855a;
  --zone: #2b6cb0;

  --ok: #2f855a;
  --warn: #b7791f;
  --bad: #c53030;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a;
    --surface: #1e2024;
    --border: #32353b;
    --text: #e8e6e3;
    --text-dim: #9a978f;
    --accent: #63a4e0;
    --control: #f56565;
    --spec: #ecc94b;
    --centre: #68d391;
    --zone: #63a4e0;
    --ok: #68d391;
    --warn: #ecc94b;
    --bad: #f56565;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a; --surface: #1e2024; --border: #32353b;
  --text: #e8e6e3; --text-dim: #9a978f; --accent: #63a4e0;
  --control: #f56565; --spec: #ecc94b; --centre: #68d391; --zone: #63a4e0;
  --ok: #68d391; --warn: #ecc94b; --bad: #f56565;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 20px 72px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 34px 0 10px; letter-spacing: -0.005em; }
p { margin: 0 0 12px; }
.sub { color: var(--text-dim); margin: 0 0 22px; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.9em; }

nav.top {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}
nav.top a { text-decoration: none; color: var(--text-dim); }
nav.top a:hover, nav.top a[aria-current="page"] { color: var(--accent); }
nav.top .brand { font-weight: 600; color: var(--text); margin-right: 6px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px; margin-bottom: 18px;
}

/* Verdict banner ---------------------------------------------------------- */
.verdict { border-left-width: 4px; border-left-style: solid; }
.verdict-capable      { border-left-color: var(--ok); }
.verdict-marginal     { border-left-color: var(--warn); }
.verdict-not_capable  { border-left-color: var(--bad); }
.verdict h2 { margin-top: 0; }
.verdict .badge { font-weight: 600; }
.verdict-capable .badge     { color: var(--ok); }
.verdict-marginal .badge    { color: var(--warn); }
.verdict-not_capable .badge { color: var(--bad); }

/* Stat tiles -------------------------------------------------------------- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 15px;
}
.tile .label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.tile .value { font-family: var(--mono); font-size: 1.32rem; margin-top: 3px; }
.tile .note { font-size: 0.78rem; color: var(--text-dim); margin-top: 2px; }

/* Tables ------------------------------------------------------------------ */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { text-align: left; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-dim); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
td.num, th.num { text-align: right; font-family: var(--mono); padding-right: 18px; }
tr.highlight td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* Control chart ----------------------------------------------------------- */
.chart-scroll { overflow-x: auto; }
.control-chart { width: 100%; min-width: 560px; height: auto; display: block; }

.cc-axis { stroke: var(--border); stroke-width: 1; }
.cc-tick, .cc-axis-label { fill: var(--text-dim); font-size: 11px; font-family: var(--mono); }
.cc-axis-label { font-family: inherit; font-size: 11.5px; }
.cc-title { fill: var(--text); font-size: 13px; font-weight: 600; }
.cc-annot { fill: var(--text-dim); font-size: 10.5px; font-family: var(--mono); }
.cc-annot-spec { fill: var(--spec); }

.cc-zone1 { fill: var(--zone); opacity: 0.07; }
.cc-zone2 { fill: var(--zone); opacity: 0.04; }

/* Control limits: thin, dashed, red. */
.cc-limit { stroke: var(--control); stroke-width: 1.25; stroke-dasharray: 6 4; }
.cc-centre { stroke: var(--centre); stroke-width: 1.5; }

/* Specification: filled amber band with a solid, thicker edge. Different hue,
   different weight, different style — it must never read as a control limit. */
.cc-spec { fill: var(--spec); opacity: 0.14; }
.cc-spec-line { stroke: var(--spec); stroke-width: 2.5; }

.cc-line { fill: none; stroke: var(--accent); stroke-width: 1.75; }
.cc-point { fill: var(--accent); }
.cc-point-violation { fill: var(--control); }
.cc-violation-ring { fill: none; stroke: var(--control); stroke-width: 2; }
.cc-rule-label { fill: var(--control); font-size: 10px; font-weight: 700; font-family: var(--mono); }

.cc-legend { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 5px;
             font-size: 0.83rem; color: var(--text-dim); }
.cc-legend .key { display: inline-block; width: 22px; height: 0; vertical-align: middle;
                  margin-right: 9px; border-top-width: 2px; border-top-style: solid; }
.key-centre { border-top-color: var(--centre); }
.key-limit { border-top-color: var(--control); border-top-style: dashed; }
.key-zone { border-top: 9px solid color-mix(in srgb, var(--zone) 22%, transparent); }
.key-spec { border-top: 9px solid color-mix(in srgb, var(--spec) 45%, transparent); }
.key-violation { border-top: none; width: 12px; height: 12px; border-radius: 50%;
                 border: 2px solid var(--control); }

.note { font-size: 0.88rem; color: var(--text-dim); }
.empty { color: var(--text-dim); font-style: italic; }
footer { margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--border);
         font-size: 0.8rem; color: var(--text-dim); }

@media (max-width: 480px) {
  .wrap { padding: 18px 14px 56px; }
  h1 { font-size: 1.28rem; }
}
