:root {
  color-scheme: light;
  --bg: #fbfaff; --surface: #fff; --surface-soft: #f1f5f9; --border: #d9dde5;
  --text: #111827; --text-muted: #475569; --primary: #5538f2; --primary-strong: #432cc7;
  --primary-soft: #ebe7ff; --danger: #b91c1c; --ok: #166534; --warn: #805800;
  --shadow: 0 6px 20px rgb(15 23 42 / 4%);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e14; --surface: #121826; --surface-soft: #1b2335; --border: #2c3851;
  --text: #e8ecf1; --text-muted: #a1acc1; --primary: #a6bfff; --primary-strong: #c4d4ff;
  --primary-soft: #172544; --danger: #ff8a80; --ok: #86efac; --warn: #facc15;
  --shadow: 0 6px 20px rgb(0 0 0 / 12%);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", "Manrope", Arial, sans-serif; }
button, input, select { font: inherit; }
button, select, input { min-height: 42px; }
button, select { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
main:focus:not(:focus-visible) { outline: none; }
a { color: var(--primary-strong); text-underline-offset: 3px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
h1, h2, h3 { line-height: 1.25; }
h3 { font-size: 14px; margin: 20px 0 10px; }
.small { font-size: 12px; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 50; background: var(--surface); padding: 12px; border-radius: 8px; }
.skip-link:focus { top: 12px; }

/* Shell and navigation */
.app { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); padding: 24px 16px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 14px; }
.brand-icon { width: 36px; height: 36px; object-fit: contain; display: block; flex-shrink: 0; }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 15px; }
.brand-copy span { font-size: 11px; color: var(--text-muted); }
.nav-group { display: grid; gap: 6px; }
.nav-label, .eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.nav-label { padding: 0 10px 6px; }
.nav-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border-radius: 8px; color: var(--text-muted); text-decoration: none; }
.nav-btn:hover { background: var(--surface-soft); color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-spacer { flex: 1; min-height: 12px; }
.status-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: var(--surface-soft); font-size: 12px; }
.status-box strong { display: block; margin-bottom: 5px; }
.theme-toggle, .btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 9px 12px; }
.theme-toggle:hover, .btn:hover { background: var(--surface-soft); }
.btn.primary { background: #5538f2; border-color: #5538f2; color: #fff; }
.btn.primary:hover { background: #432cc7; }
.mobile-top, .mobile-close { display: none; }
main { min-width: 0; padding: 30px 32px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.eyebrow { margin-bottom: 8px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.page-head p { margin: 8px 0 0; color: var(--text-muted); max-width: 720px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; padding-top: 18px; }
.window-context { font-size: 12px; color: var(--text-muted); margin: 0 0 18px; }
.notice { padding: 12px 16px; border: 1px solid var(--warn); border-radius: 8px; color: var(--warn); margin-bottom: 16px; }

/* Cards and inspection */
.stack { display: grid; gap: 16px; }
.grid-4, .grid-3, .grid-2 { display: grid; gap: 16px; align-items: start; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { min-width: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 14px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 16px; }
.card-head p { margin: 6px 0 0; font-size: 12px; color: var(--text-muted); }
.metric { min-height: 144px; height: 100%; display: flex; flex-direction: column; justify-content: space-between; gap: 12px; }
.metric-label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.metric-value { font-size: 32px; font-weight: 750; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-foot { font-size: 12px; color: var(--text-muted); }
.uninstrumented { border: 1px dashed var(--border); border-radius: 10px; padding: 14px; background: var(--surface-soft); }
.uninstrumented strong { display: block; font-size: 13px; margin-bottom: 6px; }
.uninstrumented span { font-size: 12px; color: var(--text-muted); }
.uninstrumented + .uninstrumented { margin-top: 12px; }
.attention-list { list-style: none; display: grid; gap: 14px; margin: 0; padding: 0; }
.attention-list li { border-left: 3px solid var(--warn); padding-left: 12px; }
.attention-list a { display: block; margin-top: 5px; font-size: 12px; font-weight: 600; }
.healthy-note { color: var(--ok); }
.status-chip { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 600; }
.status-chip.healthy { color: var(--ok); }
.status-chip.pending { color: var(--warn); }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px 11px 0; text-align: left; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-muted); }
td { font-size: 13px; font-variant-numeric: tabular-nums; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
.code { max-height: 440px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px; background: var(--surface-soft); border-radius: 8px; font-size: 12px; }
summary { cursor: pointer; color: var(--primary-strong); padding: 12px 0; font-size: 13px; }

/* Charts: calendar positions remain visible when a day has no report. */
.funnel { display: grid; gap: 12px; }
.funnel-step { display: grid; grid-template-columns: 112px minmax(24px, 1fr) minmax(48px, auto); gap: 10px; align-items: center; }
.funnel-label { font-size: 12px; color: var(--text-muted); }
.bar-value { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.meter { width: 100%; height: 9px; }
.track { fill: var(--surface-soft); }
.fill { fill: var(--primary); }
.history-chart { display: block; width: 100%; height: auto; min-height: 150px; max-height: 260px; }
.chart-axis { fill: var(--text-muted); font-size: 11px; }
.chart-grid { stroke: var(--border); fill: none; }
.chart-missing { stroke: var(--text-muted); stroke-width: 2; }
.chart-caption { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }

/* Forms and support */
.field { display: grid; gap: 7px; min-width: 0; }
.field label, .provider-form label { font-size: 12px; font-weight: 600; }
input, select { width: 100%; max-width: 100%; min-width: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); padding: 9px 11px; border-radius: 8px; }
input::placeholder { color: var(--text-muted); }
.toolbar select { width: auto; }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.filters .field:first-child { flex: 1 1 240px; }
.filters .field { flex: 0 1 160px; }
.provider-form { margin-top: 20px; }
.provider-form fieldset { display: grid; gap: 10px; min-width: 0; padding: 16px; margin: 0; border: 1px solid var(--border); border-radius: 8px; }
.provider-form legend { padding: 0 6px; font-size: 12px; font-weight: 600; }
#provider-result:empty { display: none; }
#provider-result { margin-top: 12px; font-size: 13px; }
.support-request { padding: 18px 0; border-top: 1px solid var(--border); }
.support-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.support-contact { overflow-wrap: anywhere; }
.support-request time { font-size: 12px; color: var(--text-muted); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 32px; }
.login-card > .brand-icon { margin-bottom: 24px; }
.login-card h1 { font-size: 28px; letter-spacing: -.03em; margin: 0; }
.login-card p { margin-top: 12px; color: var(--text-muted); }
.login-card .field { margin: 22px 0 14px; }
.login-card .btn { width: 100%; }
.login-note { margin-top: 20px; background: var(--surface-soft); border-radius: 8px; padding: 12px; color: var(--text-muted); font-size: 12px; }
#login-error { color: var(--danger); }
#login-error:empty { display: none; }

@media (max-width: 1150px) {
  .app { grid-template-columns: 220px minmax(0, 1fr); }
  main { padding: 24px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-wrap: wrap; }
  .toolbar { padding-top: 0; }
}
@media (max-width: 820px) {
  .app { display: block; }
  .sidebar { position: fixed; z-index: 30; top: 0; left: 0; width: min(300px, calc(100vw - 40px)); transform: translateX(-102%); visibility: hidden; transition: transform .18s ease, visibility .18s; }
  .sidebar.open { transform: translateX(0); visibility: visible; }
  .mobile-close { display: block; align-self: end; }
  .menu-backdrop { position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / 40%); }
  .menu-open { overflow: hidden; }
  .mobile-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 15; }
  main { padding: 20px 16px 40px; scroll-margin-top: 76px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 26px; }
}
@media (max-width: 500px) {
  .grid-4 { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .card { padding: 16px; }
  .login-card { padding: 24px; }
  .funnel-step { grid-template-columns: 100px minmax(20px, 1fr) minmax(48px, auto); gap: 8px; }
  .support-request .card-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
