/* SharpLine Billing admin — single dark theme, base #121212 */
:root {
  --bg: #121212;
  --surface: #1a1a1a;
  --surface-2: #202020;
  --line: #2b2b2b;
  --ink: #f2f2f2;           /* primary: headings, labels, values */
  --mut: #b4b4b4;           /* secondary: descriptions, table meta */
  --faint: #7f7f7f;         /* tertiary: hints, timestamps */
  --sp-section: 32px;       /* vertical rhythm between panels / sections */
  --sp-panel: 20px;         /* panel body padding */
  --accent: #5167FC;          /* the only non-neutral UI color */
  --accent-bg: rgba(81, 103, 252, .14);
  --info: #5167FC;
  --ok: #3fb27f;
  --warn: #d9a04a;
  --bad: #e5484d;
  --info-bg: rgba(81, 103, 252, .14);
  --ok-bg: rgba(63, 178, 127, .12);
  --warn-bg: rgba(217, 160, 74, .13);
  --bad-bg: rgba(229, 72, 77, .12);
}
/* Type scale: every font-size is in rem, so this one number sizes the whole app.
   100% = the original design; 112.5% = 12.5% larger for readability. */
html { font-size: 112.5%; }
:root { --ctl-h: 36px; } /* shared height for filter-bar inputs, selects, buttons */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 0.875rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  /* the page itself never scrolls — #view's <main> is the only scroller,
     so the sidebar can neither scroll away nor rubberband */
  overflow: hidden;
}
a { color: var(--ink); }

/* ---- layout ---- */
#shell { display: flex; height: 100dvh; }
nav {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); padding: 20px 12px;
  display: flex; flex-direction: column; gap: 2px;
  height: 100%; z-index: 1;
  /* scrolls only if the window is shorter than the nav itself */
  overflow-y: auto; overscroll-behavior: contain;
}
nav .brand { font-weight: 700; font-size: 0.9375rem; padding: 4px 10px 18px; letter-spacing: .01em; }
nav .brand span { color: var(--faint); font-weight: 400; }
nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px;
  text-decoration: none; color: var(--mut); font-weight: 500;
}
nav a svg { width: 16px; height: 16px; flex-shrink: 0; stroke: currentColor; fill: none;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
nav a:hover { background: var(--surface-2); color: var(--ink); }
nav a.on { background: var(--accent-bg); color: var(--ink); }
nav a.on svg { stroke: var(--accent); opacity: 1; }
nav .group { display: flex; flex-direction: column; gap: 2px; margin-top: 22px; }
nav .group-label {
  padding: 0 12px 8px; font-size: 0.6875rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink);
}
nav .foot { margin-top: auto; padding: 10px; color: var(--faint); font-size: 0.75rem; }
nav .foot button { width: 100%; }
main { flex: 1; padding: 0 40px 96px; min-width: 0;
  overflow-y: auto; overscroll-behavior: contain;
  /* Content sits in one centered column capped like Stripe's dashboard, so a
     wide monitor gets margins instead of stretched tables. main itself stays
     full-width so the scrollbar hugs the window edge. */
  display: grid; grid-template-columns: minmax(0, 1460px); justify-content: center; align-content: start; }
/* The top gap is a child of the scroller (not its padding), so a sticky table header can
   hug the top edge with nothing scrolling past above it. (main IS #view.) */
main::before { content: ''; display: block; height: 32px; }
main h1 { font-size: 1.5rem; margin: 0 0 6px; font-weight: 650; letter-spacing: -.01em; }
main .sub { color: var(--mut); margin: 0 0 var(--sp-section); max-width: 880px; line-height: 1.55; }

/* ---- components ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: var(--sp-section); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.tile b { display: block; font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile span { color: var(--mut); font-size: 0.78125rem; display: block; margin-top: 2px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: var(--sp-section); }
.panel > h2 {
  font-size: 0.8125rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink);
  margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 650;
}
.panel .body { padding: var(--sp-panel); }

.wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.8125rem; }
th {
  text-align: left; color: var(--ink); font-weight: 600; padding: 11px 16px;
  border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 0.75rem;
}
td { padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
/* Row hover: the eye can follow a row across a wide table. Header rows have no <td>, so they never highlight. */
tr:has(> td):hover > td { background: rgba(255, 255, 255, .025); }
.rowlink { color: var(--ink); text-decoration: none; display: block; }
.rowlink:hover { text-decoration: underline; }
td .sub2 { color: var(--faint); font-size: 0.75rem; }
.empty { color: var(--mut); padding: 32px 16px; text-align: center; }
.right { text-align: right; }

