:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #5b6472;
  --line: #e3e6eb;
  --accent: #0f5c63;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1f1;
  --good: #1f7a3f;
  --good-soft: #e5f4ea;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --band-a: #1f7a3f;
  --band-b: #9a5b00;
  --band-c: #5b6472;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --ink: #e8eaee;
    --muted: #9aa3af;
    --line: #2a313b;
    --accent: #4fb3ba;
    --accent-ink: #0e1116;
    --accent-soft: #15333a;
    --good: #5fcf8a;
    --good-soft: #15301f;
    --warn: #e7b35a;
    --warn-soft: #33260f;
    --bad: #f28b82;
    --bad-soft: #3a1714;
    --band-a: #5fcf8a;
    --band-b: #e7b35a;
    --band-c: #9aa3af;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 0 0 10px; }
h3 { font-size: 0.95rem; margin: 0 0 6px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 650; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; align-items: center; }
.nav a, .nav button {
  padding: 6px 10px; border-radius: 8px; color: var(--muted); font: inherit; font-size: 0.9rem;
  background: none; border: 0; cursor: pointer;
}
.nav a.active, .nav a:hover, .nav button:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.nav form { margin: 0; }
/* Phones: brand on its own line, the menu in one swipeable row underneath instead of a 3-line pile-up. */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 6px 16px; padding: 8px 12px; }
  .nav { margin-left: 0; width: 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav a, .nav button { white-space: nowrap; flex: none; }
}

.banner { padding: 8px 16px; font-size: 0.88rem; background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--line); }
.wrap { max-width: 980px; margin: 0 auto; padding: 20px 16px 64px; }
.narrow { max-width: 420px; }
.medium { max-width: 760px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin-bottom: 4px; }
.month-pick { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.month-pick input[type=month] { width: auto; }
td.empty { padding: 14px 6px; text-align: left; }
input[type=file] { display: block; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 0.9rem; }
input[type=file]::file-selector-button { margin-right: 10px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 3fr 2fr; } }

progress.progress {
  -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 8px; margin-top: 10px;
  border: 0; border-radius: 99px; overflow: hidden; background: var(--line);
}
progress.progress::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
progress.progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
progress.progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }

.band {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  font-weight: 700; font-size: 0.85rem; flex: none; border: 1.5px solid currentColor;
}
.band-A { color: var(--band-a); }
.band-B { color: var(--band-b); }
.band-C { color: var(--band-c); }

.queue { list-style: none; margin: 0; padding: 0; }
.queue li { border-top: 1px solid var(--line); }
.queue li:first-child { border-top: 0; }
.queue a.item { display: flex; gap: 12px; align-items: center; padding: 12px 4px; color: var(--ink); }
.queue a.item:hover { background: var(--accent-soft); text-decoration: none; }
.queue .who { flex: 1; min-width: 0; }
.queue .name { font-weight: 600; }
.queue .why { color: var(--muted); font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue .meta { text-align: right; font-size: 0.82rem; color: var(--muted); flex: none; }
.queue li.done a.item { opacity: 0.5; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.76rem; font-weight: 600;
  background: var(--line); color: var(--muted); white-space: nowrap;
}
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

.phone { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.phone:first-of-type { border-top: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; text-decoration: none;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.call { background: var(--good); border-color: var(--good); color: #fff; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.good { color: var(--good); border-color: var(--good); }
.btn[disabled], .btn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn.block { width: 100%; }

.reasons { list-style: none; margin: 0; padding: 0; }
.reasons li { padding: 10px 0; border-top: 1px solid var(--line); }
.reasons li:first-child { border-top: 0; padding-top: 0; }
.pts { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.82rem; }
.say { margin: 6px 0 0; padding: 8px 10px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.note { margin: 6px 0 0; font-size: 0.85rem; color: var(--warn); }
.script { padding: 10px 12px; background: var(--bg); border-radius: 8px; border: 1px solid var(--line); }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 560px) { .outcomes { grid-template-columns: repeat(4, 1fr); } }
.outcomes .btn { font-size: 0.9rem; padding: 10px 8px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=month], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.error { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.ok { background: var(--good-soft); color: var(--good); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
pre.note { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem; background: var(--bg); border: 1px solid var(--line); padding: 12px; border-radius: 10px; margin: 0 0 12px; }
label.small { display: inline-flex; gap: 6px; align-items: center; margin: 0; white-space: nowrap; }
.row.nowrap { flex-wrap: nowrap; }
input.size { width: 5.5em; min-height: 38px; padding: 6px 8px; text-align: right; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* Phones: wide tables scroll sideways inside their card rather than squeezing labels onto four lines. */
@media (max-width: 640px) { .table-scroll > table { min-width: 560px; } }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { color: var(--muted); font-size: 0.82rem; }

.funnel td { border: 0; padding: 4px 6px; vertical-align: middle; }
.funnel td.label { white-space: nowrap; width: 1%; padding-right: 14px; }
.funnel td.track { width: 100%; }
.funnel td.num { width: 1%; padding-left: 12px; }
progress.fbar { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 16px;
  border: 0; border-radius: 4px; overflow: hidden; background: var(--bg); }
progress.fbar::-webkit-progress-bar { background: var(--bg); border-radius: 4px; }
progress.fbar::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
progress.fbar::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.qr { margin: 8px 0 12px; }
.qr svg { display: block; width: 240px; max-width: 100%; height: auto; aspect-ratio: 1 / 1; shape-rendering: crispEdges; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; background: var(--bg); padding: 2px 6px; border-radius: 6px; }
@media print {
  .topbar, .banner, .noprint { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

.grow { flex: 1; min-width: 0; }
.right { text-align: right; }
.bad-text { color: var(--bad); }
.mt { margin-top: 12px; }
.accent-card { border-color: var(--accent); background: linear-gradient(0deg, var(--accent-soft), var(--accent-soft)), var(--surface); }
details summary { cursor: pointer; color: var(--accent); }
