:root {
  --bg: #141414;
  --panel: #1d1d1b;
  --panel-2: #242422;
  --text: #f2f0ea;
  --muted: #a6a49b;
  --muted-dim: #76746c;
  --sage: #8fa382;
  --sage-dim: #5f7259;
  --gold: #c9a25d;
  --gold-dim: #8c6f3d;
  --flag: #c1666b;
  --flag-dim: #6e3d40;
  --border: #2f2f2c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Calibri", "Segoe UI", system-ui, sans-serif;
  height: 100%;
}

.serif { font-family: Cambria, Georgia, serif; }

.ring-motif {
  position: fixed;
  top: 0;
  right: 0;
  width: 260px;
  height: 260px;
  pointer-events: none;
  z-index: 0;
}
.ring-motif circle {
  fill: none;
  stroke: var(--muted-dim);
  stroke-width: 1;
  opacity: 0.5;
}

/* IMPORTANT: [hidden] must win over the .login-screen/.app display rules below,
   otherwise toggling element.hidden in JS silently does nothing. */
.login-screen[hidden], .app[hidden] {
  display: none !important;
}

/* ---------- Login ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 48px 56px;
  text-align: center;
  min-width: 340px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.wordmark {
  font-family: Cambria, Georgia, serif;
  font-weight: bold;
  font-size: 40px;
  letter-spacing: 1px;
}
.rule {
  width: 44px;
  height: 3px;
  background: var(--gold);
  margin: 14px auto 18px;
}
.login-sub {
  color: var(--sage);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 0 0 28px;
}
#google-signin-button {
  display: flex;
  justify-content: center;
}
.login-error {
  color: var(--flag);
  font-size: 13px;
  margin-top: 18px;
}

/* ---------- App shell ---------- */
.app {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(180deg, rgba(143,163,130,0.05) 0%, transparent 100%);
  position: relative;
}
.app-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, var(--sage-dim) 0%, transparent 40%);
  opacity: 0.6;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo-slot { display: flex; align-items: center; }
.logo-slot img { height: 28px; width: auto; display: block; }
.login-logo { height: 56px !important; }
.logo-slot-center { justify-content: center; margin-bottom: 4px; }
.brand-word {
  font-family: Cambria, Georgia, serif;
  font-weight: bold;
  font-size: 22px;
  letter-spacing: 0.5px;
}
.brand-sub {
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}

/* ---------- Tab navigation ---------- */
.tab-nav {
  display: flex;
  gap: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-family: Calibri, sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: var(--sage-dim);
  color: var(--text);
}

/* ---------- Stat cards ---------- */
.stat-row {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 150px;
  flex: 1;
}
.stat-card .stat-value {
  font-family: Cambria, Georgia, serif;
  font-size: 26px;
  font-weight: bold;
  color: var(--sage);
  line-height: 1.1;
}
.stat-card .stat-value.gold { color: var(--gold); }
.stat-card .stat-label {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* ---------- View transitions ---------- */
.view-panel { animation: fadeIn 0.25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-block { display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.user-name { font-size: 13px; color: var(--muted); }
.link-btn {
  background: none; border: none; color: var(--muted-dim);
  font-size: 13px; cursor: pointer; text-decoration: underline;
  padding: 0;
}
.link-btn:hover { color: var(--text); }

/* ---------- Main grid ---------- */
.main-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

/* Same lesson as .login-screen/.app: [hidden] must win over any element that
   sets its own display property, or toggling .hidden in JS silently does nothing. */
.view-panel[hidden] {
  display: none !important;
}

.stock-panel {
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.stock-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.stock-panel-head h1 {
  font-family: Cambria, Georgia, serif;
  font-size: 22px;
  margin: 0;
}
.stock-controls { display: flex; align-items: center; gap: 10px; }
#stock-search {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  width: 220px;
}
#stock-search::placeholder { color: var(--muted-dim); }
.ghost-btn {
  background: transparent;
  border: 1px solid var(--sage-dim);
  color: var(--sage);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.ghost-btn:hover { background: var(--sage-dim); color: var(--text); }
.last-updated { font-size: 11px; color: var(--muted-dim); }
.grid-note { font-size: 11px; color: var(--muted-dim); margin: 8px 2px 0; }

.table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
}
.total-col { color: var(--gold); font-weight: bold; }
.stock-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.stock-table thead th {
  position: sticky; top: 0;
  background: var(--panel-2);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--muted);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.stock-table th.num, .stock-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.stock-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 12.5px;
}
.stock-table td.product-cell { font-family: "Calibri", sans-serif; font-size: 13px; }
.stock-table tbody tr { transition: background 0.12s ease; }
.stock-table tbody tr:hover { background: var(--panel-2); }
.status-dot { width: 8px; border-radius: 3px 0 0 3px; }
.status-cell { width: 6px; padding: 0 !important; }
.status-ok { background: var(--sage); }
.status-low { background: var(--gold); }
.status-critical { background: var(--flag); }
.loading-row, .empty-row { text-align: center; color: var(--muted-dim); padding: 30px !important; font-family: Calibri, sans-serif !important; }

/* ---------- Chat panel ---------- */
.chat-panel {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
}
.chat-head { padding: 20px 20px 14px; border-bottom: 1px solid var(--border); }
.chat-head h2 { font-family: Cambria, Georgia, serif; font-size: 17px; margin: 0 0 4px; }
.chat-head p { font-size: 11px; color: var(--sage); margin: 0; letter-spacing: 0.5px; text-transform: uppercase; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-msg {
  font-size: 13.5px;
  line-height: 1.5;
  padding: 10px 13px;
  border-radius: 10px;
  max-width: 92%;
  white-space: pre-wrap;
}
.chat-msg-assistant {
  background: var(--panel-2);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid var(--border);
}
.chat-msg-user {
  background: var(--sage-dim);
  color: var(--text);
  align-self: flex-end;
}
.chat-msg-error {
  background: var(--flag-dim);
  color: var(--text);
  align-self: flex-start;
  border: 1px solid var(--flag);
}
.chat-msg-thinking { color: var(--muted-dim); font-style: italic; align-self: flex-start; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
#chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
}
#chat-input::placeholder { color: var(--muted-dim); }
.send-btn {
  background: var(--sage-dim);
  color: var(--text);
  border: none;
  width: 40px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}
.send-btn:hover { background: var(--sage); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 860px) {
  .main-grid { grid-template-columns: 1fr; grid-template-rows: 1fr 340px; }
  .chat-panel { border-left: none; border-top: 1px solid var(--border); }
}

/* ---------- Sales analytics ---------- */
.sel{background:var(--panel);border:1px solid var(--border);color:var(--text);padding:8px 12px;border-radius:8px;font-size:13px}
#sales-search{background:var(--panel);border:1px solid var(--border);color:var(--text);padding:8px 12px;border-radius:8px;font-size:13px;width:200px}
#sales-search::placeholder{color:var(--muted-dim)}
.subtab-nav{display:flex;gap:4px;margin:0 0 16px;border-bottom:1px solid var(--border);flex-wrap:wrap}
.subtab-btn{background:none;border:none;border-bottom:2px solid transparent;color:var(--muted);
  font-family:Calibri,sans-serif;font-size:13px;font-weight:600;padding:9px 15px;cursor:pointer;transition:color .15s,border-color .15s}
.subtab-btn:hover{color:var(--text)}
.subtab-btn.active{color:var(--gold);border-bottom-color:var(--gold)}
.sales-body{flex:1;overflow-y:auto;min-height:0}
.panel-block{background:var(--panel);border:1px solid var(--border);border-radius:10px;padding:16px 18px;margin-bottom:16px}
.panel-block h3{font-family:Cambria,Georgia,serif;font-size:15px;margin:0 0 3px}
.panel-block .sub{font-size:11px;color:var(--muted-dim);margin:0 0 14px}
.bars{display:flex;flex-direction:column;gap:9px}
.bar-row{display:grid;grid-template-columns:190px 1fr 110px 74px;gap:10px;align-items:center;font-size:12.5px}
.bar-row .nm{color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bar-track{background:var(--panel-2);border-radius:3px;height:16px;overflow:hidden}
.bar-fill{height:100%;background:var(--sage);border-radius:3px}
.bar-fill.gold{background:var(--gold)}
.bar-row .val{text-align:right;font-family:"SF Mono",Menlo,monospace;color:var(--gold)}
.bar-row .chg{text-align:right;font-family:"SF Mono",Menlo,monospace;font-size:11.5px}
.up{color:var(--sage)} .down{color:var(--flag)} .flat{color:var(--muted-dim)}
.spark{width:100%;height:120px;display:block}
.mini-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(230px,1fr));gap:14px}
.pill{display:inline-block;font-size:10.5px;padding:2px 7px;border-radius:999px;border:1px solid var(--border);color:var(--muted);margin-left:6px}
.pill.new{border-color:var(--sage-dim);color:var(--sage)}
.pill.risk{border-color:var(--flag-dim);color:var(--flag)}

/* ---------- Filters and forecast ---------- */
.filter-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 14px;padding:10px 12px;
  background:var(--panel);border:1px solid var(--border);border-radius:10px}
.flt-label{font-size:10.5px;letter-spacing:1px;text-transform:uppercase;color:var(--muted-dim)}
.filter-bar .sel{padding:6px 10px;font-size:12px;max-width:180px}
.att-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:14px}
.att-card{background:var(--panel);border:1px solid var(--border);border-radius:10px;padding:15px 17px}
.att-card h4{margin:0 0 2px;font-family:Cambria,Georgia,serif;font-size:15px}
.att-card .who{font-size:10.5px;color:var(--muted-dim);text-transform:uppercase;letter-spacing:.6px;margin-bottom:11px}
.att-num{font-family:Cambria,Georgia,serif;font-size:27px;font-weight:bold;line-height:1}
.att-sub{font-size:11.5px;color:var(--muted);margin-top:3px}
.gauge{position:relative;height:9px;background:var(--panel-2);border-radius:5px;margin:12px 0 6px;overflow:hidden}
.gauge span{position:absolute;left:0;top:0;bottom:0;border-radius:5px}
.gauge .fill{background:var(--sage)}
.gauge .fill.under{background:var(--flag)}
.gauge .fill.over{background:var(--gold)}
.gauge i{position:absolute;top:-3px;bottom:-3px;width:2px;background:var(--muted);opacity:.85}
.gauge i.stretch{background:var(--gold-dim)}
.tick-row{display:flex;justify-content:space-between;font-size:10px;color:var(--muted-dim);font-family:"SF Mono",Menlo,monospace}
.mini-table{width:100%;border-collapse:collapse;font-size:12px;margin-top:10px}
.mini-table th{text-align:left;font-size:10px;text-transform:uppercase;letter-spacing:.5px;color:var(--muted-dim);padding:5px 6px;border-bottom:1px solid var(--border)}
.mini-table td{padding:5px 6px;border-bottom:1px solid var(--border);font-family:"SF Mono",Menlo,monospace}
.mini-table td.nm{font-family:Calibri,sans-serif}
.mini-table td.num{text-align:right}
.sparkcell{width:90px}
.sparkcell svg{width:90px;height:22px;display:block}