.pill { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 0.71875rem; font-weight: 600; }
.p-info { background: var(--info-bg); color: #8a9aff; }
.p-ok   { background: var(--ok-bg);   color: var(--ok); }
.p-warn { background: var(--warn-bg); color: var(--warn); }
.p-bad  { background: var(--bad-bg);  color: var(--bad); }
.p-mut  { background: var(--surface-2); color: var(--mut); }

button {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 0.8125rem;
  font-weight: 550; cursor: pointer;
}
button:hover { border-color: var(--faint); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: #6478ff; border-color: #6478ff; }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 0.75rem; }
button:disabled { opacity: .5; cursor: default; }

input, select {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; font: inherit;
}
input:focus, select:focus, button:focus-visible,
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px;
  color: var(--mut); cursor: pointer; font-size: 0.78125rem; background: none; font-weight: 550;
}
.chip.on { background: var(--accent-bg); color: var(--ink); border-color: var(--accent); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.formrow label { display: flex; flex-direction: column; gap: 5px; font-size: 0.75rem; color: var(--ink); font-weight: 500; }

.hbar-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink); margin: 0 0 12px; font-weight: 650; }
.hbar-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 10px;
  align-items: center; padding: 3px 0; font-size: 0.78125rem; }
.hbar-label { color: var(--ink); white-space: nowrap; }
.hbar-track { background: var(--surface-2); border-radius: 3px; height: 14px; min-width: 40px; }
.hbar-fill { background: var(--accent); border-radius: 3px; height: 100%; min-width: 1px; }
.hbar-val { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* today card */
.today-card { margin-bottom: 66px; } /* 16px + 50px: the date range below applies only to the metric cards */
.today-head { display: flex; gap: 48px; margin-bottom: 6px; }
.today-head .mval.yday { color: var(--mut); }


/* home toolbar: Date range | Granularity | Compare */
.home-toolbar { position: relative; gap: 8px; margin-bottom: 22px; }
.seg {
  display: inline-flex; align-items: stretch; height: 30px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 6px; background: var(--surface);
}
.segbtn, .segx {
  background: none; border: 0; border-radius: 0; padding: 0 10px; display: inline-flex;
  align-items: center; gap: 6px; font-size: 0.78125rem; font-weight: 600; color: var(--ink); height: 100%;
}
.segbtn:hover, .segx:hover { background: var(--surface-2); border-color: transparent; }
.segbtn .seglab { color: var(--mut); font-weight: 550; padding-right: 10px; border-right: 1px solid var(--line); margin-right: 2px; }
.segbtn .seglab.solo { border-right: 0; padding-right: 0; margin-right: 0; }
.segbtn .segval { color: #8a9aff; }
.segbtn .chev { width: 12px; height: 12px; stroke: var(--mut); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.segx { padding: 0 6px 0 9px; color: var(--mut); border-right: 1px solid var(--line); }
.segx svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; }
.segx:hover { color: var(--ink); }

.pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .55); overflow: auto;
}
.menu { padding: 6px; min-width: 190px; display: flex; flex-direction: column; gap: 1px; }
.mitem {
  background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 6px;
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  font-weight: 500; font-size: 0.84375rem; color: var(--ink);
}
.mitem:hover { background: var(--surface-2); }
.chk { width: 15px; height: 15px; flex-shrink: 0; }
.chk circle { fill: var(--ink); }
.chk .tick { fill: none; stroke: var(--surface); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* date range picker */
.rp { display: flex; gap: 20px; padding: 14px; }
.rp-presets { display: flex; flex-direction: column; gap: 2px; width: 150px; flex-shrink: 0; }
.rp-preset {
  background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 6px;
  color: var(--ink); font-weight: 500; font-size: 0.84375rem;
}
.rp-preset:hover { background: var(--surface-2); }
.rp-preset.on { background: var(--accent-bg); color: #8a9aff; }
.rp-main { display: flex; flex-direction: column; gap: 14px; }
.rp-inputs { display: flex; align-items: center; gap: 10px; }
.rp-lab { color: var(--mut); font-size: 0.8125rem; }
.dfield {
  display: inline-flex; align-items: center; gap: 2px; padding: 2px 6px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); font-variant-numeric: tabular-nums;
}
.dfield:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.dfield input {
  border: 0; background: none; padding: 3px 2px; width: 28px; text-align: center; border-radius: 4px;
  font-variant-numeric: tabular-nums; font-size: 0.84375rem;
}
.dfield input.yy { width: 46px; }
.dfield input:focus { outline: none; background: var(--accent-bg); }
.dfield input::placeholder { color: var(--faint); }
.dfield span { color: var(--mut); }
.rp-cals { display: flex; gap: 12px; align-items: flex-start; }
.rp-nav { background: none; border: 0; color: var(--mut); font-size: 1.25rem; line-height: 1; padding: 2px 6px; margin-top: 4px; }
.rp-nav:hover { color: var(--ink); }
.cal { width: 280px; }
.cal-title { text-align: center; font-weight: 600; font-size: 0.875rem; margin-bottom: 8px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.cal-dow { text-align: center; color: var(--mut); font-size: 0.75rem; padding: 4px 0 6px; }
.cal-day {
  background: none; border: 0; border-radius: 0; height: 34px; padding: 0; position: relative;
  color: var(--ink); font-size: 0.8125rem; font-weight: 500;
}
.cal-day span { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; }
.cal-day:hover:not(:disabled) span { background: var(--surface-2); }
.cal-day:disabled { color: var(--faint); opacity: .55; cursor: default; }
.cal-day.today span { text-decoration: underline; text-underline-offset: 3px; }
.cal-day.in { background: var(--accent-bg); }
.cal-day.st { border-radius: 17px 0 0 17px; }
.cal-day.en { border-radius: 0 17px 17px 0; }
.cal-day.st.en { border-radius: 17px; }
.cal-day.st span, .cal-day.en span, .cal-day.st:hover span, .cal-day.en:hover span { background: var(--accent); color: #fff; font-weight: 600; }
.rp-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
.cmp-custom { padding: 12px 14px; gap: 10px; }
.cmp-custom .rp-foot { margin-top: 4px; }

/* metric cards dim while a new window loads; the page itself never repaints */
.mgrid { transition: opacity .15s; }
.mgrid.loading { opacity: .55; pointer-events: none; }
/* A filter re-route keeps the old list on screen until the new one is ready; the
   dim is delayed so a fast response never flickers. */
#view.loading { cursor: progress; }
#view.loading .panel { opacity: .6; transition: opacity .15s ease .2s; }

/* home metric cards */
.mgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 1100px) { .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .mgrid { grid-template-columns: 1fr; } }
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px 14px; min-width: 0; }
.mtitle { font-weight: 600; font-size: 0.84375rem; display: flex; align-items: center; gap: 6px; }
.help {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px;
  border: 1px solid var(--faint); border-radius: 3px; color: var(--faint); font-size: 0.59375rem;
  font-weight: 700; cursor: help; font-style: normal; line-height: 1;
}
#tip {
  position: fixed; z-index: 1000; width: 240px; pointer-events: none;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; font-size: 0.75rem; font-weight: 400; line-height: 1.4;
  white-space: normal; text-align: left; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}

