* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--body);
  background: var(--canvas);
  color: var(--fg);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--brand-tint); }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-wide { max-width: var(--maxw-wide); }
main:focus { outline: none; }
main { padding-top: 8px; }
.view { display: none; }
.view.is-active { display: block; }
.load-error { padding: 72px 0; max-width: 520px; }
.load-error h2 { font-size: 18px; margin-bottom: 8px; }
.load-error p { color: var(--fg-muted); margin-bottom: 16px; }

/* accessibility */
.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; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 999; background: var(--brand); color: var(--on-brand); padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600; transition: top 0.2s; }
.skip-link:focus { top: 12px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-xs); }

/* view headers */

/* buttons */
.btn-primary { display: inline-flex; align-items: center; gap: 7px; background: var(--brand); color: var(--on-brand); font-weight: 600; font-size: 13.5px; padding: 9px 15px; border-radius: var(--r-sm); transition: background 0.16s var(--ease), transform 0.1s; }
.btn-primary:hover { background: var(--brand-hi); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.sm, .btn-secondary.sm { padding: 7px 11px; font-size: 12.5px; }
.btn-secondary { display: inline-flex; align-items: center; gap: 7px; background: var(--raised); color: var(--fg); border: 1px solid var(--line-2); font-weight: 600; font-size: 13px; padding: 9px 14px; border-radius: var(--r-sm); transition: border-color 0.16s, background 0.16s; }
.btn-secondary:hover { border-color: var(--brand-deep); color: var(--brand-hi); }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; width: 38px; height: 38px; justify-content: center; border-radius: var(--r-sm); color: var(--fg-muted); border: 1px solid transparent; transition: all 0.16s; }
.icon-btn:hover { color: var(--fg); background: var(--raised); }
.icon-btn.sm { width: 34px; height: 34px; border: 1px solid var(--line-2); background: var(--raised); }
.icon-btn.sm:hover { border-color: var(--brand-deep); color: var(--brand-hi); }
.icon-btn.is-disabled { opacity: 0.4; pointer-events: none; }
.mono { font-family: var(--mono); }

/* card — the one panel surface for Pulse + Complaints */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; padding: var(--pad) var(--pad) 0; }
.card-h h2 { font-family: var(--display); font-size: 16.5px; font-weight: 650; letter-spacing: -0.01em; }
.card-meta { font-size: 12px; color: var(--fg-muted); border: 1px solid var(--line-2); border-radius: var(--r-sm); padding: 3px 9px; }

/* deltas: colour follows meaning (good/bad), not direction */
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--pos); } .delta.bad { color: var(--crit); } .delta.flat { color: var(--fg-faint); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: 10px; }
.seg button, .seg a { padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--fg-muted); transition: background 0.15s, color 0.15s; }
.seg button:hover, .seg a:hover { color: var(--fg); }
.seg button.on, .seg a.on { background: var(--raised); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--fg-muted); border: 1px solid var(--line-2); background: var(--surface); transition: all 0.15s; }
.pill:hover { color: var(--fg); border-color: var(--fg-faint); }
.pill.on { color: var(--brand-hi); border-color: var(--brand-deep); background: var(--brand-tint); }
:root[data-theme='light'] .pill.on { color: var(--brand-deep); }

/* footer */
footer { border-top: 1px solid var(--line); margin-top: 80px; padding: 26px 0 60px; }
footer .foot-lead { color: var(--fg); font-size: 14px; font-weight: 600; margin-bottom: 6px; max-width: 780px; }
footer .disc { color: var(--fg-faint); font-size: 12.5px; max-width: 780px; }
footer .foot-brand { font-family: var(--mono); color: var(--fg-muted); font-size: 11px; font-weight: 600; letter-spacing: 1px; margin-top: 10px; }

.c-crit { color: var(--crit); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; } }
