/* Self-hosted Fira Sans and Fira Code (SIL Open Font License, see fonts/OFL.txt). */
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/fira-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/fira-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/fira-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/fira-sans-700.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Code";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/fira-code-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fira Code";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/fira-code-500.woff2") format("woff2");
}

/* ---------- tokens: light ---------- */
:root {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --chrome: #e9eef6;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --line-strong: #c7d2e0;

  --accent: #1e40af;
  --accent-ink: #1e40af;
  --accent-soft: #e4eafc;
  --cell-bar-opacity: .14;
  --on-accent: #ffffff;
  --series-2: #0f766e;

  --warn: #92400e;
  --warn-soft: #fdf3d8;
  --warn-border: #eccb7e;
  --warn-dot: #d97706;
  --danger: #b91c1c;
  --danger-soft: #fdeaea;
  --danger-border: #eeb4b4;
  --ok-dot: #15803d;
  --dot-idle: #94a3b8;

  --skeleton: #e2e8f0;
  --tip-bg: #0f172a;
  --tip-ink: #f8fafc;
  --weekend: #eaeef5;
  --row-hover: #f2f5fa;
  --th-bg: #eef2f8;

  --rail-bg: #101a2c;
  --rail-ink: #e8eef8;
  --rail-muted: #9db0c9;
  --rail-line: #223149;
  --rail-active-bg: #1b2c4c;
  --rail-active-ink: #bfdbfe;
  --rail-mark-bg: #1e40af;

  --chart-calls: #1e40af;
  --chart-human: #0f766e;
  --chart-dot: #ffffff;

  --focus: #1e40af;
  --pop-shadow: 0 10px 28px rgba(15, 23, 42, .18);
  --sheet-shadow: 0 -10px 30px rgba(15, 23, 42, .18);
  --scrim: rgba(15, 23, 42, .38);
  --radius-panel: 10px;
  --radius-ctrl: 6px;

  /* stacking scale: sheet + backdrop sit above every page layer */
  --z-rail: 30;
  --z-tabbar: 40;
  --z-popover: 60;
  --z-backdrop: 90;
  --z-sheet: 100;

  --mono: "Fira Code", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --sans: "Fira Sans", system-ui, "Segoe UI", Roboto, sans-serif;
}

/* ---------- tokens: dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0b1220;
    --surface: #111a2b;
    --chrome: #0e1728;
    --ink: #e8eef8;
    --muted: #9db0c9;
    --line: #1f2b40;
    --line-strong: #2d3d58;

    --accent: #2563eb;
    --accent-ink: #93c5fd;
    --accent-soft: #17284a;
    --cell-bar-opacity: .24;
    --on-accent: #ffffff;
    --series-2: #2dd4bf;

    --warn: #fcd34d;
    --warn-soft: #3a2c10;
    --warn-border: #7a5c1c;
    --warn-dot: #fbbf24;
    --danger: #fca5a5;
    --danger-soft: #3a1717;
    --danger-border: #7f2d2d;
    --ok-dot: #4ade80;
    --dot-idle: #64748b;

    --skeleton: #22304a;
    --tip-bg: #e8eef8;
    --tip-ink: #0f172a;
    --weekend: #16203a;
    --row-hover: #172238;
    --th-bg: #16213a;

    --chart-calls: #60a5fa;
    --chart-human: #2dd4bf;
    --chart-dot: #111a2b;

    --focus: #93c5fd;
    --pop-shadow: 0 10px 28px rgba(0, 0, 0, .5);
    --sheet-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
    --scrim: rgba(0, 0, 0, .55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1220;
  --surface: #111a2b;
  --chrome: #0e1728;
  --ink: #e8eef8;
  --muted: #9db0c9;
  --line: #1f2b40;
  --line-strong: #2d3d58;

  --accent: #2563eb;
  --accent-ink: #93c5fd;
  --accent-soft: #17284a;
  --cell-bar-opacity: .24;
  --on-accent: #ffffff;
  --series-2: #2dd4bf;

  --warn: #fcd34d;
  --warn-soft: #3a2c10;
  --warn-border: #7a5c1c;
  --warn-dot: #fbbf24;
  --danger: #fca5a5;
  --danger-soft: #3a1717;
  --danger-border: #7f2d2d;
  --ok-dot: #4ade80;
  --dot-idle: #64748b;

  --skeleton: #22304a;
  --tip-bg: #e8eef8;
  --tip-ink: #0f172a;
  --weekend: #16203a;
  --row-hover: #172238;
  --th-bg: #16213a;

  --chart-calls: #60a5fa;
  --chart-human: #2dd4bf;
  --chart-dot: #111a2b;

  --focus: #93c5fd;
  --pop-shadow: 0 10px 28px rgba(0, 0, 0, .5);
  --sheet-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
  --scrim: rgba(0, 0, 0, .55);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
button, a, summary, select, input { touch-action: manipulation; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 16px/1.5 var(--sans);
  background: var(--bg);
  color: var(--ink);
}

[hidden] { display: none !important; }
h1, h2, p { margin: 0; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 90;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-ctrl) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon.small { width: 16px; height: 16px; }
.chevron {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
  transition: transform .16s ease;
}

button:focus-visible, a:focus-visible, summary:focus-visible,
input:focus-visible, select:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-ctrl);
}

/* ---------- left rail ---------- */
.layout {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}
.rail {
  flex: 0 0 216px;
  width: 216px;
  z-index: var(--z-rail);
  background: var(--rail-bg);
  color: var(--rail-ink);
  border-right: 1px solid var(--rail-line);
}
.rail-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
}
.rail-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--rail-mark-bg);
  color: var(--on-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rail-mark .icon { width: 17px; height: 17px; }
.rail-name { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
}
.rail-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-ctrl);
  background: none;
  color: var(--rail-muted);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.rail-item:hover { color: var(--rail-ink); background: rgba(232, 238, 248, .06); }