/* ---------- Bullet bars ---------- */
.bullets{display:flex;flex-direction:column;gap:7px}
.bullet{display:grid;grid-template-columns:180px 1fr 120px 54px;gap:10px;align-items:center;font-size:12.5px}
.bl-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--text)}
.bl-track{position:relative;height:18px;background:var(--panel-2);border-radius:4px;overflow:hidden}
.bl-band{position:absolute;left:0;top:0;bottom:0;background:#2b2b28}
.bl-band.mid{background:#333330}
.bl-band.low{background:#3b3b37}
.bl-fill{position:absolute;left:0;top:4px;bottom:4px;background:var(--sage);border-radius:3px}
.bl-fill.under{background:var(--flag)}
.bl-fill.over{background:var(--gold)}
.bl-track i{position:absolute;top:0;bottom:0;width:2px;background:var(--text);opacity:.85}
.bl-val{text-align:right;font-family:"SF Mono",Menlo,monospace;color:var(--gold)}
.bl-of{color:var(--muted-dim)}
.bl-pct{text-align:right;font-family:"SF Mono",Menlo,monospace;font-size:11.5px}
.tx-controls{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px}
.tx-controls .sel{padding:6px 10px;font-size:12px}

/* ---------- State map ---------- */
.statemap{width:100%;max-width:620px;display:block}
.statemap .tile rect{transition:stroke .15s}
.statemap .tile:hover rect{stroke:var(--gold)}
.state-row:hover{background:var(--panel-2)}

/* ---------- Alerts, retention, entity drawer ---------- */
.alerts{display:flex;flex-direction:column;gap:7px}
.alert{display:grid;grid-template-columns:150px 1fr auto;gap:10px;align-items:center;font-size:12.5px;
  padding:8px 11px;border-radius:7px;background:var(--panel-2);border-left:3px solid var(--muted-dim)}
.alert.warn{border-left-color:var(--gold)}
.alert.bad{border-left-color:var(--flag)}
.alert .kind{font-size:10px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted)}
.alert .who{color:var(--text);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.alert .detail{font-family:"SF Mono",Menlo,monospace;font-size:11.5px;color:var(--muted)}
.cohort-table{width:100%;border-collapse:collapse;font-size:11.5px}
.cohort-table th{font-size:10px;text-transform:uppercase;letter-spacing:.4px;color:var(--muted-dim);padding:5px 4px;text-align:center}
.cohort-table td{padding:5px 4px;text-align:center;font-family:"SF Mono",Menlo,monospace;border-radius:3px}
.cohort-table td.lbl{text-align:left;font-family:Calibri,sans-serif;color:var(--text)}
.drawer{position:fixed;right:0;top:0;bottom:0;width:min(560px,94vw);background:var(--panel);
  border-left:1px solid var(--border);box-shadow:-18px 0 50px rgba(0,0,0,.55);z-index:60;display:flex;flex-direction:column}
.drawer[hidden]{display:none !important}
.drawer-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  padding:18px 20px;border-bottom:1px solid var(--border)}
.drawer-head h2{font-family:Cambria,Georgia,serif;font-size:19px;margin:0}
.drawer-body{flex:1;overflow-y:auto;padding:18px 20px}
.clickable{cursor:pointer;text-decoration:underline;text-decoration-color:var(--border);text-underline-offset:3px}
.clickable:hover{color:var(--gold)}
.pill.tier{border-color:var(--gold-dim);color:var(--gold)}
.pill.tier.t1{background:rgba(201,162,93,.18)}
.pill.tier.t2{background:rgba(201,162,93,.10)}
.pill.tier.t3{border-color:var(--border);color:var(--muted)}
.pill.tier.t4{border-color:var(--border);color:var(--muted-dim)}

/* ---------- Tracker grid ---------- */
table.tracker td, table.tracker th{white-space:nowrap;padding:4px 7px}
table.tracker td.dim{color:var(--muted-dim)}
table.tracker td.strong,table.tracker tfoot td{font-weight:700;color:var(--text);border-top:1px solid var(--border)}
table.tracker .tiny{font-size:10px;color:var(--muted)}
table.tracker tfoot td{position:sticky;bottom:0;background:var(--panel)}
.cell-good{background:rgba(143,163,130,.28);color:var(--text)}
.cell-ok{background:rgba(143,163,130,.13)}
.cell-warn{background:rgba(201,162,93,.18)}
.cell-bad{background:rgba(193,102,107,.22)}

/* ---------- Reddit ---------- */
.rd-item{border-left:2px solid var(--border);padding:9px 13px;background:var(--panel-2);border-radius:0 7px 7px 0}
.rd-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap;margin-bottom:5px}
.rd-meta{font-family:"SF Mono",Menlo,monospace;font-size:10.5px;color:var(--muted-dim)}
.rd-sent{margin-left:auto;font-family:"SF Mono",Menlo,monospace;font-size:11px}
.rd-text{font-size:12.5px;color:var(--ink-2);line-height:1.5}
.rd-link{font-size:11px;color:var(--gold);text-decoration:none}
.rd-link:hover{text-decoration:underline}

/* ---------- Sortable tables ---------- */
.mini-table th.sortable{cursor:pointer;user-select:none;position:relative;padding-right:14px}
.mini-table th.sortable:hover{color:var(--gold)}
.mini-table th.sorted-asc::after{content:"▲";position:absolute;right:3px;font-size:7px;color:var(--gold)}
.mini-table th.sorted-desc::after{content:"▼";position:absolute;right:3px;font-size:7px;color:var(--gold)}
.bar-row .drill{background:none;border:none;color:var(--muted-dim);cursor:pointer;font-size:12px;padding:0 4px;opacity:0}
.bar-row:hover .drill{opacity:1}
.bar-row .drill:hover{color:var(--gold)}
#flt-note .pchip{margin-right:4px}

/* ==========================================================================
   SECTION RAIL
   The top tab bar held five sections in a row. The section list is going to
   grow well past that, so the sections move to a left rail grouped by area.
   Everything above this block is unchanged: .tab-nav keeps its rule (nothing
   uses it now, but the guard is additive and a live stylesheet is not the
   place to prune), and .tab-btn is reused rather than replaced, so the
   existing click wiring and .active state need no change.
   ========================================================================== */
.shell {
  flex: 1;
  display: flex;
  min-height: 0;
}
.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;   /* without this a wide table sizes the column, not itself */
  min-height: 0;
}
.rail {
  flex: 0 0 196px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(143,163,130,0.04) 0%, transparent 60%);
  min-width: 0;
}
.rail-nav {
  flex: 1 1 auto;
  min-height: 0;          /* the list scrolls, the rail does not */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px 8px 14px;
  scrollbar-width: thin;
}
.rail-nav::-webkit-scrollbar { width: 8px; }
.rail-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.rail-nav::-webkit-scrollbar-track { background: transparent; }
.rail-grp {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dim);
  padding: 14px 10px 5px;
}
.rail-grp:first-child { padding-top: 4px; }
.rail-nav .tab-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border-radius: 4px;
  text-decoration: none;
  position: relative;
}
.rail-nav .tab-btn:hover { color: var(--text); background: var(--panel-2); }
/* the selected section carries a light edge rather than a filled block */
.rail-nav .tab-btn.active {
  background: linear-gradient(90deg, rgba(143,163,130,0.16), transparent 70%);
  color: var(--text);
}
.rail-nav .tab-btn.active::before {
  content: "";
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 2px;
  background: var(--sage);
  box-shadow: 0 0 8px var(--sage);
}
.rail-foot {
  flex: 0 0 auto;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted-dim);
}
@media (max-width: 1180px) { .rail { flex-basis: 168px; } }
@media (max-width: 900px)  {
  .rail { flex-basis: 148px; }
  .rail-nav .tab-btn { font-size: 12px; padding: 6px 9px; }
  .rail-grp { font-size: 8.5px; }
}

/* ---------- Today ---------- */
/* The 25% neon rule applies here: panels stay flat with a light source along
   the top hairline, lead figures emit, ordinary figures do not. No glass, no
   large radii — that restraint is what keeps it at a quarter strength. */
