/* EK KPI Hub - one hand-written stylesheet, no build step.
   A light grey page, a quiet sidebar, and the work on a white card.
   Status colours are the ones report_builder.py uses, so the screen and the
   deck never disagree about what good, warn and bad look like. */

:root {
  --page: #e6e6e8;
  --rail: #f4f4f6;
  --surface: #ffffff;
  --sunken: #f7f8f9;

  --ink: #16181d;
  --ink-soft: #4a5057;
  --muted: #8b9199;
  --faint: #b6bcc4;

  --line: #e8e9ec;
  --line-soft: #f0f1f3;

  /* Brand and status, matching the deck. */
  --navy: #0f2a44;
  --teal: #0e7c7b;
  --good: #2e7d5b;
  --warn: #c77e1b;
  --bad: #b3312c;
  --grey-bar: #b6c2cd;

  --a-orange: #ff4f18;
  --a-blue: #2f80ed;
  --a-pink: #ff5fa2;
  --a-purple: #6c4ff5;
  --a-green: #8ed44a;
  --a-amber: #f5a623;

  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI Variable Display", "Segoe UI", -apple-system, Inter,
               system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 0.92em; }

/* ============================================================= app shell */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: 252px;
  flex: 0 0 252px;
  background: var(--rail);
  padding: 22px 14px 24px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 20px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(150deg, var(--teal), var(--navy));
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}

.rail-group { margin-top: 16px; }
.rail-label {
  padding: 0 10px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--faint);
}

.rail a.item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-md);
  color: var(--ink-soft); font-weight: 500; text-decoration: none;
  margin-bottom: 1px;
}
.rail a.item:hover { background: #eaeaee; color: var(--ink); text-decoration: none; }
.rail a.item.on {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.rail .ico { width: 17px; flex: 0 0 17px; text-align: center; opacity: 0.7; }
.rail a.item.on .ico { opacity: 1; }

.rail .count {
  margin-left: auto; font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
  background: #e4e5e9; color: var(--ink-soft);
}
.rail .count.alert { background: var(--bad); color: #fff; }

.rail-foot { margin-top: auto; padding-top: 18px; }
.rail-foot a { color: var(--muted); font-size: 13px; padding-left: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 18px 18px; }

.topbar { display: flex; align-items: center; gap: 14px; height: 62px; flex: 0 0 62px; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.crumbs .here { color: var(--ink); font-weight: 600; }
.crumbs .sep { color: var(--faint); }
.topbar .spacer { margin-left: auto; }
.topbar .chipbtn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-soft); font-size: 14px; text-decoration: none;
}
.topbar .chipbtn:hover { color: var(--ink); text-decoration: none; }

.canvas {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 28px 30px 34px; flex: 1;
}

/* ========================================================== page header */

.pagehead { display: flex; align-items: flex-start; gap: 20px; padding-bottom: 20px; }
.pagehead h1 {
  margin: 0; font-size: 27px; font-weight: 700; letter-spacing: -0.02em;
}
.pagehead .sub { margin: 5px 0 0; color: var(--muted); font-size: 14.5px; max-width: 66ch; }
.pagehead .actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex: 0 0 auto; }

h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; margin: 32px 0 10px; }
h3 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.lede { color: var(--muted); max-width: 68ch; margin: 0 0 12px; font-size: 14px; }