.rail-item[aria-selected="true"], .rail-item[aria-current="page"] {
  background: var(--rail-active-bg);
  color: var(--rail-active-ink);
  font-weight: 600;
}
.rail-item .icon { width: 18px; height: 18px; }
a.rail-item { text-decoration: none; }
a.rail-item[hidden] { display: none; }
.rail-links { border-top: 1px solid var(--rail-line); margin-top: 4px; padding-top: 10px; }

.rail-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--rail-line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* data status block */
.data-status {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}
.status-line { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--dot-idle);
}
.status-dot[data-state="fresh"] { background: var(--ok-dot); }
.status-dot[data-state="stale"] { background: var(--warn-dot); }
.status-copy { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.status-through { font-weight: 600; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-updated { color: var(--rail-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rail-line);
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  transition: border-color .16s ease, color .16s ease;
}
.icon-btn .icon { width: 14px; height: 14px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { border-color: currentColor; }

/* theme toggle (rail variant) */
.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--rail-line);
  border-radius: var(--radius-ctrl);
  overflow: hidden;
}
.theme-toggle button {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 7px;
  border: 0;
  border-right: 1px solid var(--rail-line);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.theme-toggle button:last-child { border-right: 0; }
.theme-toggle button .icon { width: 13px; height: 13px; }
.theme-toggle button:hover { color: var(--rail-ink); }
.theme-toggle button[aria-pressed="true"] {
  background: var(--rail-active-bg);
  color: var(--rail-active-ink);
  font-weight: 600;
}

/* ---------- slim top bar (tablet + phone) ---------- */
.topbar {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 52px;
  padding: 6px 14px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.topbar-end .data-status { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.topbar-end .status-copy { flex-direction: row; gap: 6px; align-items: baseline; }
.topbar-end .status-updated { color: var(--muted); }
.topbar-end .icon-btn { border-color: var(--line-strong); color: var(--muted); }
.topbar-end .theme-toggle { border-color: var(--line-strong); background: var(--surface); color: var(--ink); }
.topbar-end .theme-toggle button { border-right-color: var(--line-strong); }
.topbar-end .theme-toggle button:hover { color: var(--accent-ink); }
.topbar-end .theme-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.topbar-end .btn { height: 32px; padding: 0 10px; }
.phone-end { display: none; }

/* ---------- content ---------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
}
.top-stack {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--chrome);
  border-bottom: 1px solid var(--line);
}
.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px 10px;
}
.page-title { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.content-head-actions { display: flex; gap: 8px; }

.banner {
  margin: 0 28px 10px;
  padding: 8px 12px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: center;
}
.banner.error { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.banner.notice { border-color: var(--warn-border); background: var(--warn-soft); color: var(--warn); }
.banner.loading { color: var(--muted); }
.banner .btn { margin-left: auto; }

.feed-banner {
  margin: 0 28px 10px;
  padding: 7px 12px;
  border-radius: var(--radius-ctrl);
  border: 1px solid var(--warn-border);
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
}
.feed-banner .feed-icon { width: 16px; height: 16px; }

/* ---------- filter toolbar ---------- */
.toolbar { padding: 0 28px 12px; }
.mobile-filter-toggle { display: none; }

.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.pop-anchor { position: relative; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .16s ease, background-color .16s ease;
}
.filter-btn:hover { border-color: var(--accent); }
.filter-btn[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); }
.filter-btn-text { display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.filter-btn-label { color: var(--muted); font-size: 12px; }
.filter-btn-value { font-weight: 600; }
.filter-btn-sub { color: var(--muted); font-size: 12px; }
.filter-btn .chevron { color: var(--muted); }
.filter-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  font-size: 12px;
  color: var(--ink);
}
.filter-chip .chip-x {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.filter-chip .chip-x .icon { width: 11px; height: 11px; }
.filter-chip .chip-x:hover { color: var(--danger); background: var(--danger-soft); }

.link-btn {
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 13px;
  padding: 6px 4px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.mobile-filter-done { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .16s ease, background-color .16s ease, color .16s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); filter: brightness(1.12); }
.btn:disabled { opacity: .55; cursor: not-allowed; border-color: var(--line-strong); color: var(--muted); background: var(--surface); }
.btn .icon { width: 16px; height: 16px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { border-color: var(--line-strong); background: var(--surface); color: var(--accent-ink); }
.btn.icon-only { width: 32px; min-width: 32px; padding: 0; }

/* ---------- popovers ---------- */
.popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: var(--z-popover);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-panel);
  box-shadow: var(--pop-shadow);
  padding: 12px;
  animation: pop-in .16s ease;
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.pop-cols { display: flex; gap: 14px; align-items: stretch; }
.pop-presets {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 170px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}
.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-ctrl);
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.preset-item:hover { background: var(--row-hover); }
.preset-item[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip-partial {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: 4px;
  padding: 1px 5px;
}
.pop-custom { min-width: 230px; display: flex; flex-direction: column; gap: 10px; }
.pop-note { color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.date-inputs { display: flex; gap: 10px; }
.date-inputs .field { flex: 1 1 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field-label { font-weight: 600; }
.field-hint { color: var(--danger); font-size: 11.5px; min-height: 0; }
.field-hint:empty { display: none; }

input[type="date"], input[type="text"], select {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  padding: 6px 8px;
  min-height: 34px;
  width: 100%;
  min-width: 0;
}
input[type="text"]:focus-visible, input[type="date"]:focus-visible, select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.pop-search { margin-bottom: 8px; }
.pop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 300px;
  overflow: auto;
}
.pop-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: var(--radius-ctrl);
  font-size: 13px;
  cursor: pointer;
}
.pop-option:hover { background: var(--row-hover); }
.pop-option.is-active { background: var(--row-hover); outline: 1px solid var(--line-strong); }
.pop-option[aria-selected="true"] { color: var(--accent-ink); font-weight: 600; }
.pop-option[aria-selected="true"]::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-ink);
}
.pop-option.pop-option-all { color: var(--muted); }
.pop-empty { padding: 10px; color: var(--muted); font-size: 12px; }

.status-pop { width: min(340px, 84vw); font-size: 12.5px; }
.status-pop .pop-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.status-rows { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; margin: 0 0 10px; }
.status-rows dt { color: var(--muted); white-space: nowrap; }
.status-rows dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.status-pop .warn { color: var(--warn); font-weight: 600; }
.status-pop .no-sync { color: var(--warn); font-weight: 600; }
.status-feed { display: flex; flex-direction: column; gap: 5px; border-top: 1px solid var(--line); padding-top: 9px; }
.status-feed-row { display: flex; align-items: baseline; gap: 7px; line-height: 1.4; }
.status-feed-row .status-dot { align-self: center; }
.status-feed-row .feed-err { color: var(--danger); display: block; }
.status-pop .pending-tags { margin-top: 8px; }
.status-pop .pending-tags summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; min-height: 28px; display: flex; align-items: center; }
.status-pop .pending-tags p { margin: 6px 0 4px; color: var(--muted); }
.status-pop .pending-tags ul { margin: 0; padding-left: 18px; max-height: 130px; overflow-y: auto; }
.status-pop .cov-note { margin-top: 9px; color: var(--muted); line-height: 1.45; border-top: 1px solid var(--line); padding-top: 9px; }

/* help */
.help-wrap, .card-note-help { position: relative; display: inline-flex; vertical-align: middle; }
.help-trigger, .help-pop-trigger {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
  cursor: help;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.help-trigger:hover, .help-trigger[aria-expanded="true"],
.help-pop-trigger:hover, .help-pop-trigger[aria-expanded="true"] { color: var(--accent-ink); }
.help-trigger .icon, .help-pop-trigger .icon { width: 14px; height: 14px; }
.help-tip {
  position: fixed;
  z-index: 70;
  width: min(280px, 70vw);
  padding: 9px 11px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  animation: pop-in .16s ease;
}
.help-pop {
  position: fixed;
  z-index: 70;
  width: min(340px, 84vw);
  padding: 12px;
  border-radius: var(--radius-panel);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--pop-shadow);
  font-size: 12.5px;
  line-height: 1.5;
  animation: pop-in .16s ease;
}
.help-pop p { margin: 0; }

/* ---------- panels & cards ---------- */
.panels { padding: 20px 28px 36px; display: flex; flex-direction: column; gap: 16px; }
.panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel:focus { outline: none; }
#weekly-archive { display: flex; flex-direction: column; gap: 16px; }
#weekly-archive .card > p { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  padding: 16px 18px;
  min-width: 0;
}
.card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.card-note { color: var(--muted); font-size: 12px; }
.card-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.ov-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}
.ov-grid .card { display: flex; flex-direction: column; }
#ov-trend, #ov-system, #ov-disps, #ov-agents { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
#ov-system > .bars, #ov-disps > .bars { flex: 1 1 auto; justify-content: space-between; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------- summary band ---------- */
.summary-band { padding: 16px 20px 12px; }
.summary-primary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.sum-item { padding: 2px 18px; border-left: 1px solid var(--line); min-width: 0; }
.sum-item:first-child { border-left: 0; padding-left: 2px; }
.sum-label { display: flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.sum-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 3px 0 2px;
}
.sum-sub { font-size: 12px; color: var(--muted); line-height: 1.35; }
.summary-secondary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}
.sum-pair { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sum-pair-label { display: flex; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sum-pair-label .help-trigger { width: 18px; height: 18px; }
.sum-pair-label .help-trigger .icon { width: 13px; height: 13px; }
.sum-pair-value {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -.01em;
  line-height: 1.25;
}

/* ---------- charts ---------- */
.chart-wrap { position: relative; width: 100%; overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; min-width: 320px; }
.chart-svg .grid-line { stroke: var(--line); stroke-width: 1; opacity: .55; }
.chart-svg .axis-label { fill: var(--muted); font-size: 11px; }
.chart-svg .series-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .series-dot { stroke: var(--chart-dot); stroke-width: 1.5; }
.chart-svg .weekend-band { fill: var(--weekend); }
.chart-svg .trend-dashed { fill: none; stroke-width: 2.25; stroke-dasharray: 6 5; }
.chart-svg .chart-crosshair { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-svg .chart-hot { fill: transparent; }
.chart-svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chart-tip {
  position: fixed;
  z-index: var(--z-popover);
  pointer-events: none;
  min-width: 132px;
  padding: 7px 9px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: var(--tip-ink);
  font-size: 12px;
  line-height: 1.4;
}
.chart-tip strong { display: block; margin-bottom: 3px; }
.chart-tip .tip-row { display: flex; justify-content: space-between; gap: 12px; }
.chart-tip .tip-sw { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12.5px; color: var(--ink); }
.legend .legend-note { color: var(--muted); font-size: 11.5px; }
.legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

details.data-table { margin-top: 8px; }
details.data-table > summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--accent-ink);
  font-weight: 600;
  padding: 4px 0;
  list-style: none;
}
details.data-table > summary::-webkit-details-marker { display: none; }

/* ---------- bars ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  column-gap: 12px;
  row-gap: 4px;
  align-items: baseline;
  font-size: 13px;
}
.bar-label { grid-column: 1; grid-row: 1; color: var(--ink); line-height: 1.3; overflow-wrap: anywhere; }
.bar-value { grid-column: 2; grid-row: 1; }
.bar-pct { grid-column: 3; grid-row: 1; }
.bar-track { grid-column: 1 / -1; grid-row: 2; background: var(--row-hover); border-radius: 3px; height: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; min-width: 2px; opacity: .85; }
.bar-fill.alt { background: var(--series-2); }
.bar-value, .bar-pct {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  line-height: 1.3;
}
.bar-value { font-weight: 500; min-width: 50px; }
.bar-pct { color: var(--muted); min-width: 48px; font-size: 12px; }
.bar-more {
  align-self: flex-start;
  margin-top: 2px;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 12px;
  padding: 4px 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- tables ---------- */
.table-scroll {
  overflow: auto;
  max-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctrl);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 5px; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.swipe-hint { display: none; }
table.data {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 14px;
}
table.data th, table.data td {
  height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.25;
}
table.data th:first-child, table.data td:first-child,
table.data td.align-left, table.data th.align-left { text-align: left; }
table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  background: var(--th-bg);
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
table.data th:first-child, table.data td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
table.data thead th:first-child { z-index: 3; background: var(--th-bg); }
table.data tbody tr:hover td { background: var(--row-hover); }
table.data td.num, table.data th.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
table.data tr.total-row td {
  font-weight: 700;
  background: var(--th-bg);
  border-top: 1px solid var(--line-strong);
}
table.data tr.total-row td:first-child { background: var(--th-bg); }
table.data tr.unassigned td, table.data tr.unassigned td:first-child { background: var(--row-hover); }
table.data .row-tag {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--row-hover);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 5px;
}
table.data td.trunc, table.data th.trunc {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cell-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  height: 36px;
  text-align: right;
}
.cell-bar-fill {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: var(--w, 0%);
  max-width: 100%;
  background: var(--accent);
  opacity: var(--cell-bar-opacity, .14);
  border-radius: 3px;
}
.cell-bar-text { position: relative; z-index: 1; }