.today-lead {
  border: 1px solid var(--border);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(143,163,130,0.05), transparent 70%),
    var(--panel);
  padding: 14px 16px;
  margin-bottom: 14px;
  position: relative;
}
.today-lead::before {
  content: "";
  position: absolute;
  left: 16px; right: 16px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(143,163,130,0.5), transparent);
}
.today-lead-empty {
  color: var(--muted-dim);
  font-size: 12px;
  line-height: 1.5;
  max-width: 64ch;
}

.today-grid {
  display: grid;
  /* auto-fit rather than a fixed column count: the panels are independent, so
     they should reflow rather than needing a breakpoint each. */
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  align-items: start;
}

.tpanel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  min-width: 0;              /* or a long subject line sizes the whole column */
  display: flex;
  flex-direction: column;
  position: relative;
}
.tpanel::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,162,93,0.35), transparent);
}
.tpanel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}
.tpanel-head h2 {
  font-family: Cambria, Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.01em;
}
.tpanel-count {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tpanel-body {
  padding: 4px 0;
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.tpanel-body::-webkit-scrollbar { width: 8px; }
.tpanel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.tpanel-foot {
  padding: 0 14px;
  font-size: 10.5px;
  color: var(--muted-dim);
  line-height: 1.5;
}
.tpanel-foot:not(:empty) { padding: 8px 14px 11px; border-top: 1px solid var(--border); }

.tpanel-loading { color: var(--muted-dim); font-size: 12px; padding: 10px 14px; margin: 0; }

/* Three distinct states, and they must not look alike.
   .tpanel-off  — the source is not connected
   .tpanel-none — connected, and there is genuinely nothing
   .tpanel-err  — connected and it failed
   An empty inbox panel that looked like a connected one would read as
   "you are on top of your email", which is a claim rather than an absence. */
.tpanel-off, .tpanel-none, .tpanel-err {
  font-size: 12px;
  line-height: 1.55;
  padding: 12px 14px;
  margin: 0;
}
.tpanel-off { color: var(--muted-dim); border-left: 2px solid var(--muted-dim); }
.tpanel-none { color: var(--sage); border-left: 2px solid var(--sage-dim); }
.tpanel-err { color: var(--flag); border-left: 2px solid var(--flag-dim); }
.tpanel-off code {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}

.trow {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(47,47,44,0.6);
}
.trow:last-child { border-bottom: 0; }
.trow-main { min-width: 0; }
.trow-title {
  font-size: 12.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.trow-sub {
  font-size: 11px;
  color: var(--muted-dim);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.trow-right {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.trow a { color: var(--sage); text-decoration: none; }
.trow a:hover { text-decoration: underline; }

/* Severity as a shape as well as a number, so what needs attention reads at a
   glance rather than being read. */
.tdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--muted-dim);
}
.tdot.warn { background: var(--gold); box-shadow: 0 0 6px rgba(201,162,93,0.7); }
.tdot.bad  { background: var(--flag); box-shadow: 0 0 7px rgba(193,102,107,0.8); }
.tdot.calm { background: var(--sage-dim); }

.tchip {
  display: inline-block;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--muted);
  margin-right: 6px;
  vertical-align: 1px;
}
/* A basis chip is a live claim, so it carries a faint charge. */
.tchip.lit { color: var(--gold); border-color: var(--gold-dim); box-shadow: 0 0 6px rgba(201,162,93,0.15); }

.tfig {
  font-family: "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  color: var(--text);
  /* a lead figure emits; the ordinary ones in .trow-right do not */
  text-shadow: 0 0 14px rgba(242,240,234,0.16);
}
.tfig.bad { color: var(--flag); text-shadow: 0 0 14px rgba(193,102,107,0.28); }
.tfig-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 4px;
}
.tfig-label { font-size: 11px; color: var(--muted); }
.tfig-cur {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  color: var(--muted-dim);
  letter-spacing: 0.06em;
}

@media (prefers-reduced-motion: reduce) {
  .tdot.warn, .tdot.bad { box-shadow: none; }
}

/* Below ~700px the three-column rows lose the right-hand column rather than
   squeezing it — a wait time wrapping onto two lines is worse than moving it. */
@media (max-width: 700px) {
  .today-grid { grid-template-columns: 1fr; }
  .trow { grid-template-columns: 8px 1fr; }
  .trow-right { grid-column: 2; text-align: left; margin-top: 3px; }
}

/* ---------- Customers ---------- */
/* A bad link is a flag, not a dim chip: a row whose Xero name is held twice is
   showing no balance, and that has to look different from a row that simply
   owes nothing. */
.tchip-bad { color: var(--flag); border-color: var(--flag-dim); }
#cust-grid { margin-top: 14px; }
#cust-table td { vertical-align: top; }
#cust-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#cust-table th.num { text-align: right; }

/* ---------- Deals ---------- */
/* Built phone-first: the table becomes a stack of cards below 700px rather
   than scrolling sideways, because a programme row read one column at a time
   is not a programme row. */
#deals-quality { margin-bottom: 14px; }
.deals-quality-body p { margin: 0 0 5px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.deals-quality-body p:last-child { margin-bottom: 0; }
.deals-quality-body strong { color: var(--text); }
.muted-note { color: var(--muted-dim); font-size: 11.5px; }

#deals-table td { vertical-align: top; }
#deals-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#deals-table th.num { text-align: right; }
.deals-row { cursor: pointer; }
.deals-row:hover { background: var(--panel-2); }
.deals-row-on { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--sage); }
.deals-window { font-size: 11px; color: var(--muted); white-space: nowrap; }
.deals-pace { color: var(--muted-dim); font-size: 10.5px; }

.deals-detail {
  border: 1px solid var(--border); border-radius: 6px; background: var(--panel);
  padding: 14px 16px 16px; margin-bottom: 14px; position: relative;
}
.deals-detail::before {
  content: ""; position: absolute; left: 16px; right: 16px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(143,163,130,0.5), transparent);
}
.deals-detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.deals-detail-head h2 { font-family: Cambria, Georgia, serif; font-size: 17px; margin: 0; }
.deals-detail-sub { font-size: 11.5px; color: var(--muted); margin: 3px 0 0; }
.deals-figs { display: flex; flex-wrap: wrap; gap: 18px; margin: 12px 0 10px; }
.deals-figs .tfig strong { display: block; font-family: Cambria, Georgia, serif; font-size: 20px; font-variant-numeric: tabular-nums; }
.deals-basis { font-size: 11px; color: var(--muted-dim); margin: 0 0 6px; }
.deals-note { font-size: 11.5px; margin: 0 0 6px; line-height: 1.5; }
.deals-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 8px; }
.deals-charts h3 {
  font-size: 9.5px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted-dim); margin: 0 0 4px; font-weight: 400;
}
/* A 520x170 viewBox at width:100% scales EVERYTHING, type included. In a
 * 1330px panel that is 2.56x, so an 8px tick label rendered at 20px and the
 * chart stood 435px tall. Same fault, and the same fix, as the concentration
 * chart on 31 August — never applied here.
 *
 * WIDTH is capped, not height. Capping height letterboxes the SVG inside a box
 * of the wrong aspect ratio, which leaves dead margins and puts the bars
 * somewhere a percentage cannot address — and the hover layer is positioned in
 * percentages. Capping width keeps the ratio exact, so 780/520 = 1.5x
 * everywhere and the marks are where the maths says they are.
 *
 * min-width stops the opposite failure, where a narrow panel shrank the chart
 * to 0.81x and the labels to 6px. The wrapper scrolls rather than squashing.
 *
 * MEASURED with headless Chromium at three widths, not reasoned about —
 * reasoning about it is what missed it the first time. */
.dchart { width: 100%; height: auto; display: block; max-width: 780px; min-width: 520px; }
.dchart-axis { stroke: var(--border); stroke-width: 1; }
.dchart-bar { fill: var(--sage-dim); }
.dchart-area { fill: rgba(143,163,130,0.14); }
.dchart-line { fill: none; stroke: var(--sage); stroke-width: 1.6; }
/* The target is dashed and gold on purpose: it is a plan, not a measurement,
   and it must not be mistaken for another data series. */
.dchart-target { stroke: var(--gold); stroke-width: 1; stroke-dasharray: 4 3; }
.dchart-tlabel { fill: var(--gold-dim); font-size: 8px; font-family: "SF Mono", Menlo, monospace; }
.dchart-tick { fill: var(--muted-dim); font-size: 8px; font-family: "SF Mono", Menlo, monospace; }

#deals-faults { color: var(--muted-dim); font-size: 11.5px; line-height: 1.55; }

@media (max-width: 700px) {
  #deals-table thead { display: none; }
  #deals-table, #deals-table tbody, #deals-table tr, #deals-table td { display: block; width: 100%; }
  #deals-table tr { border-bottom: 1px solid var(--border); padding: 9px 0; }
  #deals-table td { border: 0; padding: 1px 0; }
  #deals-table .num { text-align: left; }
  #deals-table td:first-child { font-size: 14px; }
  #deals-table-wrap { overflow-x: visible; }
}

/* Status and inline severity words. .tchip-bad already exists for Customers;
   these complete the set rather than redefining it. */
.tchip-ok   { color: var(--sage); border-color: var(--sage-dim); }
.tchip-warn { color: var(--gold); border-color: var(--gold-dim); }
.tchip-dim  { color: var(--muted-dim); }
.ok-text    { color: var(--sage); }
.warn-text  { color: var(--gold); }
.flag-text  { color: var(--flag); }

/* =====================================================================
   RESTYLE — 30 August 2026
   The Today mockup's visual language, applied across the app. Appended
   rather than edited in place: these rules sit last in the cascade, so
   they win at equal specificity without touching the blocks above, and
   the integrity guard sees additions rather than a rewritten file.

   The 25% neon rule still governs. Panels stay flat with a light source
   along the top hairline; only live or selected things emit. What changes
   is that the light source is now consistent — every panel, card and
   table has the same one, which is what makes a set of screens read as
   one application rather than several.
   ===================================================================== */