.mchart-wrap { position: relative; }
.hovercard {
  position: absolute; z-index: 1000; pointer-events: none; min-width: 170px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 0.78125rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.hc-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.hc-head b { font-weight: 600; }
.hc-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 2px 0; color: var(--mut); }
.hc-row b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.cur { background: var(--accent); }
.sw.prev { background: #8a8a8a; }
.mval { font-size: 1.375rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 4px; display: flex; align-items: baseline; gap: 8px; }
.delta { font-size: 0.8125rem; font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--mut); }
.mprev { color: var(--mut); font-size: 0.8125rem; margin-bottom: 8px; }
.mchart { width: 100%; display: block; cursor: crosshair; }
.mfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 0.75rem; }
.mfoot a { color: var(--mut); text-decoration: none; }
.mfoot a:hover { color: var(--ink); }

#toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink); border-radius: 8px;
  padding: 10px 16px; opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: 380px; font-size: 0.8125rem; z-index: 1001;
}
#toast.show { opacity: 1; }
#toast.err { border-color: var(--bad); }

/* key gate */
#gate {
  position: fixed; inset: 0; background: var(--bg); display: flex;
  align-items: center; justify-content: center; z-index: 2000;
}
#gate .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; width: 340px; display: flex; flex-direction: column; gap: 12px;
}
#gate h1 { font-size: 1.0625rem; margin: 0; }
#gate p { color: var(--mut); margin: 0; font-size: 0.8125rem; }
#gate .err { color: var(--bad); font-size: 0.8125rem; min-height: 18px; margin: 0; }