th button.sort-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: inherit;
  background: none;
  border: 0;
  padding: 4px 2px;
  min-height: 26px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
th .caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; opacity: .35; }
th.sort-asc .caret { border-bottom: 5px solid var(--accent-ink); opacity: 1; }
th.sort-desc .caret { border-top: 5px solid var(--accent-ink); opacity: 1; }

/* calls table: fixed columns, mono ids and times, horizontal scroll when narrow */
table.calls { table-layout: fixed; width: 100%; min-width: 1170px; }
table.calls th:nth-child(1), table.calls td:nth-child(1) { width: 138px; font-family: var(--mono); font-size: 12.5px; max-width: none; overflow: visible; text-overflow: clip; }
table.calls th:nth-child(2), table.calls td:nth-child(2) { width: 130px; }
table.calls th:nth-child(3), table.calls td:nth-child(3) { width: 150px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
table.calls th:nth-child(4), table.calls td:nth-child(4) { width: 110px; }
table.calls th:nth-child(5), table.calls td:nth-child(5) { width: 130px; }
table.calls th:nth-child(6), table.calls td:nth-child(6) { width: 140px; }
table.calls th:nth-child(7), table.calls td:nth-child(7) { width: 100px; max-width: none; overflow: visible; text-overflow: clip; }
table.calls th:nth-child(8), table.calls td:nth-child(8) { width: 88px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.calls th:nth-child(9), table.calls td:nth-child(9) { width: 72px; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.calls th:nth-child(10), table.calls td:nth-child(10) { width: 108px; font-family: var(--mono); font-size: 12.5px; }
table.calls td { overflow: hidden; text-overflow: ellipsis; }

/* ---------- segmented controls ---------- */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctrl);
  overflow: hidden;
  background: var(--surface);
}
.seg .seg-btn {
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  min-height: 30px;
  padding: 0 10px;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}
.seg .seg-btn:last-child { border-right: 0; }
.seg .seg-btn:hover { color: var(--accent-ink); }
.seg .seg-btn[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.matrix-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.matrix-scroll { max-height: 620px; }
table.matrix {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
}
table.matrix caption {
  caption-side: top;
  text-align: left;
  color: var(--muted);
  font-size: 11.5px;
  padding: 0 2px 7px;
}
table.matrix th, table.matrix td {
  padding: 0 10px;
  height: 34px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.25;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
table.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  background: var(--th-bg);
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
table.matrix th.row-head, table.matrix td.row-head {
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--line);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--sans);
  font-size: 13px;
}
table.matrix thead th.row-head { z-index: 4; background: var(--th-bg); }
table.matrix tbody tr:hover td, table.matrix tbody tr:hover td.row-head { background: var(--row-hover); }
table.matrix tr.unassigned td, table.matrix tr.unassigned th.row-head { background: var(--row-hover); }
table.matrix tr.total-row th.row-head, table.matrix tr.total-row td {
  font-weight: 700;
  background: var(--th-bg);
  border-top: 1px solid var(--line-strong);
}
table.matrix td.total-col, table.matrix th.total-col { border-left: 1px solid var(--line-strong); }

/* agent status time */
.status-meta { margin-bottom: 10px; }
.status-meta .card-note { display: block; max-width: none; margin: 0 0 4px; line-height: 1.45; }
.status-warn { display: flex; align-items: baseline; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; margin: 0; }
.status-warn .icon { width: 14px; height: 14px; align-self: center; }
table.status-matrix th.row-head, table.status-matrix td.row-head { max-width: 220px; }
table.status-matrix td, table.status-matrix th { min-width: 88px; }

/* ---------- pager ---------- */
.pager-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
}
.pager .pager-info { white-space: nowrap; }
.pager .btn { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.page-size { white-space: nowrap; }
.page-size select { width: auto; min-height: 30px; padding: 2px 6px; font-size: 12.5px; }
.mobile-call-list { display: none; }

/* ---------- states ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
}
.state .state-icon { width: 28px; height: 28px; stroke: var(--line-strong); }
.state.strong { color: var(--ink); }
.state p { margin: 0; font-size: 13.5px; }
.loading-inline { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; font-size: 13.5px; }

.skeleton-block { padding: 8px 0; min-height: 160px; }
.skeleton-block.compact { min-height: 0; padding: 4px 0; }
.skeleton-line { height: 13px; border-radius: 4px; background: var(--skeleton); margin: 11px 0; animation: skeleton-pulse 1.4s ease-in-out infinite; }
.skeleton-line.h1 { height: 26px; }
.skeleton-line.w25 { width: 25%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w55 { width: 55%; }
.skeleton-line.w70 { width: 70%; }
.skeleton-line.w85 { width: 85%; }
@keyframes skeleton-pulse { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.inline-error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-ctrl);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
}
.inline-error .btn { margin-left: auto; }

.drill-link {
  border: 0;
  background: transparent;
  color: var(--accent-ink);
  padding: 3px 0;
  font: inherit;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.drill-link:hover, .drill-link:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
.drill-link:hover { color: var(--accent); }

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent-ink);
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.footer { padding: 4px 28px 30px; color: var(--muted); font-size: 12px; }
.footer p { margin: 0; max-width: 900px; }

.sheet-scrim { display: none; }
.sheet-head { display: none; }
.sheet-section-title { display: none; }
.sheet-body { display: contents; }
.sheet-reset { display: none; }

/* Phone/tablet tab bar and "More" sheet only exist below 1100px. */
#tabbar, #more-sheet { display: none; }

/* ---------- tablet and phone chrome (<= 1099px) ---------- */
@media (max-width: 1099px) {
  .topbar { display: flex; position: sticky; top: 0; z-index: var(--z-rail); }
  .top-stack { top: 52px; }
  .rail {
    position: fixed;
    inset: auto 0 0 0;
    flex: 0 0 auto;
    width: auto;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-right: 0;
    border-top: 1px solid var(--rail-line);
    z-index: var(--z-tabbar);
  }
  .rail-inner { position: static; height: 100%; flex-direction: row; overflow: visible; }
  .rail-brand, .rail-foot { display: none; }
  #rail-nav .rail-group { display: none; }
  .rail-nav { flex: 1 1 auto; min-width: 0; display: flex; padding: 4px 6px; gap: 2px; }
  #tabbar { display: flex; flex: 1 1 auto; min-width: 0; gap: 2px; }
  #tabbar .rail-item {
    flex: 1 1 0;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 48px;
    padding: 4px 2px;
    font-size: 10.5px;
    text-align: center;
  }
  #tabbar .rail-item .icon { width: 19px; height: 19px; }
  .content { margin-left: 0; padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .content-head { display: none; }
  .ov-grid { grid-template-columns: minmax(0, 1fr); }
  .span-8, .span-6, .span-4 { grid-column: auto; }
  .split-2 { grid-template-columns: minmax(0, 1fr); }
  .panels { padding: 16px 16px 28px; }
  .banner, .feed-banner { margin-left: 16px; margin-right: 16px; }
  .toolbar { padding: 0 16px 12px; }
  .footer { padding: 4px 16px 24px; }
}

/* ---------- phone layout (<= 640px) ---------- */
@media (max-width: 640px) {
  .topbar { min-height: 56px; height: 56px; gap: 8px; padding: 0 12px; flex-wrap: nowrap; }
  .topbar-title { font-size: 15px; }
  .topbar-end { display: none; }
  .phone-end { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
  .phone-icon-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-ctrl);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
  }
  .phone-icon-btn:hover { border-color: var(--accent); }
  .phone-icon-btn .icon { width: 20px; height: 20px; }
  .phone-status-dot { width: 12px; height: 12px; }
  /* Above the page content (sticky table headers, bars) but under the top bar, tab bar,
     popovers and the filter sheet, so scrolled content never shows through the filters. */
  .top-stack { top: 56px; z-index: 20; }

  .toolbar { padding: 0 12px 10px; }
  .mobile-filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    padding: 6px 10px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-ctrl);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
  }
  .mobile-filter-toggle:hover { border-color: var(--accent); }
  .mobile-filter-copy { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
  .mobile-filter-copy strong { font-size: 13px; }
  .mobile-filter-copy small {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .toolbar[data-mobile-open="true"] .mobile-filter-toggle .chevron { transform: rotate(180deg); }
  .toolbar[data-mobile-open="false"] .filter-form { display: none; }

  .toolbar[data-mobile-open="true"] .filter-form {
    display: flex;
    flex-wrap: nowrap;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: var(--z-sheet);
    max-height: 85vh;
    max-height: 85dvh;
    overflow: hidden;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 16px env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--sheet-shadow);
  }
  .toolbar[data-mobile-open="true"] .filter-form > * { width: 100%; min-width: 0; }
  .sheet-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background: var(--scrim);
  }
  /* The sheet sits inside the sticky toolbar, which is its own stacking layer:
     lift that wrapper above the scrim (and the tab bar) while the sheet is open. */
  .top-stack:has(.toolbar[data-mobile-open="true"]) { z-index: var(--z-sheet); }

  .sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 56px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
  }
  .sheet-title { margin: 0; font-size: 15px; font-weight: 700; }
  .sheet-close { width: 44px; height: 44px; border-color: transparent; }
  .sheet-close .icon { width: 20px; height: 20px; }
  .sheet-section-title {
    display: block;
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
  }
  .sheet-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    flex-direction: column;
    gap: 14px;
    padding: 14px 0 16px;
  }
  .sheet-body > * { width: 100%; min-width: 0; }
  .active-filters {
    flex: 0 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .btn.mobile-filter-done { display: inline-flex; width: 100%; min-height: 46px; margin-top: 0; }
  #reset { display: none; }
  .sheet-reset { display: inline-flex; width: 100%; min-height: 46px; }

  .pop-anchor { position: static; }
  #date-btn { display: none; }
  #date-pop { display: block; position: static; border: 0; box-shadow: none; padding: 0; animation: none; }
  .filter-form .popover {
    position: static;
    width: auto;
    min-width: 0;
    box-shadow: none;
    border: 1px solid var(--line);
    padding: 10px;
  }
  .pop-cols { flex-direction: column; gap: 10px; }
  .pop-presets { border-right: 0; border-bottom: 1px solid var(--line); padding-right: 0; padding-bottom: 8px; }
  .preset-item { min-height: 44px; }
  .pop-custom { min-width: 0; }
  .date-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .date-inputs .field { min-width: 0; }
  .filter-btn { min-height: 46px; justify-content: space-between; width: 100%; }
  .filter-pop { max-height: 40dvh; overflow-y: auto; }
  .filter-chip { min-height: 44px; }
  .filter-chip .chip-x { width: 40px; height: 40px; }
  .link-btn { min-height: 44px; padding: 10px 6px; }
  input[type="date"], input[type="text"], select { min-height: 44px; font-size: 16px; }
  .btn { min-height: 44px; }
  .btn.icon-only { width: 44px; min-width: 44px; }
  .help-trigger { width: 44px; height: 44px; }
  .help-trigger .icon { width: 17px; height: 17px; }
  .seg .seg-btn { min-height: 44px; }
  .pager .btn { min-height: 44px; }
  .page-size select { min-height: 44px; }
  .status-pop .pending-tags summary { min-height: 44px; }
  .bar-more { min-height: 44px; }

  .panels { padding: 12px 12px 24px; gap: 12px; }
  .panel { gap: 12px; }
  .card { padding: 13px 12px; border-radius: 8px; }
  .card-head { margin-bottom: 10px; }
  .card-note { display: block; margin-top: 2px; }
  .summary-band { padding: 12px 12px 10px; }
  .summary-primary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 0; }
  .sum-item { padding: 2px 12px; }
  .sum-item:nth-child(odd) { border-left: 0; padding-left: 2px; }
  .sum-value { font-size: 24px; }
  .summary-secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
  .sum-pair-value { font-size: 16px; }

  .swipe-hint { display: block; margin: 0 0 5px; color: var(--muted); font-size: 11.5px; }
  .table-scroll { max-width: 100%; }
  table.data th, table.data td { padding: 0 10px; height: 44px; }
  table.data thead th { height: 44px; }
  table.data .cell-bar { height: 44px; }
  table.matrix th, table.matrix td { height: 44px; }
  th button.sort-btn { min-height: 44px; padding: 8px 2px; }
  .drill-link { min-height: 44px; display: inline-flex; align-items: center; }

  .bar-row {
    column-gap: 8px;
    row-gap: 3px;
    font-size: 12px;
  }

  .chart-svg { min-width: 560px; }
  .banner { align-items: flex-start; }
  .banner .btn, .inline-error .btn { min-height: 44px; }
  .feed-banner { flex-wrap: nowrap; align-items: flex-start; }
  .feed-banner > span:not(.feed-icon) { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  .feed-banner .link-btn { flex: 0 0 auto; }

  #calls-table > .table-block { display: none; }
  .mobile-call-list { display: grid; gap: 8px; }
  .mobile-call {
    border: 1px solid var(--line);
    border-radius: var(--radius-ctrl);
    background: var(--surface);
  }
  .mobile-call summary {
    cursor: pointer;
    list-style: none;
    padding: 11px 12px;
    min-height: 56px;
  }
  .mobile-call summary::-webkit-details-marker { display: none; }
  .mobile-call .mobile-call-chevron { float: right; width: 18px; height: 18px; color: var(--accent-ink); }
  .mobile-call[open] .mobile-call-chevron { transform: rotate(180deg); }
  .mobile-call-main { display: block; font-weight: 700; margin-right: 20px; }
  .mobile-call-date, .mobile-call-context { display: block; color: var(--muted); font-size: 12px; }
  .mobile-call dl {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) minmax(0, 2fr);
    gap: 5px 10px;
    margin: 0;
    padding: 11px 12px;
    border-top: 1px solid var(--line);
    font-size: 13px;
  }
  .mobile-call dt { color: var(--muted); }
  .mobile-call dd { margin: 0; overflow-wrap: anywhere; }

  .status-feed-row { flex-wrap: wrap; }
}