/* ---------- brand orb ----------
   The one genuinely futuristic object in the chrome, and the only thing
   in the header that moves. A slow counter-rotating ring on a lit core;
   5.5s is the same breath the rest of the app uses. */
.brand-orb {
  width: 26px; height: 26px; border-radius: 50%;
  flex: 0 0 auto; position: relative; margin-right: 2px;
  background: radial-gradient(circle at 34% 30%, #a9c096, var(--sage-dim) 58%, #1e241c);
  box-shadow: 0 0 0 1px rgba(143,163,130,0.35), 0 0 20px -5px rgba(143,163,130,0.85);
  animation: orb-breathe 5.5s ease-in-out infinite;
}
.brand-orb::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px solid rgba(143,163,130,0.20);
  border-top-color: rgba(201,162,93,0.55);
  animation: orb-spin 14s linear infinite;
}
@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(143,163,130,0.35), 0 0 20px -5px rgba(143,163,130,0.85); }
  50%      { box-shadow: 0 0 0 1px rgba(143,163,130,0.45), 0 0 26px -4px rgba(143,163,130,1); }
}

.app-header {
  background:
    radial-gradient(120% 300% at 0% 0%, rgba(143,163,130,0.10), transparent 55%),
    linear-gradient(180deg, rgba(201,162,93,0.03), transparent 100%);
  padding: 14px 26px;
}

/* ---------- rail ----------
   Structure unchanged — same groups, same order. What changes is the
   treatment: a ground that fades down the column, pill rows, an icon
   slot, and a lit left edge on the active row instead of a wash. */
.rail {
  background: linear-gradient(180deg, rgba(31,36,29,0.85) 0%, rgba(20,20,19,0.9) 55%, var(--bg) 100%);
}
.rail-grp {
  font-size: 8px;
  letter-spacing: 0.2em;
  padding: 15px 10px 5px;
}
.rail-nav .tab-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 9px;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
/* The icon slot is fixed width so the labels line up whatever the glyph.
   Ragged labels are the thing that makes an icon rail look unfinished. */
.rail-nav .tab-btn .ms {
  flex: 0 0 14px;
  width: 14px;
  text-align: center;
  font-size: 11px;
  line-height: 1;
  color: var(--muted-dim);
  transition: color .16s ease, filter .16s ease;
}
.rail-nav .tab-btn .lb { min-width: 0; }
.rail-nav .tab-btn:hover {
  background: var(--panel-2);
  border-color: var(--border);
}
.rail-nav .tab-btn:hover .ms { color: var(--sage); }
.rail-nav .tab-btn.active {
  background: linear-gradient(90deg, rgba(143,163,130,0.18), rgba(143,163,130,0.03) 75%);
  border-color: rgba(143,163,130,0.32);
  box-shadow: inset 2px 0 0 var(--sage), 0 0 26px -14px rgba(143,163,130,0.9);
  font-weight: 600;
}
.rail-nav .tab-btn.active .ms {
  color: #a9c096;
  filter: drop-shadow(0 0 6px rgba(143,163,130,0.85));
}

/* Placeholder rows. Dim, un-clickable, and tagged — the shape of the app
   without any suggestion that something is behind them. */
.rail-nav .tab-btn.soon {
  color: var(--muted-dim);
  cursor: default;
  opacity: 0.62;
}
.rail-nav .tab-btn.soon:hover { background: none; border-color: transparent; }
.rail-nav .tab-btn.soon:hover .ms { color: var(--muted-dim); }
.soon-tag {
  margin-left: auto;
  font-family: "SF Mono", Menlo, monospace;
  font-size: 7.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 5px;
  line-height: 1.6;
}

/* ---------- panels ----------
   One light source, everywhere. A hairline along the top edge of every
   surface, gold on data panels and sage on the ones that lead. */
.stock-panel, .panel, .card {
  position: relative;
}
.stat-card {
  border-radius: 6px;
  padding: 11px 14px;
  min-width: 132px;
  background:
    linear-gradient(180deg, rgba(201,162,93,0.045), transparent 62%),
    var(--panel);
  position: relative;
}
.stat-card::before {
  content: "";
  position: absolute;
  left: 12px; right: 12px; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,162,93,0.32), transparent);
}
/* Figures get tabular numerals so a column of them lines up, and drop a
   size: the headline tiles were competing with the data underneath. */
.stat-card .stat-value {
  font-size: 21px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat-card .stat-label {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted-dim);
}

.stock-panel-head h1 {
  letter-spacing: 0.005em;
}
/* Controls read as chrome, not as content. They were the same weight as
   the figures they filter. */
.stock-controls .sel,
.stock-controls input,
.stock-controls .ghost-btn {
  font-size: 12px;
}
.stock-controls .sel,
.stock-controls input {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--muted);
}
.stock-controls .sel:focus,
.stock-controls input:focus {
  color: var(--text);
  border-color: var(--sage-dim);
  outline: none;
  box-shadow: 0 0 0 1px rgba(143,163,130,0.25);
}

/* ---------- tables ---------- */
.stock-table thead th {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-dim);
}
.stock-table tbody tr:hover { background: var(--panel-2); }

/* ---------- the market report is deliberately untouched ----------
   It is a finished, byte-hashed artefact with its own visual identity and
   its own audience. Nothing in this block reaches it: it is served as a
   separate page and does not load this stylesheet. Recorded here so the
   next person does not "fix" the inconsistency. */

@media (prefers-reduced-motion: reduce) {
  .brand-orb, .brand-orb::after { animation: none; }
}

/* ---------- Sales chrome, reworked 30 August 2026 ----------
   The complaint was that the top of the page was frozen and ate the view: the
   title, the filter bar and six headline tiles sat between you and the data.
   Three changes, in order of how much they gave back:

     1. the subsections moved ABOVE the filters and tiles, so the thing you
        came to look at is the first thing you choose;
     2. the filter bar collapsed to one line, and hidden entirely on the two
        subsections it does not reach;
     3. the tiles shrank again.

   Nothing here is position: sticky. The only sticky element on the page is a
   table header, which is the one place it earns its keep. */
.subtab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin: 2px 0 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.subtab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .14s ease, border-color .14s ease;
}
.subtab-btn .ms { font-size: 10px; color: var(--muted-dim); transition: color .14s ease, filter .14s ease; }
.subtab-btn:hover { color: var(--text); }
.subtab-btn:hover .ms { color: var(--sage); }
.subtab-btn.active {
  color: var(--text);
  font-weight: 600;
  border-bottom-color: var(--gold);
}
.subtab-btn.active .ms {
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(201,162,93,0.7));
}

/* The filter bar: chrome, not content. */
.filter-shell { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; min-height: 26px; }
.filter-toggle {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted-dim); font: inherit; font-size: 11.5px;
  padding: 4px 10px; cursor: pointer;
}
.filter-toggle:hover { color: var(--text); border-color: var(--muted-dim); }
.filter-toggle .ms { font-size: 9px; }
/* A filtered page must never look like an unfiltered one, even with the bar
   shut. This count is the only thing between a reader and a figure that is a
   fifth of what they think it is. */
.filter-count { font-family: "SF Mono", Menlo, monospace; font-size: 9.5px; }
.filter-count.on {
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 8px;
  padding: 0 5px;
  box-shadow: 0 0 10px -4px rgba(201,162,93,0.9);
}
.filter-off-note { font-size: 11px; color: var(--muted-dim); }
.filter-bar[hidden] { display: none !important; }

.stat-row-compact { gap: 10px; margin-bottom: 12px; }
.stat-row-compact .stat-card { min-width: 108px; padding: 9px 12px; flex: 1 1 108px; }
.stat-row-compact .stat-card .stat-value { font-size: 18px; }
.stat-row-compact .stat-card .stat-label { font-size: 8.5px; }

#sales-hygiene { color: var(--gold); font-size: 11.5px; line-height: 1.5; margin: 0 0 10px; }
#sales-hygiene:empty { display: none; }

@media (max-width: 700px) {
  .subtab-btn { font-size: 12px; padding: 7px 9px 6px; }
  .subtab-btn .ms { display: none; }
}

/* The section is AGP to the people who use it; the ids, the route and the Asana
   board keep the name they were built with. Renaming an id would read as a
   deletion to the integrity guard, and renaming the board would break a join. */
.head-sub {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-dim);
  margin-left: 10px;
  vertical-align: 3px;
}

/* ---------- Doctors ---------- */
#dr-table td { vertical-align: top; }
#dr-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#dr-table th.num { text-align: right; }
.dr-row { cursor: pointer; }
.dr-row:hover { background: var(--panel-2); }
.dr-where { font-size: 11px; color: var(--muted); }
#dr-quality { margin-bottom: 14px; }
#dr-foot { color: var(--muted-dim); font-size: 11.5px; margin-top: 10px; }

@media (max-width: 700px) {
  #dr-table thead { display: none; }
  #dr-table, #dr-table tbody, #dr-table tr, #dr-table td { display: block; width: 100%; }
  #dr-table tr { border-bottom: 1px solid var(--border); padding: 9px 0; }
  #dr-table td { border: 0; padding: 1px 0; text-align: left; }
  #dr-table .num { text-align: left; }
  #dr-table td:first-child { font-size: 14px; }
  #dr-table-wrap { overflow-x: visible; }
}

/* ---------- drill-through affordances ----------
   What is interactive has to look interactive. A name that opens a record and a
   name that does not must not be the same shape. */