.backlink { color: var(--mut); text-decoration: none; font-size: 0.8125rem; display: inline-block; margin-bottom: 12px; }
.backlink:hover { color: var(--ink); }

@media (max-width: 760px) {
  #shell { flex-direction: column; }
  nav { width: 100%; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    overflow-y: visible; flex-shrink: 0; }
  nav .brand { padding-bottom: 4px; }
  nav .group { display: contents; }
  nav .group-label { display: none; }
  nav .foot { margin: 0; }
  main { padding: 0 16px 60px; --sp-section: 24px; --sp-panel: 16px; }
  main::before { height: 20px; }
}

/* payment routing */
.route { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.route-step {
  display: flex; align-items: center; gap: 12px; flex: 1 1 260px; min-width: 0;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px;
}
.route-pos {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--ink); font-weight: 650; font-size: 0.78125rem;
}
.route-body { flex: 1; min-width: 0; }
.route-name { font-weight: 600; font-size: 0.84375rem; display: flex; gap: 8px; align-items: baseline; }
.route-meta { color: var(--mut); font-size: 0.75rem; margin-top: 2px; }
.route-arrow { color: var(--faint); font-size: 1.125rem; flex-shrink: 0; }
.route-end { margin-top: 14px; color: var(--mut); font-size: 0.78125rem; display: flex; gap: 8px; align-items: baseline; }
.route-end code { font: 0.75rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink); }
.rules { margin: 0; padding-left: 18px; color: var(--mut); font-size: 0.8125rem; }
.rules li { margin-bottom: 8px; }
.rules b { color: var(--ink); font-weight: 600; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 110px; }
.spark-col { flex: 1; height: 100%; display: flex; align-items: flex-end; border-radius: 2px; min-width: 3px; }
.spark-col:hover, .spark-col:focus-visible { background: var(--surface-2); outline: none; }
.spark-bar { width: 100%; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; display: flex; flex-direction: column; }
.spark-err { background: var(--bad); border-radius: 2px 2px 0 0; }
.spark-axis { display: flex; justify-content: space-between; color: var(--faint); font-size: 0.6875rem; margin-top: 4px; }
.legend { display: flex; gap: 6px; align-items: center; color: var(--mut); font-size: 0.75rem; margin-top: 12px; }
.legend .sw + .sw, .legend i + i { margin-left: 8px; }
.sw.bad { background: var(--bad); }

/* gateways */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
.lead { margin: 0; font-size: 0.8125rem; line-height: 1.5; }
.warn-panel { border-color: var(--bad); }
.warn-panel .body { display: flex; gap: 10px; align-items: center; color: var(--mut); font-size: 0.8125rem; }
.route-pos.small { width: 22px; height: 22px; font-size: 0.71875rem; }
.credk { color: var(--faint); }
.gw-actions { white-space: nowrap; }
td.wrapcell { white-space: normal; min-width: 200px; max-width: 300px; line-height: 1.35; }
.gw-actions button { margin-left: 4px; }
.gw-form .gw-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 18px; margin-bottom: 14px; }
.gw-form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.75rem; color: var(--ink); font-weight: 500; }
.gw-form input, .gw-form select { width: 100%; }
.gw-form .hint { color: var(--faint); font-size: 0.71875rem; line-height: 1.4; }
.gw-form .req { color: var(--bad); }
/* Gateway logo: a 28px square beside the label; the empty state shows the
   label's initial so rows with and without a logo keep the same shape. */
.gw-name { display: flex; align-items: center; gap: 10px; }
.gw-logo { width: 28px; height: 28px; border-radius: 6px; flex-shrink: 0; object-fit: contain;
  background: #fff; border: 1px solid var(--line); box-sizing: border-box; padding: 2px; }
.gw-logo.is-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2);
  color: var(--faint); font-size: 0.75rem; font-weight: 650; }