@media (max-width: 380px) {
  .summary-primary { grid-template-columns: 1fr; }
  .sum-item { border-left: 0; padding-left: 2px; }
  #tabbar .rail-item { font-size: 10px; }
  .theme-toggle .theme-label { display: none; }
  .theme-toggle button { min-width: 44px; }
  #download .btn-text { display: none; }
  #download { min-width: 44px; padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  .skeleton-line { animation: none; }
  .popover, .help-tip, .help-pop { animation: none; }
  .chevron, .filter-btn, .rail-item, .btn, .seg .seg-btn, .preset-item, .theme-toggle button { transition: none; }
}

/* Reference archive (fixed historical tables) */
.archive-box { margin-top: 16px; }
.archive-summary { cursor: pointer; display: flex; flex-direction: column; gap: 2px; list-style: none; padding: 2px 0; }
.archive-summary::-webkit-details-marker { display: none; }
.archive-summary strong { font-size: 14px; color: var(--ink); }
.archive-summary span { font-size: 13px; color: var(--muted); }
.archive-summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.archive-box[open] > .archive-summary { margin-bottom: 12px; }
.archive-box section + section { margin-top: 20px; }

/* Hourly (single day) chart */
.hour-bar { transition: opacity .15s ease; }
.hour-slot.is-active .hour-bar { opacity: 1; stroke: var(--ink); stroke-width: 1; }
.hour-slot:not(.is-active) .hour-bar { opacity: .88; }
.chart-tip .tip-sub { display: block; margin: -2px 0 4px; font-size: 11px; opacity: .8; }