.ent-link {
  cursor: pointer;
  border-bottom: 1px dotted var(--muted-dim);
}
.ent-link:hover { color: var(--sage); border-bottom-color: var(--sage); }
.ent-row { cursor: pointer; }
.ent-row:hover { background: var(--panel-2); }
.ent-row:hover .nm { color: var(--sage); }
/* An invisible, generous hit area on the weekly line: 6px of target for a 1.6px
   stroke, because a tooltip you cannot land on is not a tooltip. */
.dchart-hit { fill: transparent; }
.dchart-hit:hover { fill: var(--sage); fill-opacity: 0.5; }
.dchart-bar:hover { fill: var(--sage); }

/* ---------- chart system ----------
   Recessive grid and axes; the marks carry the ink. Every rule here is shared,
   which is the whole point — twelve bespoke charts is why four of them were
   described as "poorly rendered". */
.ch { width: 100%; height: auto; display: block; }
.ch-title {
  font-size: 9.5px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--muted-dim); margin: 0 0 6px; font-weight: 400;
}
.ch-grid { stroke: var(--border); stroke-width: 1; }
.ch-axis { stroke: var(--muted-dim); stroke-width: 1; opacity: 0.6; }
.ch-mark { stroke: var(--gold-dim); stroke-width: 1; stroke-dasharray: 3 3; }
.ch-tick {
  fill: var(--muted-dim); font-size: 9px;
  font-family: "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums;
}
.ch-cap {
  fill: var(--muted-dim); font-size: 8px; letter-spacing: 0.12em;
  text-transform: uppercase; font-family: "SF Mono", Menlo, monospace;
}
/* Invisible until hovered, and generous: the hit target is bigger than the mark
   because a tooltip you cannot land on is not a tooltip. */
.ch-hit { fill: transparent; }
.ch-hit:hover { fill: var(--sage); fill-opacity: 0.45; }
.ch rect:hover { fill-opacity: 0.82; }
.ch-empty { color: var(--muted-dim); font-size: 12px; margin: 8px 0; }

/* Identity is never colour alone: the legend is always present for two or more
   series, and it carries the name beside the swatch. */
.ch-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; }
.ch-key { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.ch-key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.ch-note { font-size: 10.5px; color: var(--muted-dim); }

/* The comparison period as a thinner bar under the current one — a percentage
   alone makes you do the arithmetic to picture the move. */
.bar-track { position: relative; }
.bar-prev {
  position: absolute; left: 0; bottom: -3px; height: 2px;
  background: var(--muted-dim); opacity: 0.75; border-radius: 1px;
}

/* A real hover panel, not a native title=. The browser's own tooltip takes
   about a second to appear and only over the element it is attached to, which
   is why the comparison numbers were invisible in practice. */
.bar-tip {
  position: absolute; left: 0; bottom: calc(100% + 6px);
  z-index: 5; pointer-events: none;
  opacity: 0; transform: translateY(3px);
  transition: opacity .1s ease, transform .1s ease;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 5px 9px;
  font-size: 11.5px; color: var(--muted); white-space: nowrap;
  box-shadow: 0 6px 20px -8px rgba(0,0,0,0.9);
}
.bar-tip b { color: var(--text); font-variant-numeric: tabular-nums; }
.bar-row:hover .bar-tip { opacity: 1; transform: translateY(0); }
/* The row is the hit target, not the 6px track. */
.bar-row { position: relative; }

/* AGP: the baseline half of the chart is deliberately quieter than the
   programme half — same axis, different weight, so which is which needs no
   legend. */
.dchart-bar-pre { fill: var(--muted-dim); fill-opacity: 0.45; }
.dchart-bar-pre:hover { fill-opacity: 0.7; }
.dchart-boundary { stroke: var(--sage); stroke-width: 1; opacity: 0.8; }
.dchart-grid { stroke: var(--border); stroke-width: 1; }
.dchart-axis { stroke: var(--muted-dim); stroke-width: 1; opacity: 0.6; }
.dchart-cap {
  fill: var(--muted-dim); font-size: 7.5px; letter-spacing: 0.12em;
  text-transform: uppercase; font-family: "SF Mono", Menlo, monospace;
}

/* A placeholder that explains itself. An inert control reads as broken; one
   that says what it will do and what it is waiting on reads as deliberate. */
.soon-block { border-style: dashed; opacity: 0.9; }
.soon-btn { border-style: dashed; color: var(--muted-dim); }
.soon-btn:hover { color: var(--text); border-color: var(--muted-dim); }

/* ---------- Tracker ----------
   "Center align data and ensure the totals at the bottom fit into first view."
   Centring is a class. The totals are a sticky footer row: a total you have to
   scroll sixty rows to reach is a total nobody reads. */
#trk-table td.num, #trk-table th.num { text-align: center; }
#trk-table td.nm { text-align: left; }
#trk-table tfoot tr {
  position: sticky; bottom: 0; z-index: 3;
  background: var(--panel-2);
  box-shadow: 0 -1px 0 var(--border), 0 -8px 16px -12px rgba(0,0,0,0.9);
}
#trk-table tfoot td { font-weight: 600; color: var(--text); }
.trk-wrap { max-height: 62vh; overflow: auto; }

/* ---------- measure switch ---------- */
.ch-switch { display: flex; gap: 3px; margin-bottom: 10px; }
.ch-switch-btn {
  background: none; border: 1px solid var(--border); color: var(--muted-dim);
  font: inherit; font-size: 11.5px; padding: 4px 11px; cursor: pointer;
  border-radius: 4px;
}
.ch-switch-btn:hover { color: var(--text); border-color: var(--muted-dim); }
.ch-switch-btn.on {
  color: var(--text); border-color: var(--sage-dim);
  background: rgba(143,163,130,0.10);
}

/* Cohort cells carry their drop-off names in a hover panel for the same reason
   the bars do: a native title= arrives too late and only over the text glyph. */
.coh-wrap { overflow-x: auto; }
.cohort-table td.coh-cell { position: relative; cursor: default; }
.coh-tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px);
  transform: translate(-50%, 3px);
  z-index: 6; pointer-events: none; opacity: 0;
  transition: opacity .1s ease, transform .1s ease;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 6px 10px;
  font-family: Calibri, sans-serif; font-size: 11.5px; line-height: 1.45;
  color: var(--muted); text-align: left;
  width: max-content; max-width: 300px; white-space: normal;
  box-shadow: 0 6px 20px -8px rgba(0,0,0,0.9);
}
.coh-tip b { color: var(--text); }
.cohort-table td.coh-cell:hover .coh-tip { opacity: 1; transform: translate(-50%, 0); }

/* Placeholder actions answer back rather than doing nothing. */
.sub-actions { display: flex; gap: 8px; margin: 0 0 14px; }
.soon-note {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  max-width: 340px; padding: 14px 16px;
  background: var(--panel-2); border: 1px solid var(--gold);
  border-radius: 8px; box-shadow: 0 12px 34px -12px rgba(0,0,0,0.95);
}
.soon-note h4 { margin: 0 0 6px; font-size: 13px; color: var(--gold); }
.soon-note p { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--muted); }

/* An axis label that names a record is a link, and has to look like one. */
.ch-tick-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.ch-tick-link:hover { fill: var(--sage); }
.kam-title { font-size: 15px; color: var(--text); align-self: center; }

/* ---------- Charts speak the app's bar language ----------
   Callum: "I meant amend the existing bar charts not create new ones. Those new
   charts look completely different to rest of design." The module used to emit
   a vertical-bar SVG block, which is why. It now emits .bar-row rows on the
   same 190px / 1fr / 110px / 74px grid as every other bar in the app, with the
   axis and the hover it was built for kept. */
