/* VAMP Tracker — dark + mint house style (shared with Refunds Console).
   One radius scale (6px controls / 8px cards), one spacing scale
   (4·8·12·16·20·24), mint reserved for active + success states. */
:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1b232d;
  --panel-3: #212b38;
  --border: #263040;
  --border-soft: #1f2733;
  --text: #dbe4ee;
  --text-dim: #aebbca;
  --muted: #8794a6;
  --mint: #34d399;
  --mint-dim: #10b981;
  --dgtl: #60a5fa;
  --violet: #a78bfa;
  --err: #f87171;
  --warn: #facc15;
  --orange: #fb923c;
  /* body links stay quiet — mint means active / success, not "link" */
  --link: #93b8d8;

  --r-sm: 6px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-pill: 999px;

  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;

  --topbar-h: 52px;
  --maxw: 1280px;
  --focus: 0 0 0 3px rgba(52, 211, 153, .22);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible {
  outline: 2px solid var(--mint); outline-offset: 2px; border-radius: var(--r-sm);
}
main { max-width: var(--maxw); margin: 0 auto; padding: var(--s5) var(--s5) 64px; }
::selection { background: rgba(52, 211, 153, .28); }
.muted { color: var(--muted); }
.mint { color: var(--mint); }
.warn-c { color: var(--warn); }
.v-over { color: var(--orange); }
.v-bad { color: var(--err); }
.count { font-size: 12px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* slim loading bar */
.loadbar {
  position: fixed; top: 0; left: 0; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--mint-dim), var(--mint));
  z-index: 100; opacity: 0; transition: width .25s ease, opacity .3s;
  pointer-events: none;
}
.loadbar.active { opacity: 1; }

.tbl-wrap, .chart-scroll { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.tbl-wrap::-webkit-scrollbar, .chart-scroll::-webkit-scrollbar { height: 9px; width: 9px; }
.tbl-wrap::-webkit-scrollbar-thumb, .chart-scroll::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: var(--r-sm);
}
.tbl-wrap::-webkit-scrollbar-thumb:hover, .chart-scroll::-webkit-scrollbar-thumb:hover {
  background: #33415a;
}
.tbl-wrap::-webkit-scrollbar-track, .chart-scroll::-webkit-scrollbar-track { background: transparent; }

/* ── topbar ─────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); min-height: var(--topbar-h);
  padding: var(--s2) var(--s5);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky; top: 0; z-index: 40;
}
.brand {
  font-size: 16px; font-weight: 700; color: var(--text);
  letter-spacing: .2px; white-space: nowrap;
}
.brand span { color: var(--mint); }
.brand:hover { text-decoration: none; }
.topbar-right {
  display: flex; align-items: center; gap: var(--s2);
  min-width: 0; flex-wrap: nowrap;
}

/* compact single-line sync pill */
.syncpill {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; min-width: 0;
  padding: 5px 11px; border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  background: var(--panel-2); color: var(--muted); font-size: 12px;
  white-space: nowrap; overflow: hidden;
}
.syncpill b { color: var(--text-dim); font-weight: 600; }
.syncpill b.mint { color: var(--mint); }
.syncpill .dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--mint-dim);
}
.syncpill.err { border-color: rgba(248, 113, 113, .45); background: rgba(248, 113, 113, .08); color: var(--err); }
.syncpill.err b { color: var(--err); }
.syncpill.err .dot { background: var(--err); }
.syncpill.partial { border-color: rgba(250, 204, 21, .4); color: var(--warn); }
.syncpill.partial .dot { background: var(--warn); }
.syncpill .scanline { overflow: hidden; text-overflow: ellipsis; }
.syncpill .syncnext { color: var(--muted); opacity: .75; }
/* the running line replaces the resting line, same pill footprint */
.syncpill #syncCountdown { display: none; }
.syncpill.running { border-color: rgba(52, 211, 153, .4); }
.syncpill.running #syncLine, .syncpill.running .syncnext { display: none; }
.syncpill.running #syncCountdown { display: inline; color: var(--mint); }
.syncpill.running .dot { animation: pulse 1.4s infinite; }
#syncCountdown { font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { opacity: .35; } }

