:root {
  color-scheme: light;
  --navy: #101d30; --gold: #c8a96b;
  --masthead-bg: var(--navy); --masthead-text: #f7f7f5; --masthead-fg: #d3dae2;
  --masthead-caption: #bdc7d4; --masthead-rule: #334053; --masthead-hover: #293c56;
  --header-button-border: #617087;
  --paper: #f7f7f5; --surface: #fff; --text: #101d30; --muted: #526172;
  --line: #dce1e5; --subtle-bg: #edf0f4; --empty-bg: #f0f2f3;
  --field-bg: #fff; --field-border: #909dac;
  --button-border: #aeb8c4; --button-hover-bg: #eef1f4;
  --primary-bg: var(--navy); --primary-fg: #fff; --primary-hover-bg: #293c56;
  --danger-border: #d4a1a5; --chart-requests: var(--navy);
  --focus: #3773b5; --backdrop: rgb(16 29 48 / .65);
  --success: #246348; --success-bg: #eaf4ed;
  --warning: #795014; --warning-bg: #fff4dc; --danger: #a32d35; --danger-bg: #fceef0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text); background: var(--paper); font-synthesis: none;
}
/* Masthead + brand (navy/gold) tokens are deliberately NOT overridden below: the
   header bar stays navy in both themes and dark backgrounds are deep navy, not black. */