.ch-stack { display: flex; flex-direction: column; gap: 2px; height: 16px; background: transparent; }
.ch-stack-row { display: flex; gap: 2px; height: 100%; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.ch-stack .ch-seg { display: block; height: 100%; }
.ch-stack .ch-seg:first-child { border-radius: 3px 0 0 3px; }
.ch-stack .ch-seg:last-child { border-radius: 0 3px 3px 0; }
/* The comparison period, thinner and dimmer — the same relationship .bar-prev
   has to .bar-fill, so two periods read the same way on every chart. */
.ch-stack:has(.ch-stack-prev) { height: 20px; }
.ch-stack-prev { height: 6px; opacity: 0.55; }

.ch-scale { display: grid; grid-template-columns: 190px 1fr 110px 74px; gap: 10px; margin-top: 9px; }
.ch-scale-rule { position: relative; height: 15px; border-top: 1px solid var(--border); }
.ch-scale-tick { position: absolute; top: 0; transform: translateX(-50%); }
.ch-scale-tick i { display: block; width: 1px; height: 3px; background: var(--border); margin: 0 auto; }
.ch-scale-tick b {
  display: block; font-weight: normal; font-size: 10px; color: var(--muted-dim);
  font-family: "SF Mono", Menlo, monospace; white-space: nowrap; margin-top: 1px;
}
.ch-scale-cap { font-size: 10px; color: var(--muted-dim); text-transform: uppercase; letter-spacing: .5px; text-align: right; }
@media (max-width: 720px) {
  .ch-scale { grid-template-columns: 1fr; }
  .ch-scale-pad, .ch-scale-cap { display: none; }
}

/* Sparklines and bullet tracks get the same hover panel the bars have. The
   panel needs a positioned parent; both of these were bare SVG before. */
.spark-wrap { position: relative; display: inline-block; }
.spark-wrap:hover .bar-tip { opacity: 1; transform: translateY(0); }
.bullet .bl-track { position: relative; }
.bullet:hover .bar-tip { opacity: 1; transform: translateY(0); }
.bl-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The state tiles' hover panel, drawn in the svg so it has no native delay. */
.statemap .tile-tip { opacity: 0; pointer-events: none; transition: opacity .1s ease; }
.statemap .tile:hover .tile-tip { opacity: 1; }
.statemap .tile-tip-bg { fill: var(--panel-2); stroke: var(--border); stroke-width: 1; }
.statemap .tile-tip-t { font-family: Calibri, sans-serif; font-size: 11px; fill: var(--text); }
.statemap .tile-tip-t.dim { fill: var(--muted); }
/* The hovered tile paints above its neighbours, or the panel is clipped by them. */
.statemap .tile:hover { isolation: isolate; }

/* ---------- Today's three tiles ---------- */
.today-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 0 0 18px; }
.ttile { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 15px 17px; }
.ttile-lab { font-size: 10.5px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-dim); }
.ttile-fig { font-family: Cambria, Georgia, serif; font-size: 27px; font-weight: bold; line-height: 1.15; margin-top: 6px; color: var(--gold); }
.ttile-sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.ttile-foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 11.5px; }
.ttile-note { color: var(--muted-dim); font-size: 10.5px; }
.ttile-foot .spark-wrap { margin-left: auto; width: 90px; height: 22px; }
.ttile-foot .spark-wrap svg { width: 90px; height: 22px; display: block; }
/* A plan-centred bar: the fill is actual, the marker is target at 100%. */
.ttile-bar { position: relative; height: 8px; background: var(--panel-2); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.ttile-bar i { display: block; height: 100%; background: var(--sage); border-radius: 4px; }
.ttile-bar b { position: absolute; top: -2px; width: 2px; height: 12px; background: var(--gold); transform: translateX(-1px); }
/* Waiting on a source: legible, but visibly not a number. */
.ttile-off .ttile-fig { color: var(--muted-dim); }
.ttile-off { border-style: dashed; }

/* ---------- Needs you: one list, four sources ---------- */
.tpanel-wide { grid-column: 1 / -1; margin-bottom: 18px; }
.needs-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.needs-row { display: grid; grid-template-columns: 8px 1fr auto auto; gap: 10px; align-items: start; }
.needs-row .trow-right { white-space: nowrap; }
.needs-acts { display: flex; gap: 4px; opacity: 0; transition: opacity .1s ease; }
.needs-row:hover .needs-acts, .needs-acts:focus-within { opacity: 1; }
.nact {
  background: none; border: 1px solid var(--border); color: var(--muted);
  border-radius: 5px; width: 24px; height: 24px; cursor: pointer; font-size: 12px; line-height: 1;
}
.nact:hover { color: var(--text); border-color: var(--muted-dim); }
.nact:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
/* Touch and keyboard never get a hover, so the actions must not depend on one. */
@media (hover: none) { .needs-acts { opacity: 1; } }
@media (max-width: 620px) {
  .needs-row { grid-template-columns: 8px 1fr; }
  .needs-row .trow-main { grid-column: 2; grid-row: 1; }
  .needs-row .trow-right, .needs-row .needs-acts { grid-column: 2; opacity: 1; }
}

/* ---------- Ask Alma on the home page ----------
   Ported from _design/today-v3.html. The listening state is deliberately a
   different treatment from focus: the orb is the only indicator that the
   microphone is live, so 'focused' and 'listening' must not look alike. */
.ask {
  display: grid; grid-template-columns: 232px 1fr; gap: 26px; align-items: center;
  border: 1px solid var(--border); border-radius: 8px;
  background:
    radial-gradient(120% 150% at 12% 30%, rgba(143,163,130,0.10), transparent 58%),
    linear-gradient(180deg, rgba(201,162,93,0.045), transparent 62%),
    var(--panel);
  padding: 24px 26px; position: relative; overflow: hidden;
}
.ask::before {
  content: ""; position: absolute; left: 22px; right: 22px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(143,163,130,0.55), transparent);
}
.orb-stage { position: relative; width: 232px; height: 232px; }
.orb-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.ask-body { min-width: 0; }
.ask-eyebrow { font-size: 9.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--sage); margin-bottom: 8px; }
.ask-body h1 { font-family: Cambria, Georgia, serif; font-size: 25px; font-weight: 600; margin: 0 0 6px; text-wrap: balance; }
.ask-say { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0 0 16px; max-width: 56ch; }
.ask-say b { color: var(--text); font-weight: 600; }

.ask-field {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--panel-2);
  border-radius: 6px; padding: 7px 8px 7px 12px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.ask-field:focus-within, .ask-field.listening {
  border-color: var(--sage-dim);
  box-shadow: 0 0 0 1px rgba(143,163,130,0.28), 0 0 18px -6px rgba(143,163,130,0.5);
}
.ask-field input {
  flex: 1 1 auto; background: none; border: 0; outline: none;
  color: var(--text); font: inherit; font-size: 13.5px; min-width: 0;
}
.ask-field input::placeholder { color: var(--muted-dim); }
.ask-field.listening input { display: none; }

/* Voice: the listening state has to be unmistakable, because the difference
   between "armed" and "not armed" is the whole question a microphone raises. */
.wavebox { flex: 1 1 auto; display: none; align-items: center; gap: 9px; min-width: 0; }
.ask-field.listening .wavebox { display: flex; }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 18px; }
.wave i {
  display: block; width: 2px; background: var(--sage); border-radius: 1px;
  box-shadow: 0 0 6px rgba(143,163,130,0.7);
  animation: bounce 1s ease-in-out infinite;
}
@keyframes bounce { 0%,100% { height: 3px; } 50% { height: 17px; } }
.wave-lab { font-size: 12px; color: var(--sage); white-space: nowrap; }
.wave-lab span { color: var(--muted-dim); }

.icon-btn {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 5px;
  border: 1px solid var(--border); background: none; color: var(--muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted-dim); }
.icon-btn.on {
  color: var(--sage); border-color: var(--sage-dim);
  background: rgba(143,163,130,0.12);
  box-shadow: 0 0 14px -5px rgba(143,163,130,0.9);
}
.icon-btn svg { width: 15px; height: 15px; }
.ask-send {
  flex: 0 0 auto; border: 1px solid var(--sage-dim); background: rgba(143,163,130,0.10);
  color: var(--sage); font: inherit; font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 6px 12px; border-radius: 5px; cursor: pointer;
}
.ask-send:hover { background: rgba(143,163,130,0.2); color: var(--text); }
.ask-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.ask-chip {
  border: 1px solid var(--border); background: none; color: var(--muted);
  font: inherit; font-size: 11.5px; padding: 4px 10px; border-radius: 20px; cursor: pointer;
}
.ask-chip:hover { color: var(--text); border-color: var(--muted-dim); }

/* ---------- pulse tiles ---------- */
/* The inline thread under the orb — one engine, two surfaces. */
.ask-thread { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.ask-msg { font-size: 13px; line-height: 1.55; padding: 9px 12px; border-radius: 7px; max-width: 62ch; }
.ask-msg-you { background: var(--panel-2); border: 1px solid var(--border); color: var(--text); align-self: flex-end; }
.ask-msg-alma { background: rgba(143,163,130,0.08); border: 1px solid var(--sage-dim); color: var(--muted); }
.ask-msg-alma[data-pending] { color: var(--muted-dim); font-style: italic; }

@media (max-width: 820px) {
  .ask { grid-template-columns: 1fr; gap: 16px; }
  .orb-stage { width: 170px; height: 170px; margin: 0 auto; }
}
@media (prefers-reduced-motion: reduce) { .wave i { animation: none; height: 9px; } }

/* ---------- Charts must not scale their own type ----------
   An SVG with width:100% and a 640-unit viewBox in a 1500px panel renders at
   2.34x, and every 9px label with it — which is why the concentration chart's
   axis came out in 21px type. Capping the height bounds the scale in both
   directions: a wide panel is limited by height and letterboxes, a narrow one
   by width. Without this the same chart is unreadable at one size and absurd
   at the other. */
.ch { max-height: 300px; margin: 0 auto; }
.mini-grid .ch { max-height: 190px; }

/* [hidden] must beat display:grid, or toggling it in JS silently does nothing.
   The same lesson as .view-panel above — which carries a comment saying exactly
   this, written after it happened the first time. It was not generalised, so
   the four retired Today panels stayed on screen after being hidden. */
.today-grid[hidden], .today-tiles[hidden] { display: none !important; }
/* A narrow panel scrolls the chart rather than shrinking its type: at 320px a
   640-unit viewBox renders every 9px label at 5px, which is not a small label,
   it is an absent one. Measured, not guessed — see test/render.mjs. */
.ch-wrap { overflow-x: auto; }
.ch { min-width: 520px; }

/* ---------- AGP creator ---------- */
.agp-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 14px; align-items: flex-end; }
.agp-lab { display: block; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-dim); margin-bottom: 4px; }
.agp-in { background: var(--panel-2); border: 1px solid var(--border); border-radius: 5px; color: var(--text);
  padding: 8px 10px; font-family: inherit; font-size: 13px; }
.agp-in.agp-wide { min-width: 300px; }
.agp-in.agp-static { color: var(--muted); }
.agp-tog.on { border-color: var(--sage-dim); color: var(--sage); }

.agp-bases { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; margin: 12px 0; }
.agp-base { background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 11px 13px;
  cursor: pointer; position: relative; }