/* ── cards + sections ───────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--r-lg); padding: var(--s4) var(--s5); margin-top: var(--s4);
}
.card.sub {
  background: transparent; border-color: var(--border-soft);
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
.sec-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3);
}
.sec-head h2 { line-height: 1.3; }
.card.sub .sec-head h2 { font-size: 14px; color: var(--text-dim); }
.sec-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

/* ── buttons / inputs ───────────────────────────────────────────── */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text-dim);
  padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px;
  font-family: inherit; white-space: nowrap;
  transition: border-color .15s, background-color .15s, color .15s;
}
.btn:hover { border-color: #35455c; background: var(--panel-3); color: var(--text); text-decoration: none; }
.btn.primary {
  background: var(--mint-dim); border-color: var(--mint-dim); color: #06251a; font-weight: 600;
}
.btn.primary:hover { background: var(--mint); border-color: var(--mint); color: #06251a; }
.btn.ghost { background: transparent; border-color: var(--border-soft); color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.ghost.navactive { border-color: rgba(52, 211, 153, .45); color: var(--mint); background: rgba(52, 211, 153, .08); }
#syncBtn:disabled { color: var(--mint); cursor: default; border-color: var(--border-soft); }
#syncBtn:disabled { animation: pulse 1.4s infinite; }

input[type="password"], input[type="search"], input[type="email"], input[type="text"] {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 7px 11px; font-size: 13px;
  font-family: inherit; color-scheme: dark;
  transition: border-color .15s, box-shadow .15s;
}
input[type="password"]:focus, input[type="search"]:focus,
input[type="email"]:focus, input[type="text"]:focus {
  outline: none; border-color: var(--mint-dim); box-shadow: var(--focus);
}
select.sel {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 6px 28px 6px 11px; font-size: 13px;
  font-family: inherit; height: 30px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238794a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  color-scheme: dark; transition: border-color .15s;
}
select.sel:hover { border-color: #35455c; }
select.sel:focus { outline: none; border-color: var(--mint-dim); box-shadow: var(--focus); }
select.sel:disabled { color: var(--muted); cursor: default; }
input::placeholder { color: var(--muted); }

/* ── login ──────────────────────────────────────────────────────── */
.login-wrap { display: flex; justify-content: center; padding-top: 14vh; }
.login-card {
  width: 320px; max-width: 100%; margin-top: 0;
  display: flex; flex-direction: column; gap: var(--s3);
  padding: var(--s6);
}
.login-card h1 { font-size: 20px; text-align: center; letter-spacing: .2px; }
.login-card h1 span { color: var(--mint); }
.login-card .pw {
  width: 100%; padding: 10px 12px; font-size: 14px; text-align: center; letter-spacing: 2px;
}
.login-card .pw::placeholder { letter-spacing: normal; }
/* the wide letter-spacing is a password affordance — not for the email */
.login-card input[type="email"].pw { letter-spacing: normal; }
.login-card .btn.primary { width: 100%; padding: 10px; font-size: 14px; }
.login-card .error {
  margin: 0; padding: 7px 11px; font-size: 12px;
  color: var(--err); background: rgba(248, 113, 113, .08);
  border: 1px solid rgba(248, 113, 113, .3); border-radius: var(--r-sm);
}

/* ── control strip (one toolbar, not several chip groups) ───────── */
.toolbar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
}
.toolbar .spacer { margin-left: auto; }
.tb-range {
  margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap;
}
.tb-range b { color: var(--text-dim); font-weight: 600; }

/* month navigator: ‹ [dropdown] › */
.monthnav { display: flex; align-items: center; gap: var(--s1); }
.mnav {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--panel-2); color: var(--text-dim);
  font-size: 16px; line-height: 1; text-decoration: none;
  transition: border-color .15s, color .15s, background-color .15s;
}
.mnav:hover { border-color: #35455c; background: var(--panel-3); color: var(--text); text-decoration: none; }
.mnav.off { color: #2b3646; cursor: default; }
.month-select {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--r-sm); padding: 6px 28px 6px 11px; font-size: 13px; font-weight: 600;
  font-family: inherit; height: 30px;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238794a6' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  color-scheme: dark; transition: border-color .15s;
}
.month-select:hover { border-color: #35455c; }
.month-select:focus { outline: none; border-color: var(--mint-dim); box-shadow: var(--focus); }

/* segmented control — business line + chart mode */
.seg {
  display: inline-flex; gap: 2px; padding: 2px; height: 30px;
  border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--panel-2);
}
.seg-btn {
  display: inline-flex; align-items: center; padding: 0 11px; border-radius: 4px;
  font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: color .15s, background-color .15s;
}
.seg-btn:hover { text-decoration: none; color: var(--text); background: rgba(255, 255, 255, .03); }
.seg-btn.active { background: var(--panel-3); color: var(--text); }
.seg-btn.cat-core.active    { background: rgba(52, 211, 153, .16); color: var(--mint); }
.seg-btn.cat-digital.active { background: rgba(96, 165, 250, .16); color: var(--dgtl); }
.seg-btn.cat-growth.active  { background: rgba(167, 139, 250, .16); color: var(--violet); }
.seg-btn.mode.active        { background: rgba(52, 211, 153, .14); color: var(--mint); }

/* RDR toggle — reads as one state word, detail lives in the title */
.toggle {
  display: inline-flex; align-items: center; gap: 7px; height: 30px;
  padding: 0 11px; border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: color .15s, border-color .15s, background-color .15s;
}
.toggle:hover { text-decoration: none; color: var(--text); border-color: #35455c; }
.toggle .knob {
  width: 22px; height: 12px; border-radius: var(--r-pill); flex: none;
  background: #2b3646; position: relative; transition: background-color .18s;
}
.toggle .knob::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted);
  transition: transform .18s, background-color .18s;
}
.toggle.active { color: var(--mint); border-color: rgba(52, 211, 153, .4); background: rgba(52, 211, 153, .08); }
.toggle.active .knob { background: rgba(52, 211, 153, .3); }
.toggle.active .knob::after { transform: translateX(10px); background: var(--mint); }

/* ── new-account banner ─────────────────────────────────────────── */
.card.banner {
  border-color: rgba(250, 204, 21, .35); background: rgba(250, 204, 21, .04);
  padding: var(--s3) var(--s4);
}
.banner-head { margin: 0 0 var(--s1); font-size: 13px; font-weight: 600; color: var(--warn); }
.banner-line { margin: 0; font-size: 13px; color: var(--text-dim); }
.banner-line b { color: var(--text); font-weight: 600; }

/* ── KPI area ───────────────────────────────────────────────────── */
.kpi-card {
  display: grid; grid-template-columns: minmax(190px, 250px) 1fr;
  gap: var(--s5); align-items: center;
}
.kpi-primary {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3) var(--s4); min-width: 0;
  background: rgba(255, 255, 255, .022);
  border: 1px solid var(--border-soft); border-radius: var(--r-sm);
}
.kpi-primary .kpi-label { font-size: 11px; color: var(--text-dim); }
.kpi-primary-row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.kpi-primary-value { font-size: 30px; font-weight: 650; line-height: 1.05; white-space: nowrap; }
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s4) var(--s5);
}
.kpi { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi[title] { cursor: help; }
.kpi-value { font-size: 22px; font-weight: 600; line-height: 1.15; white-space: nowrap; }
.kpi-value.kpi-zero { color: var(--muted); }
.kpi-label {
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.kpi-sub { font-size: 11px; color: var(--muted); line-height: 1.45; }
.kpi-sub b { color: var(--text-dim); font-weight: 600; }

/* ── MID detail hero ────────────────────────────────────────────── */
.mid-hero { display: flex; flex-direction: column; }
.hero-main {
  display: grid; grid-template-columns: minmax(200px, 280px) 1fr;
  gap: var(--s5); align-items: center;
  margin-top: var(--s4); padding-top: var(--s4);
  border-top: 1px solid var(--border-soft);
}
.hero-id { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.hero-id h1 { font-size: 20px; line-height: 1.2; overflow-wrap: anywhere; }
.hero-meta { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.hero-kpis {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s4) var(--s5);
  padding-left: var(--s5); border-left: 1px solid var(--border-soft);
}
.hero-kpis .kpi:first-child .kpi-value { font-size: 26px; }

/* ── chart ──────────────────────────────────────────────────────── */
.chart-scroll { overflow-x: auto; margin: 0 -2px; }
.trend { width: 100%; height: auto; display: block; }
.gridline { stroke: #1c2532; stroke-width: 1; }
.threshline { stroke-width: 1; stroke-dasharray: 5 5; opacity: .45; }
.thresh-label { font-size: 9.5px; font-weight: 600; opacity: .9; }
.thresh-bg { fill: var(--panel); stroke: var(--border-soft); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 10px; }
.line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line.all { stroke-dasharray: 6 5; stroke-width: 2; opacity: .85; }
@media (prefers-reduced-motion: no-preference) {
  .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .7s ease-out forwards; }
  .line.all { animation: none; stroke-dasharray: 6 5; stroke-dashoffset: 0; }
  .bar { transform-origin: left center; animation: growbar .45s cubic-bezier(.2, .7, .3, 1); }
}
/* re-renders (legend/mode toggles, resize) skip the draw-in animation */
svg.trend.no-anim .line { animation: none; stroke-dasharray: none; stroke-dashoffset: 0; }
svg.trend.no-anim .line.all { stroke-dasharray: 6 5; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes growbar { from { transform: scaleX(0); } }
.focus-dot { fill: var(--bg); stroke-width: 2.5; pointer-events: none; }
.hoverline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }
.chart-tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s2) var(--s3); font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  max-width: 340px;
}
.chart-tip[hidden] { display: none !important; }
.tip-head {
  font-weight: 600; color: var(--text); padding-bottom: 5px; margin-bottom: 5px;
  border-bottom: 1px solid var(--border-soft);
}
.tip-rows { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); }
.tip-name {
  display: flex; align-items: center; gap: 6px; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px;
}
.tip-val { color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }
.tip-name.is-all, .tip-val.is-all { color: var(--text); font-weight: 600; }
.tip-note { grid-column: 1 / -1; color: var(--muted); padding-top: 3px; }
.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dotc.dot-all { width: 12px; height: 0; border-radius: 0; border-top: 2px dashed var(--text); }