/* =============================================================== buttons */

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 18px;
  font-family: inherit; font-size: 14.5px; font-weight: 600;
  color: #fff; background: #1d1f24; border: 0; border-radius: 999px;
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { background: #000; color: #fff; text-decoration: none; }
button:disabled { background: #d7d9de; cursor: not-allowed; }
button.ghost, .btn.ghost {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
}
button.ghost:hover, .btn.ghost:hover { background: var(--sunken); color: var(--ink); }
button.small, .btn.small { height: 34px; padding: 0 14px; font-size: 13.5px; }
button.danger { background: var(--bad); }
button.danger:hover { background: #8d2622; }

/* ================================================================= cards */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 20px;
}
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* Stat tiles: the numbers you want without reading anything. */
.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: 12px; margin-bottom: 4px;
}
.tile {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px 15px; background: var(--surface);
  display: flex; flex-direction: column;
}
.tile .top {
  font-size: 11px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
  display: flex; align-items: center; gap: 7px;
}
.tile .value {
  font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.tile .value.good { color: var(--good); }
.tile .value.warn { color: var(--warn); }
.tile .value.bad { color: var(--bad); }
.tile .foot { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.tile .foot .up { color: var(--good); font-weight: 600; }
.tile .foot .down { color: var(--bad); font-weight: 600; }
.tile.lead-good { border-left: 3px solid var(--good); }
.tile.lead-warn { border-left: 3px solid var(--warn); }
.tile.lead-bad { border-left: 3px solid var(--bad); }

/* Dashed meter under a tile value. */
.meter {
  --fill: 50%; --tint: var(--teal);
  height: 7px; margin-top: 11px; border-radius: 4px;
  background: repeating-linear-gradient(90deg, #e6e8eb 0 3px, transparent 3px 6px);
  position: relative;
}
.meter::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--fill);
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, var(--tint) 0 3px, transparent 3px 6px);
}
.meter.good { --tint: var(--good); }
.meter.warn { --tint: var(--a-amber); }
.meter.bad { --tint: var(--bad); }

/* Horizontal ranked bars, as on the error-type breakdown. */
.hbars { display: grid; gap: 11px; margin-top: 4px; }
.hbar { display: grid; grid-template-columns: 128px 1fr 44px; align-items: center; gap: 12px; }
.hbar .name { text-align: right; color: var(--ink-soft); font-size: 13.5px; font-weight: 500; }
.hbar .track { height: 17px; border-radius: 5px; background: var(--line-soft); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 5px; background: var(--teal); }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13.5px; }
.hbar.primary .fill { background: var(--bad); }
.hbar.primary .name { color: var(--bad); font-weight: 700; }
.hbar a.name { text-decoration: none; }
.hbar a.name:hover { text-decoration: underline; }