.agp-base.on { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(201,162,93,.28); }
.agp-base.dim { opacity: .6; cursor: default; }
.agp-base-lab { font-size: 9px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted-dim); }
.agp-base-fig { font-family: Cambria, Georgia, serif; font-size: 21px; margin-top: 5px; font-variant-numeric: tabular-nums; }
.agp-base.on .agp-base-fig { color: var(--gold); }
.agp-base-note { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.agp-base-tgt { font-size: 11px; color: var(--sage); margin-top: 6px; font-family: "SF Mono", Menlo, monospace; }
.agp-base-tgt.dimtext { color: var(--muted-dim); }
.agp-dflt { position: absolute; top: -8px; left: 11px; background: var(--gold); color: #141414; font-size: 8.5px;
  letter-spacing: .1em; text-transform: uppercase; padding: 2px 7px; border-radius: 999px; font-weight: 600; }

.agp-part { font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted-dim); }
.ch-stack.part { outline: 1px dashed var(--muted-dim); outline-offset: -1px; }
.ch-stack.part i { opacity: .62; }
.ch-stack.agp-target { outline: 1px solid var(--sage-dim); outline-offset: -1px; }

.agp-table td .agp-cell { width: 78px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 4px 6px; text-align: right; font-family: "SF Mono", Menlo, monospace; font-size: 12px; }
.agp-table td .agp-cell.edited { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 0 1px rgba(201,162,93,.2); }
.agp-table td.off { color: var(--gold); }
.agp-table tr.agp-dead { opacity: .55; }
.agp-table td.dim { color: var(--muted-dim); }

.agp-h4 { margin: 0 0 7px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted-dim); font-weight: 400; }
.agp-diff { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 12px 14px;
  font-family: "SF Mono", Menlo, monospace; font-size: 11.5px; }
.agp-diff dl { display: grid; grid-template-columns: 148px 1fr; gap: 4px 12px; margin: 0; }
.agp-diff dt { color: var(--muted-dim); }
.agp-diff dd { margin: 0; }
.agp-diff dd.new { color: var(--sage); }
.agp-diff dd.chg { color: var(--gold); }
.agp-diff .was { color: var(--muted-dim); text-decoration: line-through; margin-right: 6px; }

.agp-subs { list-style: none; padding: 0; margin: 11px 0 0; font-size: 12.5px; }
.agp-subs li { display: flex; align-items: center; gap: 9px; padding: 6px 0; border-bottom: 1px solid rgba(47,47,44,.5); }
.agp-subs li:last-child { border-bottom: none; }
.agp-box { width: 13px; height: 13px; border: 1px solid var(--muted-dim); border-radius: 3px; flex: none; }
.agp-box.req { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,93,.18); }

.agp-actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.agp-why { font-size: 11.5px; color: var(--muted-dim); max-width: 52ch; margin: 0; }

.callout-flag, .callout-warn { border-radius: 6px; padding: 11px 13px; margin: 12px 0; font-size: 12px; color: var(--muted); }
.callout-flag { border: 1px solid var(--flag-dim); background: rgba(193,102,107,.07); }
.callout-flag b { color: var(--flag); }
.callout-warn { border: 1px solid var(--gold-dim); background: rgba(201,162,93,.07); }
.callout-warn b { color: var(--gold); }

/* ---- AGP create result ----
 * Three states with three colours, and the dry-run one is deliberately the
 * WARNING colour rather than the success colour. "Nothing was written" printed
 * in green is how somebody closes the tab believing a programme exists.
 */
.agp-result { margin-top: 10px; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel); font-size: 13px; line-height: 1.5; }
.agp-result.good { border-color: #8fa382; }
.agp-result.warn { border-color: #c9a25d; }
.agp-result.bad  { border-color: #c1666b; }
.agp-result a { color: var(--text); }
/* A button that does nothing must not look like one that does. */
.dead-btn { opacity: .62; }
.dead-btn .pill.risk { margin-left: 6px; }

/* A row action that is mid-write. The row must not move until the event comes
 * back, so the button says it is working rather than the list pretending. */
.nact.busy { opacity: .5; }
.nact:disabled { cursor: progress; }

/* ---- Sortable column headings ----
 * The cursor and the hover are the only affordance a table heading gets, so
 * both are needed — a heading that sorts and looks inert gets clicked by
 * accident and never on purpose.
 */
#deals-table th.sortable { cursor: pointer; user-select: none; }
#deals-table th.sortable:hover { color: var(--text); }
#deals-table th.sorted { color: var(--text); }

/* ---- Hover: the products behind a month ----
 * A rule rather than a blank line, because the group split and the product
 * split are two different readings of the same bar and running them together
 * makes both harder to scan.
 */
.bar-tip .tip-rule { display: block; height: 1px; margin: 6px 0; background: var(--border); }
.bar-tip .tip-more { color: var(--muted); }
/* The tooltip now carries up to eight lines, so it needs room and must not
 * clip. Widened rather than scrolled: a scrollbar inside a hover is unusable. */
.bar-tip { max-width: 260px; white-space: normal; line-height: 1.45; }


/* ---- Hover on the SVG deal charts ----
 * The sizing lives on the WRAPPER, so the spots and the svg share one box. The
 * spots are positioned in percentages of that box, which only lines up because
 * the svg's aspect ratio is exact — see the note on .dchart.
 */
.dchart-hover { position: relative; max-width: 780px; min-width: 520px; }
.dchart-hover .dchart { max-width: none; min-width: 0; width: 100%; }
.dchart-spot { position: absolute; top: 0; bottom: 0; display: block; cursor: default; }
/* A hit area wider than the bar, because a 6px-wide bar is not a target anyone
 * can hit — the spot spans the whole month, gaps included. */
.dchart-spot .bar-tip {
  position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, 4px);
  opacity: 0; pointer-events: none; transition: opacity .12s ease, transform .12s ease;
  z-index: 5;
}
.dchart-spot:hover .bar-tip { opacity: 1; transform: translate(-50%, -2px); }
/* The band lights up so it is obvious which month is being read. */
.dchart-spot:hover { background: rgba(143,163,130,0.10); }
@media (prefers-reduced-motion: reduce) {
  .dchart-spot .bar-tip { transition: none; }
}

/* ---------- Reconciliation ----------
   A queue, not a report. Severity is a pill as well as a colour, so the row
   that needs attention reads at a glance and still reads in monochrome. */
.recon-basis{color:var(--muted);font-size:12.5px;line-height:1.55;margin:0 0 10px;max-width:92ch}
.recon-note{font-size:11.5px;color:var(--muted-dim);margin:0 0 8px}
.recon-h2{font-size:14px;margin:26px 0 6px;font-weight:600}
.recon-sources{display:flex;flex-wrap:wrap;gap:8px;margin:0 0 20px}
.recon-src{font-size:10px;letter-spacing:.1em;text-transform:uppercase;border:1px solid var(--border);
  padding:3px 8px;color:var(--muted-dim)}
.recon-src.on{color:var(--sage);border-color:var(--sage-dim)}
.recon-src.off{color:var(--flag);border-color:var(--flag-dim)}
.recon-legs{display:grid;grid-template-columns:repeat(auto-fit,minmax(330px,1fr));gap:14px;margin-bottom:8px}
.recon-leg{border:1px solid var(--border);background:var(--panel);padding:16px 18px 18px}
.recon-leg h3{margin:6px 0 4px;font-size:14px;font-weight:600}
.recon-leg .leg-no{font-size:10px;letter-spacing:.12em;text-transform:uppercase;color:var(--gold);
  margin-right:8px}
.recon-leg .leg-pop{font-size:11.5px;color:var(--muted-dim);line-height:1.5;margin:6px 0 12px}
.recon-rows{width:100%;border-collapse:collapse;font-size:13px}
.recon-rows td{padding:5px 0;border-bottom:1px solid var(--border);vertical-align:top}
.recon-rows td:last-child{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap;
  padding-left:10px}
.recon-rows tr:last-child td{border-bottom:0}
.recon-rows td.k{color:var(--muted)}
.recon-var{font-weight:600}
.sev{display:inline-block;font-size:9.5px;letter-spacing:.1em;text-transform:uppercase;
  padding:2px 6px 1px;border:1px solid var(--border);color:var(--muted);white-space:nowrap}
.sev.critical{color:var(--flag);border-color:var(--flag-dim)}
.sev.serious{color:var(--gold);border-color:var(--gold-dim)}
.sev.watch{color:var(--muted)}
.sev.ok{color:var(--sage);border-color:var(--sage-dim)}
.sev.unknown{color:var(--muted-dim);border-style:dotted}
.recon-queue{display:flex;flex-direction:column;gap:1px;background:var(--border);
  border:1px solid var(--border)}
.recon-exc{background:var(--panel);padding:12px 16px;display:grid;
  grid-template-columns:92px 1fr auto;gap:14px;align-items:baseline}
.recon-exc .exc-sub{font-weight:600;font-size:13px;margin-bottom:2px}
.recon-exc .exc-msg{font-size:13px;line-height:1.5;color:var(--muted)}
.recon-exc .exc-basis{font-size:11px;color:var(--muted-dim);margin-top:4px}
.recon-exc .exc-val{font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}
/* An assumption must never look like a record. */
.recon-assumed,.recon-exc.assumed .exc-val{color:var(--muted);font-style:italic;
  border-bottom:1px dotted var(--muted-dim);cursor:help}
.recon-blocked{display:flex;flex-direction:column;gap:10px;font-size:12.5px;color:var(--muted)}
.recon-blocked div{border-left:2px solid var(--border);padding-left:12px;max-width:92ch;line-height:1.55}
@media (max-width:640px){.recon-exc{grid-template-columns:1fr;gap:6px}}

/* ---- The action bar, the issue queue, and the draft ------------------------
   The bar sticks because the exception list is long and a person who has
   scrolled to the sixth row should not have to scroll back to act on it. */
.recon-actions{position:sticky;top:0;z-index:5;background:var(--panel-2);
  border:1px solid var(--border);border-bottom:0;padding:10px 16px 12px;
  display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px}
.recon-actions[hidden]{display:none !important}
.ra-count{font-size:12px;color:var(--gold);letter-spacing:.06em;white-space:nowrap}
.ra-btns{display:flex;flex-wrap:wrap;gap:8px}
.ra-btns .ra-primary{border-color:var(--sage-dim);color:var(--sage)}
.ra-btns button:disabled{opacity:.45;cursor:not-allowed}
.ra-basis{flex-basis:100%;margin:0;font-size:11.5px;line-height:1.55;color:var(--muted-dim);max-width:92ch}
.ra-field{display:block;font-size:11.5px;color:var(--muted);margin:14px 0 0}
.ra-field .sel,.ra-field textarea{display:block;width:100%;margin-top:5px}

/* A checkbox column, added ahead of the severity pill. The row stays a grid so
   the message column keeps its width. */
.recon-exc{grid-template-columns:22px 92px 1fr auto}
.recon-exc .exc-pick{align-self:center}
.recon-exc.picked{background:var(--panel-2)}
/* An exception with nobody to send it to says so rather than offering a
   checkbox that leads to a refusal. */
.recon-exc .exc-noone{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted-dim)}
.exc-state{font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);
  border:1px solid var(--border);padding:1px 6px;margin-left:8px;white-space:nowrap}