/* ── legend ─────────────────────────────────────────────────────── */
.legend-chips { margin-top: var(--s3); }
.lg-top {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding-bottom: var(--s2); margin-bottom: var(--s2);
  border-bottom: 1px solid var(--border-soft);
}
.lg-chips { display: flex; flex-wrap: wrap; gap: var(--s1) 6px; }
.lchip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-sm); border: 1px solid var(--border-soft);
  background: var(--panel-2); color: var(--text-dim); font-size: 12px; cursor: pointer;
  font-family: inherit;
  transition: opacity .15s, border-color .15s, color .15s, background-color .15s;
}
.lchip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.lchip.off { opacity: .4; }
.lchip:hover { border-color: #35455c; color: var(--text); }
/* company line: distinct by weight + dashed swatch, not by size */
.lchip.all-chip { border-color: var(--border); background: var(--panel-3); font-weight: 600; }
.lchip.all-chip .dotc {
  width: 14px; height: 0; border-radius: 0; border-top: 2px dashed var(--text);
}
.lg-ctl {
  margin-left: auto; padding: 3px 9px; font-size: 12px;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent;
  color: var(--muted); cursor: pointer; font-family: inherit;
  transition: color .15s, border-color .15s, background-color .15s;
}
.lg-ctl:hover { color: var(--text); border-color: var(--border-soft); background: var(--panel-2); }
.lchip.more-chip {
  border-style: dashed; color: var(--muted); background: transparent;
}
.lchip.more-chip:hover { color: var(--text); }

/* ── status pills / tags ────────────────────────────────────────── */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.pill.ok { background: rgba(52, 211, 153, .09); color: #6ee7b7; }
.pill.pend { background: rgba(250, 204, 21, .12); color: var(--warn); }
.pill.warn-o { background: rgba(251, 146, 60, .14); color: var(--orange); }
/* red caps is reserved for EXCESSIVE — both Visa conditions met */
.pill.bad {
  background: rgba(248, 113, 113, .16); color: var(--err);
  border-color: rgba(248, 113, 113, .4); letter-spacing: .4px;
}
.pill.muted-pill { background: rgba(135, 148, 166, .12); color: var(--muted); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.tag.cat-tag { text-decoration: none; }
.tag.cat-tag:hover { text-decoration: none; filter: brightness(1.15); }
.tag.cat-core    { background: rgba(52, 211, 153, .14); color: var(--mint); }
.tag.cat-digital { background: rgba(96, 165, 250, .14); color: var(--dgtl); }
.tag.cat-growth  { background: rgba(167, 139, 250, .14); color: var(--violet); }
.tag.type-tc40    { background: rgba(248, 113, 113, .14); color: var(--err); }
.tag.type-cb      { background: rgba(96, 165, 250, .14); color: var(--dgtl); }
.tag.type-cbfraud { background: rgba(135, 148, 166, .14); color: var(--text-dim); }
.tag.type-won     { background: rgba(52, 211, 153, .14); color: var(--mint); }
.tag.type-lost    { background: rgba(250, 204, 21, .12); color: var(--warn); }

/* ── tables ─────────────────────────────────────────────────────── */
.tbl-tools {
  display: flex; align-items: center; gap: var(--s3); margin: 0 0 var(--s3);
  flex-wrap: wrap; min-height: 32px;
}
.tbl-tools input[type="search"] { width: 260px; max-width: 100%; }
/* Tables run full length and the page does the scrolling — the header
   pins under the topbar instead of inside a nested scrollport. A wrap
   that scrolls sideways can't do that (an overflow box becomes the
   scrollport), so app.js measures each table and adds .x-fits when it
   doesn't need the sideways scroll, which is the desktop case. The
   overflow default stays on so a pre-JS or no-JS render still can't
   push the page sideways. */
.tbl-wrap { overflow-x: auto; }
.tbl-wrap.x-fits { overflow: visible; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl-wrap .tbl { min-width: 900px; }
.tbl th {
  position: sticky; top: var(--topbar-h); z-index: 2; background: var(--panel);
  text-align: left; color: var(--muted); font-weight: 600;
  font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
  padding: 8px 10px; white-space: nowrap;
  box-shadow: inset 0 -1px 0 var(--border);
}
.card.sub .tbl th { background: var(--bg); }
.tbl td {
  padding: 6px 10px; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle; transition: background-color .12s;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--panel-2); }
.card.sub .tbl tbody tr:hover td { background: var(--panel); }
th.num { text-align: right; }
th[title] { cursor: help; }
.agent-link { font-weight: 600; color: var(--text); }
.agent-link:hover { color: var(--mint); text-decoration: none; }
.rank { width: 30px; font-size: 11px; text-align: right; color: var(--muted); }
.pivot tbody tr { cursor: pointer; }
.pivot.static-rows tbody tr { cursor: default; }
.tbl td.stmt { max-width: 300px; overflow-wrap: anywhere; line-height: 1.4; }
.tbl td.reason { max-width: 340px; overflow-wrap: anywhere; line-height: 1.4; }
.psp {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text-dim);
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.flags { display: flex; gap: var(--s1); flex-wrap: wrap; }
.ctry-flag { font-size: 14px; line-height: 1; margin-right: 7px; }
.crumb { margin: 0 0 var(--s2); font-size: 12px; }

/* The MID column stays pinned while the pivot scrolls horizontally.
   Its edge shadow only appears once the table is actually scrolled
   sideways (app.js flags the wrap) — otherwise it reads as a stray
   rule down the middle of a table that fits. */
.pivot th:nth-child(2), .pivot td:nth-child(2) {
  position: sticky; left: 0; background: var(--panel);
}
.pivot th:nth-child(2) { z-index: 3; box-shadow: inset 0 -1px 0 var(--border); }
.pivot td:nth-child(2) { z-index: 1; }
.scrolled-x .pivot td:nth-child(2) { box-shadow: 6px 0 8px -6px rgba(0, 0, 0, .65); }
.scrolled-x .pivot th:nth-child(2) {
  box-shadow: inset 0 -1px 0 var(--border), 6px 0 8px -6px rgba(0, 0, 0, .65);
}
/* Nothing to pin sideways when the table already fits — and left-sticky
   against the viewport would be a live tripwire if the page ever did
   scroll horizontally. Drop only the horizontal offset: clearing
   `position` here would also un-stick this one header cell vertically
   and leave it scrolling away while its ten neighbours pinned. */
.tbl-wrap.x-fits .pivot th:nth-child(2),
.tbl-wrap.x-fits .pivot td:nth-child(2) { left: auto; }
.card.sub .pivot th:nth-child(2), .card.sub .pivot td:nth-child(2) { background: var(--bg); }
.pivot tbody tr:hover td:nth-child(2) { background: var(--panel-2); }
.card.sub .pivot tbody tr:hover td:nth-child(2) { background: var(--panel); }

/* sortable headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: "↕"; margin-left: 5px; color: #33415a; font-size: 9px; }
th.sortable:hover { color: var(--text-dim); }
th.sortable:hover::after { color: var(--muted); }
th.sortable.sort-desc, th.sortable.sort-asc { color: var(--text); }
th.sortable.sort-desc::after { content: "↓"; color: var(--mint); font-size: 10px; }
th.sortable.sort-asc::after  { content: "↑"; color: var(--mint); font-size: 10px; }

/* ── bars + dual threshold meter ────────────────────────────────── */
.barcell { width: 16%; min-width: 148px; vertical-align: middle; }
.bar-track { background: rgba(255, 255, 255, .045); border-radius: 3px; overflow: hidden; }
.bar {
  height: 6px; border-radius: 3px; min-width: 2px;
  background: linear-gradient(90deg, var(--mint-dim), var(--mint));
}
.bar.subtle { background: rgba(52, 211, 153, .35); }
/* dual threshold meter: a FULL bar = at Visa's limit (see _macros.html) */
.meter2 {
  display: grid; grid-template-columns: 38px 1fr;
  gap: 4px var(--s2); align-items: center; cursor: help;
}
.meter2 .mlabel { font-size: 10px; line-height: 1; color: var(--muted); text-align: right; }
.meter2 .bar { height: 6px; }
.bar-track.meter { position: relative; overflow: visible; border-radius: 3px; }
.bar-track.meter > .bar { position: relative; z-index: 1; }
.bar.warn { background: linear-gradient(90deg, #b45309, var(--warn)); }
.bar.bad  { background: linear-gradient(90deg, #b91c1c, var(--err)); }
.bar.lowvol { background: rgba(135, 148, 166, .45); }
.bar.cnt  { background: rgba(96, 165, 250, .5); }
.bar.over { background: linear-gradient(90deg, #c2410c, var(--orange)); }
/* watch line = amber tick inside the track; excessive line = the end cap */
.meter .tick {
  position: absolute; top: -2px; bottom: -2px; width: 2px; z-index: 2;
  background: rgba(250, 204, 21, .6); border-radius: 1px;
}
.meter .limit {
  position: absolute; top: -2px; bottom: -2px; right: 0; width: 3px; z-index: 2;
  background: rgba(248, 113, 113, .6); border-radius: 1px;
}
.meter .limit.cnt { background: rgba(251, 146, 60, .5); }

/* ── notes / footnotes ──────────────────────────────────────────── */
.note { margin-top: var(--s4); font-size: 12px; }
.note > summary {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content;
  padding: 3px 10px; border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; list-style: none;
  transition: color .15s, border-color .15s, background-color .15s;
}
.note > summary::-webkit-details-marker { display: none; }
.note > summary::after { content: "▾"; font-size: 9px; transition: transform .15s; }
.note[open] > summary::after { transform: rotate(180deg); }
.note > summary:hover { color: var(--text-dim); border-color: var(--border); background: var(--panel-2); }
.note-body {
  margin: var(--s2) 0 0; padding: var(--s3) var(--s4);
  color: var(--muted); line-height: 1.6; max-width: 82ch;
  background: rgba(255, 255, 255, .015); border-radius: var(--r-sm);
  border: 1px solid var(--border-soft);
}
.note-body p { margin: 0 0 var(--s2); }
.note-body p:last-child { margin-bottom: 0; }
.note-body b { color: var(--text-dim); }
.hint { margin: var(--s3) 0 0; font-size: 12px; color: var(--muted); }
.empty {
  margin: 0; padding: var(--s3) var(--s4); font-size: 13px; color: var(--muted);
  background: rgba(255, 255, 255, .015);
  border: 1px solid var(--border-soft); border-radius: var(--r-sm);
}

/* ── MID mapping (config) ───────────────────────────────────────── */
.cfg-tools {
  position: sticky; top: var(--topbar-h); z-index: 5;
  background: var(--panel); padding: var(--s3) 0;
  margin-top: calc(var(--s3) * -1);
  border-bottom: 1px solid var(--border-soft);
}
/* the mapping table's header pins below the sticky tools row, not under
   it — app.js keeps --cfg-tools-h in step with the row's real height */
.config-tbl th { top: calc(var(--topbar-h) + var(--cfg-tools-h, 57px)); }
.cfg-tools .spacer { margin-left: auto; }
.savedmsg {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--mint); white-space: nowrap;
}
.savedmsg::before {
  content: "✓"; display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; border-radius: 50%; font-size: 10px;
  background: rgba(52, 211, 153, .16);
}
.config-tbl td { padding: 0 10px; height: 38px; }
.config-tbl td.midcell { padding: 0 10px; }
/* the Adyen display name, when it isn't just the MID again */
.acct-name { font-size: 12px; margin-left: 2px; }
.config-tbl .radio-cell { padding: 0; text-align: center; }
.config-tbl .radio-cell label {
  display: flex; align-items: center; justify-content: center;
  height: 38px; cursor: pointer; transition: background-color .12s;
}
.config-tbl .radio-cell label:hover { background: rgba(255, 255, 255, .03); }
.config-tbl input[type="radio"] {
  accent-color: var(--mint-dim); color-scheme: dark;
  width: 15px; height: 15px; cursor: pointer;
}
/* Selected-cell highlight. :has() paints it before script runs; the
   .is-picked twin (set by app.js) covers browsers without :has() and
   keeps up as the user clicks. Kept as separate rules on purpose — one
   selector list would be thrown out whole where :has() is unknown. */
.config-tbl .radio-cell:has(input:checked) {
  background: rgba(52, 211, 153, .1); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .22);
}
.config-tbl .radio-cell.is-picked {
  background: rgba(52, 211, 153, .1); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, .22);
}
/* "Unassigned" checked is the resting state for 50+ rows — flag it
   neutrally and let the row's amber edge carry the "needs attention" */
.config-tbl .radio-cell.none-cell:has(input:checked) {
  background: rgba(255, 255, 255, .03); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
}
.config-tbl .radio-cell.none-cell.is-picked {
  background: rgba(255, 255, 255, .03); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .07);
}
.config-tbl tr.row-unassigned td:first-child { box-shadow: inset 2px 0 0 rgba(250, 204, 21, .5); }
.cfg-foot { margin-top: var(--s4); display: flex; align-items: center; justify-content: flex-end; gap: var(--s3); }

/* ── users ──────────────────────────────────────────────────────── */
.userchip {
  font-size: 12px; color: var(--muted); white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  padding: 0 var(--s1);
}
.userchip .ro {
  margin-left: 4px; padding: 1px 7px; border-radius: var(--r-pill);
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
  background: rgba(135, 148, 166, .14); color: var(--text-dim);
}
.users-add {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  padding-bottom: var(--s3); margin-bottom: var(--s3);
  border-bottom: 1px solid var(--border-soft);
}
.users-add input[type="email"] { width: 220px; }
.users-add input[type="text"] { width: 150px; }
.catpick { display: inline-flex; align-items: center; gap: var(--s3); }
.catpick label {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-dim); cursor: pointer; white-space: nowrap;
}
.catpick input[type="checkbox"] {
  accent-color: var(--mint-dim); color-scheme: dark;
  width: 14px; height: 14px; cursor: pointer;
}
.catpick.off { opacity: .35; }
.catpick.off label { cursor: default; }
.users-tbl td { height: 44px; }
.users-actions { text-align: right; }
.btn.danger:hover {
  border-color: rgba(248, 113, 113, .5); color: var(--err);
  background: rgba(248, 113, 113, .08);
}
.flash {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  margin: 0 0 var(--s3); padding: 8px 12px; font-size: 13px;
  border: 1px solid rgba(52, 211, 153, .3); border-radius: var(--r-sm);
  background: rgba(52, 211, 153, .07); color: var(--text-dim);
}
.flash.err {
  border-color: rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .07); color: var(--err);
}
.invite-hint { margin: 0; font-size: 13px; color: var(--text-dim); text-align: center; }
.invite-hint b { color: var(--text); }
a.lastlogin:hover { color: var(--text); text-decoration: none; }
.tbl td.agent {
  max-width: 420px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; color: var(--muted); font-size: 12px;
}

/* ── responsive ─────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .syncpill .syncnext { display: none; }
}
/* the identity chip is a nicety — give its room back to the controls
   before the topbar starts wrapping */
@media (max-width: 1100px) {
  .userchip { display: none; }
}
@media (max-width: 1000px) {
  .kpi-card { grid-template-columns: 1fr; gap: var(--s4); }
  .kpi-primary {
    flex-direction: row; align-items: center; justify-content: space-between;
    gap: var(--s3); padding-right: 0; padding-bottom: var(--s4);
    border-right: 0; border-bottom: 1px solid var(--border-soft);
  }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-main { grid-template-columns: 1fr; }
  .hero-kpis { padding-left: 0; padding-top: var(--s4); border-left: 0; border-top: 1px solid var(--border-soft); }
}
@media (max-width: 760px) {
  main { padding: var(--s3) var(--s3) 48px; }
  .topbar { flex-wrap: wrap; row-gap: var(--s2); padding: var(--s2) var(--s3); }
  .topbar-right { width: 100%; flex-wrap: wrap; row-gap: var(--s2); }
  .syncpill { order: 2; width: 100%; }
  .toolbar { gap: var(--s2); }
  .toolbar > .monthnav { flex: 1 1 100%; }
  .monthnav .month-select { flex: 1; }
  .tb-range { margin-left: 0; flex: 1 1 100%; }
  .hero-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
  .card { padding: var(--s3) var(--s4); }
  /* the topbar wraps to two rows here — a stack of sticky bars would eat
     the viewport, so the tools row and table headers scroll away
     normally (both pages keep a second Save button at the foot) */
  .cfg-tools { position: static; }
  .tbl th, .config-tbl th { position: static; }
}
@media (max-width: 430px) {
  .kpi-primary-value { font-size: 24px; }
  .kpi-value { font-size: 19px; }
  .hero-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-kpis .kpi:first-child .kpi-value { font-size: 22px; }
  .seg-btn { padding: 0 9px; }
  .tbl-tools input[type="search"] { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* ── print / save-as-PDF ────────────────────────────────────────────
   The Save PDF button just calls window.print(); these rules make the
   browser's own "Save as PDF" come out as a clean dark snapshot.
   Landscape because the pivot tables run ~900px wide; margin 0 so the
   dark background bleeds to the page edge (main carries the padding
   instead — printers only clip inside their hardware margin, and a
   saved PDF has none). */
.print-only { display: none; }
@page { size: landscape; margin: 0; }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: var(--bg); }
  .print-only { display: revert; }
  .print-omit { display: none !important; }
  /* interactive chrome has no meaning on paper — the .print-head line
     in the templates restates the month / business line / RDR state */
  .loadbar, .topbar-right, .toolbar, .tbl-tools, .crumb,
  .lg-ctl, .lchip.more-chip, .hint, .note,
  .users-add, .users-actions, .flash, [data-copy-path],
  .chart-tip, .hoverline, .focus-dot { display: none !important; }
  /* the dashboard's toolbar-only card would print as an empty box, and
     the unmapped-MIDs ops banner is internal chatter, not data */
  .card:has(> .toolbar:only-child), .card.banner { display: none !important; }
  /* Chromium's print viewport can land under the responsive
     breakpoints — pin the desktop layouts back for paper */
  .kpi-card { grid-template-columns: minmax(190px, 250px) 1fr; }
  .kpi-primary {
    flex-direction: column; align-items: stretch; justify-content: flex-start;
    padding: var(--s3) var(--s4); border: 1px solid var(--border-soft);
  }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero-main { grid-template-columns: minmax(200px, 280px) 1fr; }
  .hero-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-left: var(--s5); padding-top: 0;
    border-left: 1px solid var(--border-soft); border-top: 0;
  }
  .topbar {
    position: static; border-bottom: 0; background: var(--bg);
    padding: 9mm 10mm 0;
  }
  .print-url { margin-left: auto; font-size: 11px; color: var(--muted); }
  main { padding: 0 10mm 9mm; }
  .print-head { margin: var(--s3) 0 0; font-size: 13px; color: var(--text-dim); }
  .print-head b { color: var(--text); }
  .print-note { margin: var(--s4) 0 0; font-size: 12px; color: var(--muted); }
  /* the mid-hero toolbar is gone — don't leave its divider hanging */
  .hero-main { margin-top: 0; padding-top: 0; border-top: 0; }
  /* pagination: keep the small cards and rows whole, let tables run
     across pages with their header row repeating (table-header-group) */
  .kpi-card, .mid-hero, .chart-scroll, .legend-chips { break-inside: avoid; }
  tr, .kpi { break-inside: avoid; }
  /* sticky was for scrolling — static on paper, and the page must not
     clip a nested scrollport */
  .tbl th { position: static; }
  .pivot th:nth-child(2), .pivot td:nth-child(2) { position: static; }
  .tbl-wrap, .chart-scroll { overflow: visible; }
  .tbl-wrap .tbl { min-width: 0; }
  a { text-decoration: none !important; }
}