/* Solid gradient bars for a split of one total. */
.bars { display: grid; gap: 15px; }
.bar-row .bl { display: flex; align-items: baseline; margin-bottom: 6px; }
.bar-row .bl .name { color: var(--ink-soft); font-weight: 500; }
.bar-row .bl .val { margin-left: auto; font-weight: 700; }
.bar-track {
  height: 20px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(115deg, #f1f2f4 0 6px, #f7f8f9 6px 12px);
}
.bar-fill { height: 100%; border-radius: 6px; border-right: 3px solid #fff;
            background: linear-gradient(90deg, var(--c1), var(--c2)); }
.bar-row.c1 .bar-fill { --c1: #ff6a3d; --c2: var(--a-orange); }
.bar-row.c2 .bar-fill { --c1: #ff86bb; --c2: var(--a-pink); }
.bar-row.c3 .bar-fill { --c1: #5b9df9; --c2: var(--a-blue); }
.bar-row.c4 .bar-fill { --c1: #a58bff; --c2: var(--a-purple); }

.empty-state { color: var(--muted); text-align: center; padding: 36px 10px; font-size: 14px; }

/* ================================================================= forms */

label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
input[type="number"], input[type="password"], input[type="text"], textarea, select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
  font-size: 15px; font-family: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface);
}
input[type="number"] { font-size: 18px; font-weight: 600; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(14, 124, 123, 0.25); border-color: var(--teal);
}
select { cursor: pointer; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 15px; }
.note { margin-top: 16px; }
.note textarea { font-size: 14.5px; font-weight: 400; }

.toggle { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: baseline;
          margin-bottom: 18px; }
.toggle input { margin: 3px 0 0; transform: scale(1.15); }
.toggle span { font-weight: 600; color: var(--ink); font-size: 15px; }
.toggle small { flex-basis: 100%; color: var(--muted); margin: 3px 0 0 27px;
                font-weight: 400; }
.toggle label { font-weight: 400; }

#dayform:has(input[name="is_operating_day"]:not(:checked)) .fields,
#dayform:has(input[name="is_operating_day"]:not(:checked)) .note {
  opacity: 0.35; pointer-events: none;
}

form.inline { display: flex; gap: 7px; margin: 0; align-items: center; }
form.inline select, form.inline input { margin-top: 0; }

/* ================================================================ notice */

.notice {
  background: #fff8e8; border: 1px solid #f3e2be; border-radius: var(--r-md);
  padding: 12px 16px; margin: 0 0 20px; color: #6b4f16; font-weight: 500;
}
.statusline {
  background: var(--sunken); border: 1px solid var(--line);
  border-left: 3px solid var(--teal); border-radius: var(--r-md);
  padding: 12px 16px; margin: 0 0 22px; font-weight: 600; font-size: 14.5px;
}

/* ================================================================ tables */

.grid { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.grid th {
  text-align: left; background: var(--sunken); color: var(--muted);
  padding: 10px 12px; font-weight: 600; font-size: 12.5px; letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line);
}
.grid th:first-child { border-radius: var(--r-sm) 0 0 0; }
.grid th:last-child { border-radius: 0 var(--r-sm) 0 0; }
.grid td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tbody tr:hover { background: var(--sunken); }
.grid .wrap { max-width: 260px; overflow-wrap: anywhere; }
.grid .good { color: var(--good); font-weight: 700; }
.grid .warn { color: var(--warn); font-weight: 700; }
.grid .bad { color: var(--bad); font-weight: 700; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.complete { background: #e9f6f0; color: var(--good); }
.pill.optional { background: #fdf3e3; color: var(--warn); }
.pill.blocked { background: #fdecea; color: var(--bad); }

/* =============================================================== derived */

.derived {
  display: flex; align-items: baseline; gap: 14px; margin: 20px 0 6px;
  padding: 16px 20px; border-radius: var(--r-md);
  background: var(--sunken); border: 1px solid var(--line);
  border-left: 4px solid var(--grey-bar);
}
.derived .label { font-weight: 600; color: var(--muted); font-size: 14px; }
.derived .value { font-size: 32px; font-weight: 700; margin-right: auto; letter-spacing: -0.02em; }
.derived .against { color: var(--muted); font-size: 13px; }
.derived.good { border-left-color: var(--good); }
.derived.good .value { color: var(--good); }
.derived.warn { border-left-color: var(--warn); }
.derived.warn .value { color: var(--warn); }
.derived.bad { border-left-color: var(--bad); }
.derived.bad .value { color: var(--bad); }
.savemark { color: var(--muted); font-size: 12.5px; margin: 0 0 24px; }

/* =========================================================== month strip */

.striphead {
  font-size: 11px; color: var(--muted); margin: 0 0 8px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
}
.strip { display: flex; flex-wrap: wrap; gap: 5px; }
.cell {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); font-size: 12px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface);
}
.cell:hover { text-decoration: none; }
.cell.good { background: var(--good); border-color: var(--good); color: #fff; }
.cell.warn { background: var(--a-amber); border-color: var(--a-amber); color: #fff; }
.cell.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.cell.closed { background: var(--surface); border: 1px dashed var(--grey-bar); color: var(--faint); }
.cell.missing { background: #dfe2e6; border-color: #dfe2e6; color: #fff; }
.cell.weekend-empty { background: var(--surface); border-style: dotted; color: var(--faint); }
.cell.future { background: var(--surface); color: #d5d9de; }

.legend { margin-top: 14px; color: var(--muted); font-size: 12.5px; }
.legend .key {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  margin: 0 5px 0 16px; vertical-align: -1px; border: 1px solid var(--line);
}
.legend .key:first-child { margin-left: 0; }
.legend .key.good { background: var(--good); }
.legend .key.warn { background: var(--a-amber); }
.legend .key.bad { background: var(--bad); }
.legend .key.closed { background: #fff; border: 1px dashed var(--grey-bar); }
.legend .key.missing { background: #dfe2e6; }
.legend .key.weekend-empty { background: #fff; border-style: dotted; }

/* =============================================================== imports */

.dropzone {
  border: 1.5px dashed #d9dce1; border-radius: var(--r-md); background: var(--sunken);
  text-align: center; padding: 32px 20px; transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--teal); background: #eef7f7; }
.dropzone.slim { padding: 20px; }
.dropzone input[type="file"] { display: none; }
.dropzone label { cursor: pointer; font-size: 15px; color: var(--ink-soft); font-weight: 400; }
.dropzone label strong { color: var(--teal); font-weight: 600; }
.dropzone label small { display: block; color: var(--muted); margin-top: 5px; font-size: 13px; }
.htmx-indicator { display: none; color: var(--muted); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

.result {
  margin-top: 16px; padding: 16px 18px; border-radius: var(--r-md);
  background: var(--sunken); border: 1px solid var(--line);
  border-left: 4px solid var(--good);
}
.result.bad { border-left-color: var(--bad); }
.result h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.result .figures { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.result .message { color: var(--warn); font-weight: 600; font-size: 14px; }
.result .detail { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.result code { background: #fff; padding: 1px 5px; border-radius: 4px; }

.unmapped td { vertical-align: top; padding: 13px 12px; }
.unmapped code {
  display: inline-block; background: var(--sunken); padding: 2px 8px;
  border-radius: 5px; font-size: 12.5px; color: var(--navy); font-weight: 600;
}
.unmapped .says { display: inline-block; margin-left: 8px; font-weight: 600; }
.unmapped small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; max-width: 52ch; }
.unmapped small.members { color: var(--faint); font-family: Consolas, monospace; }
.unmapped select { max-width: 210px; }

/* ============================================================ month page */

.checklist th {
  background: transparent; color: var(--ink); width: 190px; font-size: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.checklist td { color: var(--muted); }
.checklist .state { text-align: right; width: 120px; }

.generate { margin-top: 18px; text-align: center; background: var(--sunken); }
.generate button { height: 50px; padding: 0 46px; font-size: 16px; }
.generate .lede { margin: 12px auto 0; }

.derivation {
  margin-top: 18px; padding: 13px 16px; background: #eef7f7;
  border: 1px solid #d4e8e8; border-radius: var(--r-md);
  font-size: 13.5px; color: var(--ink-soft);
}
.derivation strong { color: var(--teal); }

.actions input[type="text"] { padding: 7px 9px; font-size: 13.5px; margin-top: 0; }
.actions tr.new input { background: var(--sunken); }
.card button.small { margin-top: 16px; }

/* ====================================================== A-Frame walk list */

.chooser { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.chip {
  display: block; padding: 9px 14px; border: 1px solid var(--line);
  border-radius: var(--r-md); text-decoration: none; color: var(--ink);
  background: var(--surface); font-weight: 600; font-size: 14px;
}
.chip span { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.chip:hover { border-color: var(--teal); text-decoration: none; }
.chip.primary { border-color: #f3c4bf; background: #fef7f6; }
.chip.on { background: #1d1f24; border-color: #1d1f24; color: #fff; }
.chip.on span { color: #a9afb8; }

.ordering { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.printbar {
  margin: 0 0 18px; color: var(--muted); font-size: 13.5px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.printbar .hint { flex-basis: 100%; font-size: 12.5px; }

.printhead { margin: 22px 0 6px; }
.printhead h2 { margin: 0; font-size: 19px; }
.printhead p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

.walk td { padding: 10px 12px; }
.walk .big { font-size: 17px; font-weight: 700; }
.walk .tick { width: 46px; text-align: center; }
.walk .box {
  display: inline-block; width: 15px; height: 15px;
  border: 1.5px solid var(--faint); border-radius: 4px;
}
.walk tr.severe { background: #fdf0ef; }
.walk tr.severe:hover { background: #fbe6e4; }
.walk tr.severe .big { color: var(--bad); }
.walk code.quiet { color: var(--muted); font-size: 12px; }
.walk .unsure { color: var(--faint); }
.note-mark { color: var(--warn); font-weight: 700; }
.article-inline { display: none; }

/* ================================================================= login */

.loginpage {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--page);
}
.login { width: 340px; box-shadow: var(--shadow); border: 0; padding: 28px; border-radius: var(--r-lg); }
.login .brand { padding: 0 0 18px; }
.login .error { color: var(--bad); font-size: 13.5px; margin: 0 0 10px; }
.login button { width: 100%; margin-top: 18px; }

.stub h1 { margin-top: 0; }
.stub p { color: var(--muted); }

/* ============================================================== printing */

@media print {
  .rail, .topbar, .screen-only, .notice, .printbar, form, .chooser, .ordering {
    display: none !important;
  }
  body { font-size: 11pt; color: #000; background: #fff; }
  .shell { display: block; }
  .main { padding: 0; }
  .canvas { box-shadow: none; border-radius: 0; padding: 0; }
  .printhead h2 { font-size: 15pt; }
  .printhead p { color: #000; font-size: 9pt; }
  .grid { font-size: 10pt; }
  .grid th { background: #fff !important; color: #000 !important; border-bottom: 2px solid #000; }
  .grid td { border-bottom: 1px solid #bbb; }
  .grid tbody tr:hover { background: #fff; }
  .walk .box { border-color: #000; width: 17px; height: 17px; }
  tr { page-break-inside: avoid; }
  thead { display: table-header-group; }

  /* Colour is gone on a mono printer, so severity has to be structural. */
  .walk tr.severe { background: #fff; }
  .walk tr.severe td { border-top: 1.2pt solid #000; border-bottom: 1.2pt solid #000; }
  .walk tr.severe .big { color: #000; font-weight: 800; }
  .walk tr.severe .tick::after { content: "!"; font-weight: 800; margin-left: 3px; }

  /* Portrait is the clipboard sheet: the article number moves under the
     geocode so the columns fit across 186 mm without shrinking the numbers
     that get read at the machine. */
  body.portrait .col-article { display: none; }
  body.portrait .article-inline {
    display: block; font-size: 7.5pt; color: #444; font-family: Consolas, monospace;
  }
  body.portrait .grid { font-size: 9pt; }
  body.portrait .grid td { padding: 7px 5px; }
  body.portrait .walk .big { font-size: 12pt; }
  body.portrait .walk .tick { width: 34px; }
  body.portrait .walk .box { width: 15px; height: 15px; }
}

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .rail { width: 66px; flex-basis: 66px; }
  .rail-label, .rail .count, .rail .label-text, .brand .name { display: none; }
  .rail a.item { justify-content: center; }
  .canvas { padding: 20px 16px 26px; }
}

/* =================================================== topbar, right side */

.searchbox {
  display: flex; align-items: center; gap: 9px;
  height: 40px; width: 300px; padding: 0 15px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 14px;
}
.searchbox input {
  border: 0; outline: 0; margin: 0; padding: 0; width: 100%;
  font-family: inherit; font-size: 14px; background: transparent; color: var(--ink);
}
.searchbox input::placeholder { color: var(--muted); }
.iconbtn {
  width: 40px; height: 40px; flex: 0 0 40px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  display: grid; place-items: center; color: var(--ink-soft);
  text-decoration: none; font-size: 15px; position: relative;
}
.iconbtn:hover { background: var(--sunken); text-decoration: none; }
.iconbtn .dot {
  position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--bad); border: 1.5px solid var(--surface);
}
.avatar {
  width: 40px; height: 40px; flex: 0 0 40px; border-radius: 999px;
  background: linear-gradient(150deg, var(--teal), var(--navy));
  color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; text-decoration: none;
}
.avatar:hover { text-decoration: none; color: #fff; }

/* ==================================== KPI tile, as on the reference cards */

.tile .top .badge {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  font-size: 11px; color: #fff; flex: 0 0 22px;
}
.tile .top .badge.t1 { background: var(--a-orange); }
.tile .top .badge.t2 { background: var(--a-blue); }
.tile .top .badge.t3 { background: var(--a-purple); }
.tile .top .badge.t4 { background: var(--a-green); }
.tile .top .badge.t5 { background: var(--a-amber); }
.tile .top .badge.t6 { background: var(--a-pink); }
.tile .top .kebab { margin-left: auto; color: var(--faint); letter-spacing: 1px; }
.tile .top .name { text-transform: none; letter-spacing: 0; font-size: 13px;
                   font-weight: 500; color: var(--ink-soft); }

/* The inner well the reference puts the number in. */
.tile.welled { padding: 14px; }
/* The wells line up across the row even when one delta wraps to two lines. */
.tile.welled .well {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px 14px; background: var(--surface);
  flex: 1; display: flex; flex-direction: column;
}
.tile.welled .well .delta { margin-top: auto; padding-top: 10px; }
.tile .delta { margin-top: 10px; font-size: 13px; color: var(--muted); }
.tile .delta .up { color: var(--good); font-weight: 600; }
.tile .delta .down { color: var(--bad); font-weight: 600; }
.tile .delta .flat { color: var(--muted); font-weight: 600; }

/* ============================ split-of-a-total card, as on Gross Volume */

.volume .total { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0 18px; }
.volume h3 { margin-bottom: 0; font-size: 15px; }

/* ================ twelve-month dot matrix, as on the engagement chart */

.matrix { display: flex; align-items: flex-end; gap: 10px; margin-top: 6px; flex: 1; }
.matrix .col { flex: 1; display: flex; flex-direction: column; align-items: center; }
/* The dots stack from the bottom up, so a column reads like a bar. */
.matrix .dots { display: flex; flex-direction: column-reverse; gap: 4px; width: 100%;
                align-items: center; }
.matrix .dot {
  width: 100%; max-width: 26px; aspect-ratio: 1; border-radius: 6px; background: #eef0f2;
}
.matrix .dot.on { background: var(--a-purple); }
.matrix .dot.on.good { background: var(--good); }
.matrix .dot.on.warn { background: var(--a-amber); }
.matrix .dot.on.bad { background: var(--bad); }
.matrix .tag { font-size: 12px; color: var(--muted); margin-top: 8px; }
.matrix .col.none .tag { color: var(--faint); }
.matrixwrap { display: flex; gap: 14px; align-items: stretch; }
.matrixwrap .scale {
  display: flex; flex-direction: column-reverse; justify-content: space-between;
  font-size: 11px; color: var(--muted); padding-bottom: 26px; flex: 0 0 auto;
}
.chartlegend { display: flex; gap: 16px; color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.chartlegend .k { display: inline-flex; align-items: center; gap: 6px; }
.chartlegend .sw { width: 9px; height: 14px; border-radius: 3px; background: var(--a-purple); }
.chartlegend .sw.grey { background: #e3e6e9; }

/* ============================== overlaid bar chart, thin rounded columns */

.chartcard .head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 2px; }
.chartcard .head .actions { margin-left: auto; }
.chartcard h3 { margin-bottom: 2px; font-size: 15px; }
.chartcard .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }

.plot { display: flex; gap: 12px; }
.plot .yaxis {
  display: flex; flex-direction: column-reverse; justify-content: space-between;
  font-size: 11.5px; color: var(--muted); padding-bottom: 22px; flex: 0 0 auto;
  text-align: right; min-width: 34px;
}
.plot .area {
  flex: 1; min-width: 0;
  /* Four horizontal gridlines, as on the reference. */
  background-image: repeating-linear-gradient(to top, var(--line-soft) 0 1px,
                    transparent 1px 25%);
  background-size: 100% calc(100% - 22px);
  background-repeat: no-repeat;
  border-left: 1px solid var(--line);
}
.bars-x { display: flex; align-items: flex-end; gap: 2px; height: 200px; }
.bars-x .slot { flex: 1; position: relative; height: 100%; display: flex;
                align-items: flex-end; justify-content: center; }
.bars-x .back, .bars-x .front {
  position: absolute; bottom: 0; width: 8px; border-radius: 5px;
}
.bars-x .back { background: #dfe3e7; }
.bars-x .front { background: var(--a-blue); }
.bars-x .front.good { background: var(--good); }
.bars-x .front.warn { background: var(--a-amber); }
.bars-x .front.bad { background: var(--bad); }
.bars-x .slot:hover .back { background: #cfd5db; }
.xaxis { display: flex; gap: 2px; margin-top: 7px; }
.xaxis span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }

.chartlegend .sw.sq { width: 12px; height: 12px; border-radius: 3px; }

/* ======================= segmented share bar, as on Spending Breakdown */

.ticker { display: flex; gap: 2.5px; height: 30px; margin: 14px 0 12px; }
.ticker i { flex: 1; border-radius: 3px; background: var(--c, #dfe3e7); }
.sharelist { display: grid; gap: 0; }
.sharelist .row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px;
}
.sharelist .row:last-child { border-bottom: 0; }
.sharelist .swatch { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.sharelist .row .pctv { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.sharelist .row .cnt { color: var(--muted); font-variant-numeric: tabular-nums; }
.sharelist a { color: var(--ink); }
.totalline { display: flex; align-items: baseline; }
.totalline .big { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; }
.totalline .cap { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ================================ panel: tinted header, icon, kebab */

.panel {
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 16px; background: var(--sunken);
  border-bottom: 1px solid var(--line);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft);
}
.panel-head .ic { color: var(--muted); font-size: 13px; }
.panel-head .kebab { margin-left: auto; color: var(--faint); letter-spacing: 1px; }
.panel-head a { color: var(--teal); text-transform: none; letter-spacing: 0;
                font-size: 13px; font-weight: 600; margin-left: auto; }
.panel-body { padding: 18px 16px 20px; }

/* ============= vertical capsule gauges with a hatched remainder */

.gauges { display: flex; gap: 14px; align-items: flex-end; }
.gauge { flex: 1; min-width: 0; text-align: center; }
.gauge .cap {
  position: relative; height: 168px; width: 34px; margin: 0 auto;
  border-radius: 999px;
  background: repeating-linear-gradient(135deg, #eef0f2 0 5px, #f7f8f9 5px 10px);
  overflow: hidden;
}
.gauge .fill {
  position: absolute; left: 0; right: 0; bottom: 0; border-radius: 999px;
  background: repeating-linear-gradient(135deg,
              var(--g1) 0 5px, var(--g2) 5px 10px);
  border-top: 2px solid var(--surface);
}
.gauge.good .fill { --g1: #2e7d5b; --g2: #3d9670; }
.gauge.warn .fill { --g1: #d98a1f; --g2: #f0a638; }
.gauge.bad .fill { --g1: #b3312c; --g2: #ce4741; }
.gauge .v { font-size: 15px; font-weight: 700; margin-bottom: 8px;
            font-variant-numeric: tabular-nums; }
.gauge .v.good { color: var(--good); }
.gauge .v.warn { color: var(--warn); }
.gauge .v.bad { color: var(--bad); }
.gauge .n { margin-top: 9px; font-size: 12px; color: var(--muted);
            overflow-wrap: anywhere; }
.gauge .sub { font-size: 11px; color: var(--faint); }
.gaugescale { position: relative; }
.gaugescale .rule {
  position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line);
  font-size: 10.5px; color: var(--faint); text-align: right; padding-right: 2px;
}

/* Dotted gridlines, as on the reference plots. */
.plot .area {
  background-image: repeating-linear-gradient(to right, var(--line) 0 2px,
                    transparent 2px 7px);
  background-position: 0 0, 0 25%, 0 50%, 0 75%;
  background-size: 100% 1px;
  background-repeat: repeat-x;
}
.plot .area.grid4 {
  background-image:
    repeating-linear-gradient(to right, var(--line) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(to right, var(--line) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(to right, var(--line) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(to right, var(--line) 0 2px, transparent 2px 7px);
  background-position: 0 0, 0 33%, 0 66%, 0 calc(100% - 22px);
  background-size: 100% 1px;
  background-repeat: repeat-x;
}

/* Hover card on a chart column. */
.bars-x .slot .tip {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); z-index: 5;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); box-shadow: var(--shadow);
  padding: 9px 11px; width: 156px; text-align: left; white-space: nowrap;
}
.bars-x .slot:hover .tip { display: block; }
.bars-x .tip .d { font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.bars-x .tip .r { display: flex; align-items: center; gap: 7px; font-size: 12px;
                  color: var(--muted); padding: 2px 0; }
.bars-x .tip .r .sw { width: 8px; height: 8px; border-radius: 50%; }
.bars-x .tip .r b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.bars-x .tip .f { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-soft);
                  font-size: 12px; color: var(--muted); display: flex; }
.bars-x .tip .f b { margin-left: auto; }

/* ================================================================ history */

.history td small, .compare td small {
  display: block; font-size: 11px; font-weight: 600; margin-top: 2px;
}
.history small.up, .compare small.up { color: var(--good); }
.history small.down, .compare small.down { color: var(--bad); }
.history small.flat, .compare small.flat { color: var(--muted); font-weight: 400; }
.history th:first-child, .compare th:first-child { text-align: left; }
.compare tbody th {
  background: transparent; color: var(--ink); font-weight: 600; font-size: 14px;
  border-bottom: 1px solid var(--line-soft); text-align: left;
}
.history .xaxis span { font-size: 10.5px; }
.quietpill {
  display: inline-flex; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--sunken);
}
/* With only a handful of months the columns should read as bars, not sticks. */
.history .bars-x { gap: 6px; }
.history .bars-x .front, .history .bars-x .back { width: 22px; }

/* ============================== ticking channels off, and recurrences */

.walk .tick { position: relative; }
/* The empty box is the printed sheet; the button is the screen. */
.walk .tick .box { display: inline-block; }
.walk .tickform { display: none; }
@media screen {
  .walk .tick .box { display: none; }
  .walk .tickform { display: inline-flex; margin: 0; }
}
.tickbtn {
  width: 26px; height: 26px; padding: 0; border-radius: 7px;
  background: var(--surface); color: var(--faint);
  border: 1.5px solid var(--line); font-size: 13px; line-height: 1;
}
.tickbtn:hover { background: var(--sunken); color: var(--good); border-color: var(--good); }
.tickbtn.on { background: var(--good); border-color: var(--good); color: #fff; }
.tickbtn.on:hover { background: #256a4c; color: #fff; }

.walk tr.done { background: #f2f9f5; }
.walk tr.done code { opacity: 0.7; }
.walk tr.cameback { background: #fdf0ef; }
.done-note { color: var(--good); font-weight: 600; }

.backflag {
  display: inline-block; margin-left: 7px; padding: 1px 7px;
  border-radius: 4px; background: var(--bad); color: #fff;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em;
  vertical-align: 1px;
}

.back-panel .panel-head { background: #fdf0ef; border-bottom-color: #f3c4bf;
                          color: var(--bad); }
.back-panel small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.back-panel small.members { color: var(--faint); font-family: Consolas, monospace; }
.back-panel tr.sev-chronic td { background: #fdecea; }
.back-panel .wrap { max-width: 420px; }

@media print {
  .backflag { background: #fff; color: #000; border: 1.2pt solid #000; }
  .walk tr.done, .walk tr.cameback { background: #fff; }
}