.exc-state.corrected{color:var(--sage);border-color:var(--sage-dim)}
.exc-state.open{color:var(--flag);border-color:var(--flag-dim)}

.recon-issues{display:flex;flex-direction:column;gap:1px;background:var(--border);
  border:1px solid var(--border)}
.recon-issue{background:var(--panel);padding:12px 16px;display:grid;
  grid-template-columns:1fr auto;gap:4px 14px;align-items:baseline}
.recon-issue .ri-sub{font-weight:600;font-size:13px}
.recon-issue .ri-meta{font-size:11.5px;color:var(--muted-dim);grid-column:1/-1;line-height:1.5}
.recon-issue .ri-val{font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}
.recon-issue.breached{border-left:2px solid var(--flag)}

.bls-body{width:100%;background:var(--bg);color:var(--text);border:1px solid var(--border);
  font:12.5px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;padding:12px;resize:vertical}
.bls-draft .ra-btns{margin-top:14px}

@media (max-width:640px){.recon-exc{grid-template-columns:22px 1fr;gap:6px}}
/* ---- §11 exception registers -----------------------------------------------
   A register is a named list of the transactions that failed a match, not a
   percentage. The severity stripe is on the left edge because the first
   question is always "does this block the close". */
.recon-registers{display:flex;flex-direction:column;gap:12px;margin-bottom:6px}
.reg{border:1px solid var(--border);background:var(--panel);border-left:3px solid var(--border)}
.reg.S1{border-left-color:var(--flag)}
.reg.S2{border-left-color:var(--gold)}
.reg.S3{border-left-color:var(--muted-dim)}
.reg.empty{opacity:.55}
.reghead{display:flex;align-items:center;gap:11px;flex-wrap:wrap;padding:11px 15px;
  background:var(--panel-2);border-bottom:1px solid var(--border);cursor:pointer}
.reg.empty .reghead{border-bottom:0}
.reghead .code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:12px;
  color:var(--gold);letter-spacing:.04em;min-width:34px}
.reghead h3{flex:1;min-width:200px;margin:0;font-size:13.5px;font-weight:600}
.reghead .cnt{font-size:12px;font-variant-numeric:tabular-nums;color:var(--text)}
.reghead .of{font-size:11px;color:var(--muted-dim)}
.reghead .sla{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted-dim)}
.reghead .caret{color:var(--muted-dim);font-size:11px;width:12px;text-align:center}
.sev-tag{display:inline-block;font-size:9.5px;letter-spacing:.1em;font-weight:600;
  padding:2px 6px 1px;border:1px solid var(--border);white-space:nowrap}
.sev-tag.S1{color:var(--flag);border-color:var(--flag-dim);background:rgba(193,102,107,.09)}
.sev-tag.S2{color:var(--gold);border-color:var(--gold-dim);background:rgba(201,162,93,.08)}
.sev-tag.S3{color:var(--muted)}
.sev-tag.S4{color:var(--muted-dim);border-style:dotted}
.regbody{padding:12px 15px 14px}
.regbasis{font-size:11.5px;color:var(--muted-dim);line-height:1.55;margin:0 0 10px;max-width:100ch}
.regnote{font-size:11.5px;color:var(--muted);line-height:1.55;margin:10px 0 0;max-width:100ch;
  border-left:2px solid var(--border);padding-left:11px}
.regtable{width:100%;border-collapse:collapse;font-size:12.5px}
.regtable th{text-align:left;font-size:10px;letter-spacing:.09em;text-transform:uppercase;
  color:var(--muted-dim);font-weight:600;padding:0 10px 6px 0;border-bottom:1px solid var(--border);
  white-space:nowrap}
.regtable td{padding:6px 10px 6px 0;border-bottom:1px solid var(--border);vertical-align:top}
.regtable tr:last-child td{border-bottom:0}
.regtable .n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.regtable th.n{text-align:right}
.regtable .mono{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px}
.regtable .miss{color:var(--flag);font-style:italic}
.regcap{font-size:11px;color:var(--gold);margin:9px 0 0}

/* ---- the headline row and the legs table -----------------------------------
   Four boxes in a ragged grid became a tile row plus one table. The tiles are
   what a person acts on; the table is what they compare. */
/* Four across, always, until there is genuinely no room. auto-fit with a 210px
   floor wrapped to 3 + 1 at 1440px and left a quarter of the row empty. */
.recon-tiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:0 0 16px}
@media (max-width:1000px){.recon-tiles{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media (max-width:560px){.recon-tiles{grid-template-columns:1fr}}
.rtile{border:1px solid var(--border);border-top:2px solid var(--border);
  background:var(--panel);padding:13px 15px 14px}
.rtile.bad{border-top-color:var(--flag)}
.rtile.warn{border-top-color:var(--gold)}
.rtile.good{border-top-color:var(--sage)}
.rtile .lab{font-size:10px;letter-spacing:.1em;text-transform:uppercase;color:var(--muted-dim)}
.rtile .val{font-family:Cambria,Georgia,serif;font-size:26px;line-height:1.15;margin:7px 0 3px;
  font-variant-numeric:tabular-nums}
.rtile.bad .val{color:var(--flag)}
.rtile.warn .val{color:var(--gold)}
.rtile.good .val{color:var(--sage)}
.rtile .foot{font-size:11.5px;color:var(--muted);line-height:1.45}

.legs-table{width:100%;border-collapse:collapse;font-size:13px;
  border:1px solid var(--border);background:var(--panel)}
.legs-table th{text-align:left;font-size:10px;letter-spacing:.09em;text-transform:uppercase;
  color:var(--muted-dim);font-weight:600;padding:9px 12px;border-bottom:1px solid var(--border);
  white-space:nowrap;background:var(--panel-2)}
.legs-table th.n{text-align:right}
.legs-table td{padding:9px 12px;border-bottom:1px solid var(--border);vertical-align:top}
.legs-table tr.legrow{cursor:pointer}
.legs-table tr.legrow:hover td{background:var(--panel-2)}
.legs-table tr.legrow.on td{background:var(--panel-2)}
.legs-table td.n{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.legs-table .legno{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--gold);
  font-size:12px}
.legs-table .legnm{font-weight:600}
.legs-table .legpop{font-size:11.5px;color:var(--muted-dim);line-height:1.5;max-width:52ch}
.legs-table .caret{color:var(--muted-dim);font-size:11px}
.legdetail td{background:var(--bg);padding:0}
.legdetail .inner{padding:14px 16px 16px;border-left:2px solid var(--gold-dim);margin:0 12px 12px}
/* The leg cards still render, inside their own row's detail. The card's
   chrome comes off there — the row above already carries the name and the
   population, and repeating them is how a detail view starts looking like a
   second screen. */
.legdetail .recon-leg{border:0;background:transparent;padding:0}
.legdetail .recon-leg h3,.legdetail .recon-leg > .leg-no,.legdetail .recon-leg > .sev{display:none}
.legdetail .recon-leg > .leg-pop:first-of-type{display:none}
@media (max-width:760px){.legs-table .legpop{display:none}}

/* ---- §12 gap register ------------------------------------------------------
   Ordered by state, not severity: "what have we not started" is the question
   it exists to answer, and severity-first puts the closed ones on top. */
.gaps-table{width:100%;border-collapse:collapse;font-size:12.5px;
  border:1px solid var(--border);background:var(--panel)}
.gaps-table th{text-align:left;font-size:10px;letter-spacing:.09em;text-transform:uppercase;
  color:var(--muted-dim);font-weight:600;padding:9px 12px;border-bottom:1px solid var(--border);
  white-space:nowrap;background:var(--panel-2)}
.gaps-table td{padding:9px 12px;border-bottom:1px solid var(--border);vertical-align:top}
.gaps-table tr:last-child td{border-bottom:0}
.gaps-table .gid{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11.5px;
  color:var(--gold);white-space:nowrap}
.gaps-table .gname{font-weight:600;line-height:1.45}
.gaps-table .gsub{font-size:11.5px;color:var(--muted-dim);line-height:1.5;margin-top:3px;max-width:78ch}
.gaps-table tr.open td{background:rgba(193,102,107,.04)}
.gstate{font-size:9.5px;letter-spacing:.1em;text-transform:uppercase;padding:2px 6px 1px;
  border:1px solid var(--border);white-space:nowrap}
.gstate.open{color:var(--flag);border-color:var(--flag-dim)}
.gstate.detected{color:var(--gold);border-color:var(--gold-dim)}
.gstate.closed{color:var(--sage);border-color:var(--sage-dim)}
.gbecause{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:10.5px;
  color:var(--muted);white-space:nowrap}