/* ---------- Sign-in page (spec 002) ---------- */
.login-body { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink); }
.login-brand-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 28px 24px 22px; box-shadow: 0 1px 2px rgba(15, 23, 42, .05); }
.login-card h1 { margin: 0; font-size: 21px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.login-sub { margin: 4px 0 20px; color: var(--muted); font-size: 13.5px; }
#login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink); }
.login-field input {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-ctrl);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 16px;
}
.login-field input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.login-password { position: relative; display: block; }
.login-password input { padding-right: 48px; }
.login-reveal {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: var(--radius-ctrl);
}
.login-reveal:hover { color: var(--accent-ink); }
.login-reveal:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.login-reveal .icon { width: 19px; height: 19px; }
.login-submit { width: 100%; min-height: 44px; font-size: 15px; margin-top: 4px; }
.login-error {
  display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--danger-border);
  border-radius: var(--radius-ctrl); background: var(--danger-soft); color: var(--danger); font-size: 13.5px;
}
.login-error[hidden] { display: none; }
.login-error .icon { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.login-foot { margin: 18px 0 0; color: var(--muted); font-size: 12.5px; text-align: center; }
@media (prefers-reduced-motion: reduce) { .login-reveal, .login-submit { transition: none; } }

/* ---------- One app shell: grouped rail, account menu, dialog (spec 002) ---------- */
.rail-group { display: flex; flex-direction: column; gap: 2px; }
.rail-group[hidden] { display: none; }
.rail-group + .rail-group { margin-top: 14px; }
.rail-group-label {
  margin: 0 0 4px; padding: 0 10px; color: var(--rail-muted); font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; opacity: .8;
}
.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rail-item:focus-visible { outline: 2px solid var(--rail-active-ink); outline-offset: -2px; }

/* Only the active area's chrome shows. */
body.area-req #toolbar, body.area-req #feed-banner, body.area-req #data-status, body.area-req #download,
body.area-req #phone-download, body.area-req #phone-status-btn, body.area-req .ops-only { display: none !important; }
body:not(.area-req) .req-only, body:not(.area-req) #req-banner { display: none !important; }
body:not(.has-geo) .geo-credit { display: none !important; }
.req-view[hidden] { display: none; }

.account { position: relative; }
.account-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 8px; border: 1px solid transparent;
  border-radius: var(--radius-ctrl); background: none; color: var(--rail-ink); font: inherit; text-align: left; cursor: pointer;
}
.account-btn:hover { background: rgba(232, 238, 248, .06); }
.account-btn:focus-visible { outline: 2px solid var(--rail-active-ink); outline-offset: -2px; }
.account-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.account-btn .chevron { width: 16px; height: 16px; color: var(--rail-muted); flex: none; transition: transform .16s ease; }
.account-avatar {
  width: 30px; height: 30px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--rail-active-bg); color: var(--rail-active-ink); font-weight: 600; font-size: 13px;
}
.account-copy { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.account-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-role { font-size: 11.5px; color: var(--rail-muted); }
.account-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: var(--z-popover); padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--pop-shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.account-menu[hidden] { display: none; }
.account-menu-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0; border-radius: var(--radius-ctrl);
  background: none; color: var(--ink); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
}
.account-menu-item:hover, .account-menu-item:focus-visible { background: var(--row-hover); color: var(--accent-ink); outline: none; }
.account-menu-item .icon { width: 17px; height: 17px; color: var(--muted); }