[data-theme="dark"] {
  color-scheme: dark;
  --paper: #0c1623; --surface: #16263a; --text: #e9eef4; --muted: #a4b4c6;
  --line: #36495f; --subtle-bg: #1d2f45; --empty-bg: #172a3f;
  --field-bg: #0f1d2e; --field-border: #607691;
  --button-border: #607691; --button-hover-bg: #20334a;
  --primary-bg: var(--gold); --primary-fg: var(--navy); --primary-hover-bg: #d8bd85;
  --danger-border: #a85a60; --chart-requests: #7ea8d6;
  --focus: #6ea8e0; --backdrop: rgb(3 8 15 / .72);
  --success: #7fd3a4; --success-bg: #123524;
  --warning: #edb866; --warning-bg: #3a2a10; --danger: #f2a0a7; --danger-bg: #3a1a1e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #0c1623; --surface: #16263a; --text: #e9eef4; --muted: #a4b4c6;
    --line: #36495f; --subtle-bg: #1d2f45; --empty-bg: #172a3f;
    --field-bg: #0f1d2e; --field-border: #607691;
    --button-border: #607691; --button-hover-bg: #20334a;
    --primary-bg: var(--gold); --primary-fg: var(--navy); --primary-hover-bg: #d8bd85;
    --danger-border: #a85a60; --chart-requests: #7ea8d6;
    --focus: #6ea8e0; --backdrop: rgb(3 8 15 / .72);
    --success: #7fd3a4; --success-bg: #123524;
    --warning: #edb866; --warning-bg: #3a2a10; --danger: #f2a0a7; --danger-bg: #3a1a1e;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 15px; line-height: 1.6; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled, select:disabled { cursor: not-allowed; opacity: .65; }
a { color: inherit; text-underline-offset: 4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(32px, 4vw, 48px); font-weight: 500; letter-spacing: -.04em; line-height: 1.12; }
h2 { font-size: 24px; font-weight: 550; letter-spacing: -.025em; line-height: 1.25; }
h3 { font-size: 20px; font-weight: 600; line-height: 1.35; }
small { font-size: 12px; color: var(--muted); }
.muted, .section-note { color: var(--muted); }
.eyebrow { font-size: 10px; letter-spacing: .18em; font-weight: 700; margin-bottom: 12px; }
.skip-link { position: fixed; top: -100px; left: 16px; padding: 12px; z-index: 10; background: var(--surface); color: var(--text); }
.skip-link:focus { top: 12px; }
.masthead { background: var(--masthead-bg); color: var(--masthead-text); }
.header-inner { max-width: 1200px; margin: auto; padding: 28px 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 32px; }
.wordmark { font-size: 25px; letter-spacing: .21em; text-decoration: none; color: var(--gold); line-height: 1.2; }
.wordmark span { display: block; font-size: 8px; letter-spacing: .25em; color: var(--masthead-fg); margin-top: 8px; }
.header-caption { margin-left: auto; font-size: 12px; color: var(--masthead-caption); }
nav { max-width: 1120px; margin: auto; display: flex; gap: 32px; border-top: 1px solid var(--masthead-rule); }
nav a { text-decoration: none; font-size: 13px; padding: 16px 0; min-height: 48px; color: var(--masthead-fg); }
nav a:hover, nav a:focus-visible { color: var(--gold); }
main { max-width: 1200px; margin: auto; padding: 48px 40px 64px; min-height: 70vh; }
.page-heading, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 24px; }
.page-heading { margin-bottom: 32px; }
.page-heading .muted { margin-top: 12px; }
.refresh-box { display: flex; align-items: flex-end; flex-direction: column; gap: 8px; text-align: right; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 16px; border: 1px solid var(--button-border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 600; line-height: 1.4; }
.button:hover:not(:disabled) { background: var(--button-hover-bg); }
.button.primary { background: var(--primary-bg); color: var(--primary-fg); border-color: var(--primary-bg); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover-bg); }
.button.danger { color: var(--danger); border-color: var(--danger-border); }
.button.header-button { background: transparent; border-color: var(--header-button-border); color: var(--masthead-text); }
.button.header-button:hover { background: var(--masthead-hover); }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--line); padding: 24px 0; gap: 24px; }
.stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat:first-child { border: 0; padding-left: 0; }
.stat strong { display: block; font-size: 36px; line-height: 1.2; font-weight: 500; font-variant-numeric: tabular-nums; }
.stat span { display: block; color: var(--muted); font-size: 12px; margin-top: 8px; }
.worker-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 16px 0; font-size: 12px; }
.section { margin-top: 48px; scroll-margin-top: 24px; }
.section-heading { margin-bottom: 20px; }
.section-heading .eyebrow { color: var(--muted); margin-bottom: 8px; }
.section-count { font-size: 12px; color: var(--muted); }
.section-note { margin: -4px 0 24px; font-size: 13px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; min-width: 0; }
.card { display: flex; flex-direction: column; gap: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.card-header > div { min-width: 0; }
.card h3, .card p, .record p, td, dd { overflow-wrap: anywhere; }
.card-subtitle { font-size: 12px; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; flex-shrink: 0; border-radius: 5px; padding: 4px 8px; font-size: 11px; font-weight: 650; background: var(--subtle-bg); color: var(--muted); line-height: 1.5; }
.badge.success, .notice.success { color: var(--success); background: var(--success-bg); }
.badge.warning, .notice.warning { color: var(--warning); background: var(--warning-bg); }
.badge.error, .notice.error { color: var(--danger); background: var(--danger-bg); }
dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
dt { color: var(--muted); font-size: 11px; }
dd { margin: 3px 0 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.card-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.extension-actions { display: flex; flex-basis: 100%; align-items: flex-end; gap: 8px; }
.days-control { display: flex; flex-direction: column; gap: 4px; }
label { font-size: 12px; font-weight: 600; }
input, select { width: 100%; min-height: 44px; border: 1px solid var(--field-border); border-radius: 8px; background: var(--field-bg); color: var(--text); padding: 10px 12px; }
.days-control select { min-width: 100px; }
.notice { padding: 14px 16px; background: var(--subtle-bg); border-radius: 8px; margin-bottom: 20px; font-size: 13px; overflow-wrap: anywhere; }
.empty { padding: 24px; text-align: center; font-size: 14px; color: var(--muted); background: var(--empty-bg); border-radius: 8px; grid-column: 1 / -1; }
.record { display: flex; align-items: flex-start; gap: 16px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.record:first-child { padding-top: 0; }
.record:last-child { padding-bottom: 0; border: 0; }
.record-body { flex: 1; min-width: 0; }
.record-title { font-weight: 600; }
.record .badge { margin-top: 4px; }
.record small { display: block; margin-top: 6px; }
.trend-control { min-width: 230px; max-width: 100%; }
.trend-control label { display: block; margin-bottom: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 20px; margin-block: 16px; font-size: 12px; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 7px; background: var(--chart-requests); }
.legend span:nth-child(2)::before { background: var(--gold); }
.legend span:nth-child(3)::before { background: var(--danger); }
.chart-scroll { overflow-x: auto; }
.chart { display: flex; align-items: flex-end; gap: 12px; height: 180px; border-bottom: 1px solid var(--line); padding: 8px 0 0; min-width: min-content; }
.bar-group { height: 100%; flex: 1 0 20px; max-width: 64px; display: flex; align-items: flex-end; gap: 3px; }
.bar { flex: 1; background: var(--chart-requests); border-radius: 3px 3px 0 0; }
.bar.voice { background: var(--gold); }
.bar.emergency { background: var(--danger); }
.table-scroll { overflow-x: auto; margin-top: 20px; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; }
caption { text-align: left; font-weight: 600; padding-bottom: 12px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; }
details { font-size: 13px; }
summary { cursor: pointer; min-height: 44px; padding: 10px 0; font-weight: 600; }
details dl { margin-top: 12px; }
.login-layout { display: grid; grid-template-columns: 1fr 400px; gap: 80px; align-items: center; padding: 40px 0; }
.login-intro h1 { font-size: clamp(36px, 5vw, 60px); margin-bottom: 24px; }
.login-intro > p { max-width: 390px; }
.intro-rule { width: 64px; height: 2px; background: var(--gold); margin: 32px 0; }
.login-card { padding: 32px; }
.login-card > .muted { margin-top: 12px; font-size: 13px; }
.login-card label { display: block; margin: 24px 0 6px; }
.login-card small { display: block; margin-top: 8px; }
.login-card .button { width: 100%; margin-top: 24px; }
.login-card .notice { margin-top: 16px; margin-bottom: 0; }
.boot { text-align: center; padding: 64px 0; }
footer { max-width: 1120px; margin: auto; border-top: 1px solid var(--line); padding: 24px 0; display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .15em; color: var(--muted); }
footer span { letter-spacing: 0; }
dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; padding: 32px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: var(--backdrop); }
dialog h2 { margin-bottom: 16px; }
dialog p { overflow-wrap: anywhere; }
dialog .notice { margin-top: 20px; }
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.theme-switch { display: inline-flex; gap: 2px; margin: 0; padding: 3px; border: 1px solid var(--masthead-rule); border-radius: 999px; min-width: 0; }
.theme-switch label { display: inline-flex; margin: 0; }
.theme-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; margin: 0; }
.theme-switch span { display: inline-flex; align-items: center; min-height: 36px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--masthead-fg); white-space: nowrap; cursor: pointer; }
.theme-switch label:hover span { background: var(--masthead-hover); color: var(--masthead-text); }
.theme-switch input:checked + span { background: var(--gold); color: var(--navy); }
.theme-switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus { -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset; caret-color: var(--text); }
@media (max-width: 900px) {
  .header-inner { padding: 24px; } nav { margin: 0 24px; gap: 24px; flex-wrap: wrap; }
  main { padding: 32px 24px 48px; } footer { margin: 0 24px; }
  .login-layout { grid-template-columns: 1fr 1fr; gap: 32px; }
  .card-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .header-inner { padding: 20px 16px; gap: 16px; } .header-caption { display: none; }
  .header-button { margin-left: auto; } .wordmark { font-size: 22px; }
  .theme-switch span { padding: 6px 10px; font-size: 11px; }
  nav { margin: 0 16px; gap: 0; justify-content: space-between; }
  nav a { flex: 0 0 33.333%; padding: 12px 4px; font-size: 12px; }
  main { padding: 32px 16px 48px; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 20px; }
  .refresh-box { align-items: flex-start; text-align: left; }
  .summary { grid-template-columns: repeat(2, 1fr); gap: 24px 16px; }
  .stat { padding-left: 16px; } .stat:nth-child(3) { border: 0; padding-left: 0; }
  .stat strong { font-size: 32px; }
  .section { margin-top: 36px; } .section-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .panel, .card { padding: 20px; } .card-header { flex-wrap: wrap; gap: 8px; }
  .card-actions .button { flex: 1 1 auto; } h2 { font-size: 22px; }
  .login-layout { grid-template-columns: 1fr; gap: 32px; padding: 0; }
  .login-intro .intro-rule, .login-intro > .muted { display: none; }
  .login-intro h1 { font-size: 36px; } .login-card { padding: 24px; }
  .trend-control { width: 100%; min-width: 0; }
  .record { flex-wrap: wrap; } .record-body { flex-basis: 100%; }
  dialog { padding: 24px; } .dialog-actions { flex-wrap: wrap; }
  .dialog-actions .button { flex: 1; }
  footer { margin: 0 16px; gap: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
.create-form label { display: block; margin: 18px 0 6px; }
.create-form small { display: block; margin-top: 4px; }
.create-form .dialog-actions { margin-top: 24px; }
.address-field { display: flex; align-items: center; gap: 8px; }
.address-field span { color: var(--muted); white-space: nowrap; }
.confirm-typed label { display: block; margin: 16px 0 6px; }