/* Secret fields rendered as text (not type=password) so the browser never autofills a saved login into them; masked visually instead. */
.secret-input { -webkit-text-security: disc; }
.secret-input:focus { -webkit-text-security: none; }
.gw-note { margin: 0 0 12px; font-size: 0.78125rem; line-height: 1.5; max-width: 720px; }
.gw-submit { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* routing editor */
.rt-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.rt-spacer { flex: 1; }
.rt-canvas {
  position: relative; display: grid; grid-template-columns: 170px 1fr; gap: 0 36px; align-items: center;
  padding: 22px 18px; border-radius: 10px; border: 1px solid var(--line);
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1px); background-size: 16px 16px;
}
.rt-wires { position: absolute; inset: 0; pointer-events: none; }
.rt-wires path { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.rt-start-col { display: flex; align-items: center; gap: 12px; }
.rt-start { background: #2a2a2a; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 9px 18px; font-weight: 650; }
.rt-split { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; }
.rt-split svg { width: 16px; height: 16px; stroke: var(--mut); fill: none; stroke-width: 1.8; }
.rt-branches { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rt-branch { display: grid; grid-template-columns: 280px 34px 1fr; align-items: center; min-width: 0; border-radius: 10px; }
.rt-branch.is-over { outline: 2px dashed var(--accent); outline-offset: 4px; }
.rt-node {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 12px 8px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font: inherit; color: var(--ink);
  min-width: 0;
}
.rt-node:hover { border-color: var(--faint); }
.rt-branch.is-selected .rt-node { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.rt-branch.is-off .rt-node { opacity: .55; }
.rt-node-static { cursor: default; }
.rt-node-static:hover { border-color: var(--line); }
.rt-badge { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-bg); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 650; flex-shrink: 0; }
.rt-node-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.rt-node-text b { font-weight: 600; font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-node-text .sub2 { font-size: 0.71875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-line { height: 0; border-top: 1.5px solid var(--faint); position: relative; margin: 0 4px; }
.rt-line::after { content: ''; position: absolute; right: -1px; top: -4px; border: 4px solid transparent; border-left: 6px solid var(--faint); }
.rt-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 8px; min-height: 58px; min-width: 0; }
.rt-card.is-over { border-color: var(--accent); background: var(--accent-bg); }
.rt-card.is-empty { border-style: dashed; }
.rt-card-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 30px; }
.rt-card-foot { color: var(--faint); font-size: 0.6875rem; margin-top: 6px; text-align: center; }
.rt-empty { color: var(--faint); font-size: 0.78125rem; }
/* touch / keyboard alternative to dragging a gateway onto a branch */
.rt-add-gw { padding: 3px 8px; font-size: 0.71875rem; color: var(--mut); max-width: 100%; }
.rt-arrow { color: var(--faint); font-size: 0.875rem; }
.rt-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 8px 4px 4px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 0.78125rem; font-weight: 550; cursor: grab; user-select: none;
}
.rt-chip:active { cursor: grabbing; }
.rt-chip.is-dragging { opacity: .4; }
.rt-chip.is-off { opacity: .45; cursor: not-allowed; }
.rt-logo { width: 22px; height: 22px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font-style: normal; font-weight: 800; font-size: 0.75rem; color: #fff; }
.rt-logo-nmi { background: #2f6fed; }
.rt-logo-mock { background: #7a7a7a; }
.rt-x { background: none; border: none; color: var(--faint); font-size: 0.9375rem; line-height: 1; padding: 0 2px; cursor: pointer; }
.rt-x:hover { color: var(--bad); border: none; }
.rt-palette { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; }
.rt-inspector { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.rt-insp-head { display: flex; gap: 16px; align-items: end; flex-wrap: wrap; }
.rt-name { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--mut); flex: 1 1 260px; }
.rt-enabled { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; padding-bottom: 7px; }
.rt-conds { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.rt-cond { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rt-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.rt-preview { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.8125rem; }
.rt-preview select { padding: 4px 8px; font-size: 0.78125rem; }
@media (max-width: 900px) {
  .rt-canvas { grid-template-columns: 1fr; gap: 16px; }
  .rt-wires { display: none; }
  .rt-branch { grid-template-columns: 1fr; gap: 6px; }
  .rt-line { display: none; }
}

/* invoice detail: charge history */
.run-head td { background: var(--surface-2); color: var(--mut); font-size: 0.75rem; padding: 6px 14px; }
.run-head b { color: var(--ink); font-weight: 600; }
.card-brand { display: inline-block; font-size: 0.59375rem; font-weight: 800; letter-spacing: .04em; padding: 1px 4px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--line); color: var(--mut); vertical-align: middle; }
/* Card network logos (sprite injected by app.js; see cardLogo) */
.card-logo-wrap { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; }
.card-logo { width: 30px; height: 20px; flex: none; border-radius: 3px; display: block; object-fit: contain; }
.chip .card-logo { width: 24px; height: 16px; }
.chip .card-logo-wrap { gap: 5px; }
table.p2-heat th .card-logo-wrap { justify-content: center; }
.mono { font: 0.75rem ui-monospace, SFMono-Regular, Menlo, monospace; }
.rt-logo-none { background: #444; }
.rt-logo-img { background: #fff; object-fit: contain; padding: 2px; box-sizing: border-box; vertical-align: middle; }
table.charges td { vertical-align: top; }
table.charges td .rt-logo { vertical-align: middle; margin-right: 2px; }

/* ---- shared primitives (modal, toast actions, pager, badges, tz note) ---- */
.modal-host { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal h3 { margin: 0 0 8px; font-size: 1rem; }
.modal p { margin: 0 0 14px; color: var(--mut); }
.modal-typed { display: block; margin-bottom: 14px; font-size: 0.8125rem; color: var(--mut); }
.modal-typed code { color: var(--ink); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.modal-typed input { display: block; width: 100%; margin-top: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
#toast { display: flex; align-items: center; gap: 12px; }
#toast .toast-action { border-color: var(--accent); color: var(--ink); }
.pager { display: flex; align-items: center; gap: 12px; padding: 12px 4px; color: var(--mut); font-size: 0.8125rem; }
.tz-note { color: var(--faint); font-size: 0.71875rem; margin: 6px 0 0; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 99px; font-size: 0.65rem; font-weight: 700; padding: 0 6px; min-width: 18px; text-align: center; line-height: 18px; }
nav .who { color: var(--faint); font-size: 0.71875rem; padding: 0 10px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters input, .filters select { min-width: 120px; }
/* Every control in a filter bar shares one height, whether or not it has a
   label above it, so a row of search + selects + buttons reads as one line. */
.filters input, .filters select, .filters button,
.p2-range-form input, .p2-range-form button, .p2-range > button {
  height: var(--ctl-h); box-sizing: border-box; padding-top: 0; padding-bottom: 0;
}
.filters .chip { align-self: flex-end; margin-bottom: 2px; } /* centred on the control row, not the label row */
.filters .grow { flex: 1; }
#toast.show { pointer-events: auto; }

/* ---- approvals release: shared ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.bad-text { color: var(--bad); }
.live-stamp { color: var(--faint); font-size: 0.71875rem; font-weight: 400; margin-left: 8px; }
.h-stamp { font-weight: 400; }
.panel > h2 a { color: var(--mut); text-decoration: none; font-weight: 500; font-size: 0.78125rem; margin-left: auto; }
.panel > h2 a:hover { color: var(--ink); }
.panel > h2 .sub2, .panel > h2 .live-stamp { font-weight: 400; color: var(--faint); font-size: 0.75rem; }
.panel > h2 button { margin-left: auto; }
.filters .f { display: flex; flex-direction: column; gap: 4px; font-size: 0.6875rem; color: var(--ink); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.filters .f input, .filters .f select { min-width: 0; }
.filters input[type="search"] { min-width: 220px; }
.filters .f input[type="date"] { min-width: 140px; }
.filters button { align-self: flex-end; }
.filters .f > span { line-height: 1.2; }
.pager button { min-width: 72px; }
.kv > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.8125rem; }
.kv > div:last-child { border-bottom: none; }
.kv > div > span { color: var(--ink); font-weight: 500; }
.kv > div > b { font-weight: 500; overflow-wrap: anywhere; }
.kv .ua { font-weight: 400; }
.kv .kv-actions { display: flex; gap: 10px; align-items: center; grid-template-columns: none; padding-top: 12px; flex-wrap: wrap; }
.notes { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notes li { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.8125rem; }
.notes .note-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.notes .sub2 { color: var(--faint); font-size: 0.71875rem; margin-top: 4px; display: flex; gap: 6px; align-items: center; }
.note-form { display: flex; gap: 8px; }
.note-form input { flex: 1; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.timeline li { position: relative; display: flex; flex-direction: column; gap: 2px; font-size: 0.8125rem; }
.timeline li::before { content: ''; position: absolute; left: -19px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .tl-when { font-size: 0.71875rem; }
.timeline .tl-body { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* modals with forms */
.modal-form { max-height: calc(100dvh - 40px); overflow-y: auto; }
.modal-wide { width: min(600px, calc(100vw - 32px)); }
.modal-body { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.mf { display: flex; flex-direction: column; gap: 5px; font-size: 0.75rem; color: var(--ink); font-weight: 500; }
.mf input, .mf select, .mf textarea { width: 100%; }
.mf .hint { color: var(--faint); font-size: 0.71875rem; line-height: 1.4; }
.mf-row { display: flex; gap: 10px; }
.mf-row .mf { flex: 1; }
.mf-check { display: flex; gap: 8px; align-items: flex-start; font-size: 0.8125rem; color: var(--ink); line-height: 1.4; }
.mf-check input { margin-top: 3px; }
.modal-err { color: var(--bad); font-size: 0.8125rem; min-height: 0; margin: 0 0 10px; }
.modal-err:empty { display: none; }

/* home: attention strip + extra tiles */
.tile .rowlink { text-decoration: none; }

/* invoice detail: retry ladder */
.inv-actions { gap: 8px; }
.ladder-head { font-size: 0.8125rem; color: var(--mut); margin-bottom: 14px; }
.ladder-head b { color: var(--ink); }
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ladder-step { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: flex-start; position: relative; padding: 0 0 14px; }
.ladder-step::before { content: ''; position: absolute; left: 12px; top: 24px; bottom: 0; border-left: 2px solid var(--line); }
.ladder-step:last-child::before { display: none; }
.ladder-icon { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--mut); }
.ladder-step.is-ok .ladder-icon { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.ladder-step.is-failed .ladder-icon { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.ladder-step.is-next .ladder-icon { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 0 0 3px var(--accent-bg); }
.ladder-step.is-parked .ladder-icon { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.ladder-step.is-skipped { opacity: .5; }
.ladder-main { display: flex; flex-direction: column; font-size: 0.8125rem; line-height: 1.35; padding-top: 2px; }
.ladder-main b { font-weight: 600; }
.ladder-main .sub2 { color: var(--faint); font-size: 0.75rem; }
.ladder-note { margin: 8px 0 0; line-height: 1.5; }
details.raw { margin-top: 4px; }
details.raw summary { cursor: pointer; }
details.raw pre { font: 0.6875rem ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px; max-height: 240px; max-width: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; margin: 6px 0 0; }

/* gateways: health block */
.gw-health { display: flex; flex-direction: column; gap: 3px; font-size: 0.78125rem; min-width: 240px; }
.gw-health b { font-weight: 600; }
.gw-health .hbar-track { height: 8px; margin-top: 4px; }
.gw-health .hbar-fill.is-warn { background: var(--warn); }
.gw-health .hbar-fill.is-full { background: var(--bad); }
.gw-health-actions { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.gw-bypass.on { border-color: var(--warn); color: var(--warn); }
tr.is-paused td { background: var(--warn-bg); }
td .gw-health-cell { vertical-align: top; }

/* routing editor: move buttons, bins, preview */
.rt-node-wrap { display: flex; align-items: center; gap: 4px; min-width: 0; }
.rt-node-wrap .rt-node { flex: 1; min-width: 0; }
.rt-move { display: inline-flex; flex-direction: column; gap: 0; }
.rt-move .rt-x { font-size: 0.75rem; line-height: 1; padding: 0 3px; }
.rt-move .rt-x:disabled { opacity: .3; cursor: default; }
.rt-chip .rt-move { flex-direction: row; margin-left: 2px; }
.rt-bins { display: flex; flex-direction: column; gap: 4px; flex: 1 1 320px; }
.rt-bins textarea { width: 100%; font: 0.78125rem ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; resize: vertical; }
.rt-bins textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.rt-cond .hint { color: var(--faint); font-size: 0.71875rem; line-height: 1.4; flex-basis: 100%; order: 10; }
.rt-cond .hint code { color: var(--ink); background: var(--surface-2); padding: 0 4px; border-radius: 3px; }
.rt-cond input[type="range"] { width: 180px; accent-color: var(--accent); }
.rt-preview input.pv { padding: 4px 8px; font-size: 0.78125rem; }
.rt-byrule { margin-top: 18px; }
.rt-byrule table { font-size: 0.78125rem; }
.wh-summary > h2 { display: flex; align-items: center; }

/* transactions rows */
.dn-actions button { margin-left: 4px; }

@media (max-width: 760px) {
  .inv-grid, .grid2 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .ladder-step { grid-template-columns: 22px 1fr; }
  .kv > div { grid-template-columns: 1fr; gap: 2px; }
  .filters .f, .filters input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .rt-node-wrap { flex-wrap: wrap; }
  .modal-wide { width: calc(100vw - 24px); }
}
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }

/* invoice detail / dunning: why retries are parked */
.park-callout {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 14px; padding: 10px 12px;
  border: 1px solid var(--warn); border-radius: 8px; background: var(--warn-bg); font-size: 0.8125rem; line-height: 1.45;
}
.park-callout.is-terminal { border-color: var(--bad); background: var(--bad-bg); }
.park-callout b { font-weight: 600; overflow-wrap: anywhere; }
.park-callout .sub2 { flex-basis: 100%; }
.ladder-step.is-paused .ladder-icon { background: var(--surface-2); color: var(--mut); border-color: var(--faint); }
.ladder-step.is-deferred .ladder-icon { background: var(--info-bg); color: #8a9aff; border-color: transparent; }
tr.is-parked td { background: var(--bad-bg); }
.inv-actions button[disabled] { cursor: not-allowed; }

/* Page header with an action on the right (Payment Routing → Configure Gateways). */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head h1 { margin: 0; }

/* Side drawer (Configure gateways on Payment Routing). Lives inside #view so the
   page's delegated click/submit handlers keep working for the buttons inside it. */
.drawer-host { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .22s ease; }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(1040px, 96vw); background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: -24px 0 48px rgba(0,0,0,.45); display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease; }
.drawer-host.open .drawer-backdrop { opacity: 1; }
.drawer-host.open .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.drawer-body { padding: 0 24px 32px; overflow: auto; flex: 1; }
.drawer-body > :first-child { margin-top: 20px; }
.drawer-body .panel { margin-top: 0; }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-backdrop { transition: none; } }

/* Divider heading between the two halves of a combined page (Declines → Dunning). */
.merged-section { font-size: 0.8125rem; letter-spacing: .07em; text-transform: uppercase; color: var(--ink); font-weight: 650; margin: 40px 0 16px; padding-top: 20px; border-top: 1px solid var(--line); }

/* Products → New plan: six fields on one full-width row, the button underneath. */
.plan-form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
.plan-form label { min-width: 0; }
.plan-form input, .plan-form select { width: 100%; height: var(--ctl-h); padding-top: 0; padding-bottom: 0; }
.plan-form-actions { grid-column: 1 / -1; padding-top: 4px; }
@media (max-width: 1100px) { .plan-form { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .plan-form { grid-template-columns: 1fr; } }

/* ---- sidebar search ---- */
.nav-search { padding: 0 2px 10px; }
.nav-search input { width: 100%; height: 32px; padding: 0 10px; font-size: 0.8125rem; background: var(--bg); }
.nav-search input::placeholder { color: var(--faint); }

/* ---- sortable columns ---- */
th:not(:empty) { cursor: pointer; user-select: none; }
th:not(:empty):hover { color: var(--accent); }
th.is-sorted-asc::after { content: ' ▲'; font-size: 0.6rem; color: var(--accent); }
th.is-sorted-desc::after { content: ' ▼'; font-size: 0.6rem; color: var(--accent); }

/* ---- time on hover ---- */
.t-rel, .t-abs { cursor: help; text-decoration: underline dotted transparent; }
.t-rel:hover, .t-abs:hover { text-decoration-color: var(--faint); }

/* ---- Home alert line + empty states ---- */
.home-alerts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -2px 0 18px; font-size: 0.8125rem; }
.home-alerts a { color: var(--ink); }
.empty-panel .body { color: var(--mut); line-height: 1.55; }
.empty-panel .body b { color: var(--ink); }

/* ---- row "···" menus ---- */
.rowmenu-wrap { display: inline-block; }
.rowmenu { display: none; }
button.kebab { padding: 2px 10px; font-weight: 700; letter-spacing: .05em; line-height: 1.3; }
button.kebab[aria-expanded="true"] { border-color: var(--accent); color: var(--ink); }
#rowmenu-host { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 36px rgba(0, 0, 0, .55); }
#rowmenu-host .menu { min-width: 200px; }
#rowmenu-host .mitem.is-danger { color: var(--bad); }