.dialog-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: var(--z-backdrop); }
.dialog-scrim[hidden] { display: none; }
.dialog {
  position: fixed; z-index: var(--z-sheet); left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: var(--pop-shadow); padding: 22px 22px 18px;
}
.dialog h2 { margin: 0; font-size: 18px; font-weight: 600; }
.dialog-sub { margin: 4px 0 16px; color: var(--muted); font-size: 13px; }
.dialog-form { display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .btn { min-height: 40px; }
.dialog .field-help { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; z-index: var(--z-sheet); left: 50%; bottom: 24px; transform: translateX(-50%); padding: 10px 16px;
  background: var(--tip-bg); color: var(--tip-ink); border-radius: var(--radius-ctrl); box-shadow: var(--pop-shadow); font-size: 13.5px;
}

/* ---------- phone/tablet "More" sheet (spec 002) ---------- */
@media (max-width: 1099px) {
  #more-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: var(--z-backdrop);
    background: var(--scrim);
  }
  #more-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    z-index: var(--z-sheet);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    max-height: 85vh;
    max-height: 85dvh;
    background: var(--surface);
    color: var(--ink);
    border-radius: 12px 12px 0 0;
    box-shadow: var(--sheet-shadow);
    padding: 0 16px env(safe-area-inset-bottom, 0px);
    animation: more-sheet-in .18s ease;
  }
  #more-scrim { animation: more-fade-in .18s ease; }
  .more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 56px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
  }
  .more-title { margin: 0; font-size: 15px; font-weight: 700; }
  .more-close { width: 44px; height: 44px; border-color: transparent; }
  .more-close .icon { width: 20px; height: 20px; }
  .more-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    flex-direction: column;
    gap: 14px;
    padding: 14px 0 16px;
  }
  #more-nav { display: flex; flex-direction: column; gap: 2px; }
  .more-group-label {
    margin: 12px 0 4px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .more-group-label:first-child { margin-top: 0; }
  .more-sheet .rail-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-ctrl);
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
  }
  .more-sheet .rail-item:hover { background: var(--row-hover); color: var(--accent-ink); }
  .more-sheet .rail-item[aria-current="page"] {
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-weight: 600;
  }
  .more-sheet .rail-item .icon { width: 18px; height: 18px; color: var(--muted); }
  .more-sheet .rail-item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  .more-account {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }
  .more-account-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
  .more-account-avatar { background: var(--accent-soft); color: var(--accent-ink); }
  .more-account-copy { display: flex; flex-direction: column; min-width: 0; }
  .more-account-name {
    font-size: 13.5px; font-weight: 600; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .more-account-role { font-size: 11.5px; color: var(--muted); }
  .more-sheet .account-menu-item { min-height: 44px; }
  .more-theme { padding: 4px 0 0; }
  .more-theme .theme-toggle { display: flex; width: 100%; border-color: var(--line); }
  .more-theme .theme-toggle button {
    flex: 1 1 0; min-height: 44px; border-right-color: var(--line); color: var(--ink); font-size: 12.5px;
  }
  .more-theme .theme-toggle button:hover { background: var(--row-hover); color: var(--accent-ink); }
  .more-theme .theme-toggle button[aria-pressed="true"] {
    background: var(--accent-soft); color: var(--accent-ink);
  }
}

@keyframes more-sheet-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes more-fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  #more-sheet, #more-scrim { animation: none; }
  .more-sheet .rail-item, .more-theme .theme-toggle button { transition: none; }
}
@media (prefers-reduced-motion: reduce) { .account-btn .chevron { transition: none; } }
