/* RIFT (Rapid Intelligence Financial Tracking) - "midnight ledger" theme.
   Composition rules: the sidebar is the ledger's dark cover; the content is
   the paper inside, and the paper itself is the surface - one sheet per view,
   ruled hairlines, serif section rows. The dark ledger strip is the hero;
   each view adds its own masthead figure.
   Ink blue = leak money (the rift), green = recovered.
   Chart pair #2f63e8 / #0b7f66 on white. */

:root {
  --bg: #f6f6f2;
  --surface: #ffffff;
  --surface-2: #efefe8;
  --line: #e5e4db;
  --line-strong: #c9c8bc;
  --ink: #22231f;
  --ink-2: #55564f;
  --ink-3: #888a80;
  /* the ledger cover (blue-black) */
  --cover: #15171c;
  --cover-2: #1d2026;
  --cover-line: #2d3039;
  --cover-text: #9aa0ab;
  --cover-bright: #eef0f4;
  /* accent: leak money */
  --accent: #2f63e8;
  --accent-bright: #6d92ff;
  --accent-deep: #1e46b8;
  --accent-tint: rgba(47, 99, 232, 0.12);
  --accent-grad: linear-gradient(165deg, #6d92ff 0%, #2f63e8 55%, #1e46b8 100%);
  --recovered: #0b7f66;
  --recovered-bright: #3ecfa5;
  --warn: #b45309;
  --fail: #b3261e;
  --shadow: 0 1px 2px rgba(34, 35, 31, 0.05), 0 4px 14px rgba(34, 35, 31, 0.06);
  --shadow-lift: 0 2px 4px rgba(34, 35, 31, 0.06), 0 10px 28px rgba(34, 35, 31, 0.1);
  --serif: 'Fraunces', Georgia, serif;
  --mono: ui-monospace, 'Cascadia Mono', 'Consolas', monospace;
  --sans: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
/* reserve the scrollbar lane permanently - without this, tab switches make
   the scrollbar blink in/out and the whole layout (sidebar included) shifts
   sideways ~17px */
html { scrollbar-gutter: stable; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:active { transform: scale(0.98); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(109, 146, 255, 0.3); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes unfold  { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop     { 0% { transform: scale(0.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

/* ── lockup (canonical RIS pattern, on-cover variant) ── */
.lockup { display: inline-flex; flex-direction: column; line-height: 1.1; gap: 3px;
  text-decoration: none; color: var(--cover-bright); font-family: 'Syne', sans-serif;
  font-size: 1.12rem; font-weight: 700; letter-spacing: -0.02em; }
.lockup .lockup-top em { font-style: normal; background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.lockup .lockup-rule { display: flex; align-items: center; gap: 6px; }
.lockup .lockup-rule::before, .lockup .lockup-rule::after { content: ""; flex: 1; height: 1px; background: var(--cover-line); }
.lockup .lockup-sub { font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 0.52em; letter-spacing: 0.1em; color: var(--cover-text); }

/* ── product mark ── */
.product-mark { margin-top: 20px; display: flex; flex-direction: column; gap: 3px; }
.product-name { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.5rem;
  letter-spacing: 0.16em; background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: flex; align-items: center; gap: 8px; }
.product-name .ea-pill { font-family: var(--sans); font-weight: 700; font-size: 0.56rem;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--cover-text);
  -webkit-text-fill-color: var(--cover-text);
  border: 1px solid var(--cover-line); border-radius: 99px; padding: 2px 8px; }
.product-expansion { font-family: var(--serif); font-style: italic; font-size: 0.72rem;
  color: var(--cover-text); letter-spacing: 0.04em; }

/* ── login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
[hidden] { display: none !important; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 40px 36px 36px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow-lift); animation: fade-up 0.3s ease-out; position: relative; overflow: hidden; }
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: var(--accent-grad); }
.login-card .lockup { color: var(--ink); }
.login-card .lockup .lockup-rule::before, .login-card .lockup .lockup-rule::after { background: var(--line-strong); }
.login-card .lockup .lockup-sub { color: var(--ink-3); }
.login-card .product-mark { margin: 2px 0 10px; }
.login-card .product-name .ea-pill { color: var(--ink-3); -webkit-text-fill-color: var(--ink-3);
  border-color: var(--line-strong); }
.login-card .product-expansion { color: var(--ink-3); }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--ink-2); }
input, select { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 10px 12px; font: inherit; transition: border-color 0.15s, box-shadow 0.15s; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.btn-primary { background: var(--accent-grad); background-size: 130% 130%; background-position: 0% 0%;
  color: #fff; font-weight: 700; border-radius: 8px;
  padding: 11px 18px; transition: background-position 0.3s, box-shadow 0.2s, transform 0.1s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 3px rgba(30, 70, 184, 0.3); }
.btn-primary:hover { background-position: 90% 90%;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 12px rgba(30, 70, 184, 0.35); }
.form-error { color: var(--fail); font-size: 0.85rem; }
.legal-links { text-align: center; font-size: 0.72rem; color: var(--ink-3); margin-top: 2px; }
.legal-links a { color: var(--ink-3); text-decoration: underline; }
.legal-links a:hover { color: var(--ink); }

/* ── shell: cover + paper ── */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; padding: 30px 22px 24px;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  background: linear-gradient(175deg, var(--cover-2) 0%, var(--cover) 30%);
  color: var(--cover-text);
  /* short windows: scroll INSIDE the cover, never spill past its painted
     background onto the paper */
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-color: var(--cover-line) transparent; }
.sidebar-foot { flex-shrink: 0; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 26px; }
.nav-eyebrow { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--cover-text); opacity: 0.6; margin: 16px 12px 6px; }
.sidebar nav button { display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 9px 12px; border-radius: 9px; color: var(--cover-text);
  font-weight: 500; font-size: 0.92rem; transition: background 0.15s, color 0.15s; }
.sidebar nav button svg { flex-shrink: 0; opacity: 0.75; transition: opacity 0.15s; }
.sidebar nav button:hover { color: var(--cover-bright); background: rgba(255, 255, 255, 0.05); }
.sidebar nav button:hover svg { opacity: 1; }
.sidebar nav button.active { color: var(--accent-bright); background: var(--accent-tint); font-weight: 600; }
.sidebar nav button.active svg { opacity: 1; }
.nav-count { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 0.68rem; font-weight: 600; color: #fff; background: var(--accent);
  border-radius: 99px; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; font-size: 0.78rem; color: var(--cover-text);
  display: flex; flex-direction: column; gap: 6px; overflow-wrap: anywhere;
  border-top: 1px solid var(--cover-line); padding-top: 14px; }
.link-btn { color: var(--cover-text); text-decoration: underline; text-align: left; padding: 0; }
.link-btn:hover { color: var(--cover-bright); }

main { flex: 1; padding: 32px 48px 72px; max-width: 1020px; min-width: 0; }
.panel { animation: fade-up 0.22s ease-out; }

/* ── the ledger strip (signature): dark hero card on the paper ── */
.ledger-strip { display: flex; align-items: stretch; gap: 26px;
  background: linear-gradient(170deg, var(--cover-2) 0%, var(--cover) 55%);
  border: 1px solid var(--cover-line); border-radius: 16px; padding: 24px 28px 18px;
  margin-bottom: 26px; flex-wrap: wrap; color: var(--cover-text);
  box-shadow: 0 4px 10px rgba(21, 23, 28, 0.14), 0 14px 36px rgba(21, 23, 28, 0.16); }
.ledger-cell { display: flex; flex-direction: column; gap: 6px; }
.ledger-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--cover-text); }
.ledger-amount { font-family: var(--serif); font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum"; font-size: 2.1rem; font-weight: 600; letter-spacing: -0.01em;
  color: var(--cover-bright); line-height: 1.1; }
#stat-headline { color: var(--accent-bright); }
.ledger-amount.recovered { color: var(--recovered-bright);
  border-bottom: 3px double var(--recovered-bright); padding-bottom: 3px; align-self: flex-start; }
.ledger-amount.muted { color: var(--cover-text); font-weight: 500; }
/* excluded-but-real money: shown under the estimate so it can't hide */
.ledger-note { font-size: 0.72rem; color: #dfa94d; }
.ledger-rule { width: 1px; background: var(--cover-line); }
/* the strip's footer: a dashed ledger rule with the data window + sync control */
.ledger-sync { flex-basis: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; border-top: 1px dashed var(--cover-line); padding-top: 12px;
  margin-top: 8px; font-family: var(--serif); font-style: italic;
  color: var(--cover-text); font-size: 0.85rem; }
.sync-btn { font-family: var(--sans); font-style: normal; font-size: 0.8rem; font-weight: 600;
  color: var(--cover-bright); border: 1px solid var(--cover-line); border-radius: 99px; padding: 6px 16px;
  transition: all 0.15s; background: rgba(255, 255, 255, 0.04); }
.sync-btn:hover:not(:disabled) { color: #fff; border-color: var(--accent);
  background: var(--accent-tint); }
.sync-btn:disabled { opacity: 0.5; cursor: wait; }

/* ── confidence banner ── */
#confidence-banner { border: 1px solid var(--line); border-left: 4px solid var(--warn);
  background: var(--surface);
  border-radius: 10px; padding: 14px 18px; margin-bottom: 22px; font-size: 0.88rem;
  box-shadow: var(--shadow); animation: fade-up 0.2s ease-out; }
#confidence-banner.fail { border-left-color: var(--fail); }
#confidence-banner strong { display: block; margin-bottom: 4px; font-family: var(--serif); }
#confidence-banner ul { margin-left: 18px; color: var(--ink-2); }

/* ── masthead: title left, the view's one big number right ── */
.panel-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  flex-wrap: wrap; margin: 4px 0 16px; padding-bottom: 16px;
  border-bottom: 1px solid var(--line-strong); }
.panel-head h1 { font-family: var(--serif); font-weight: 600; font-size: 1.9rem;
  letter-spacing: -0.02em; line-height: 1.05; }
.panel-head .panel-sub { color: var(--ink-2); font-size: 0.85rem; margin-top: 7px;
  max-width: 520px; line-height: 1.5; }
.panel-figure { text-align: right; display: flex; flex-direction: column; gap: 3px;
  align-items: flex-end; }
.figure-label { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--ink-3); }
.figure-value { font-family: var(--serif); font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum"; font-size: 1.9rem; font-weight: 600; line-height: 1;
  color: var(--ink); }
.figure-value.leak { color: var(--accent); }
.hint { color: var(--ink-2); font-size: 0.85rem; line-height: 1.5; max-width: 620px; }
.field-hint { color: var(--ink-3); font-size: 0.72rem; font-weight: 400; line-height: 1.4; }

/* ── toolbar: segmented status filter / tab strip / sort ── */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn { padding: 6px 14px; border-radius: 7px; font-size: 0.82rem; color: var(--ink-2);
  transition: all 0.15s; }
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 3px rgba(34, 35, 31, 0.14); }
.tabstrip { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line-strong);
  margin-bottom: 20px; scrollbar-width: none; }
.tabstrip::-webkit-scrollbar { display: none; }
.tabstrip-wrap { position: relative; margin-bottom: 20px; }
.tabstrip-wrap .tabstrip { margin-bottom: 0; }
.strip-arrow { position: absolute; top: 0; bottom: 1px; width: 28px; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: var(--ink-2); }
.strip-arrow.left { left: 0; background: linear-gradient(90deg, var(--bg) 55%, transparent); }
.strip-arrow.right { right: 0; background: linear-gradient(270deg, var(--bg) 55%, transparent); }
.strip-arrow:hover { color: var(--accent-deep); }
.tab-btn { padding: 8px 12px 9px; font-size: 0.84rem; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s, border-color 0.15s; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--accent-deep); border-bottom-color: var(--accent); font-weight: 600; }
.chip { border: 1px solid var(--line-strong); border-radius: 99px; padding: 6px 14px;
  font-size: 0.82rem; color: var(--ink-2); transition: all 0.15s; background: var(--surface); }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip-n { font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 0.7rem; color: var(--ink-3); margin-left: 5px; }
.chip.active .chip-n, .tab-btn.active .chip-n { color: inherit; opacity: 0.75; }
.sort-select { margin-left: auto; border-radius: 99px; padding: 6px 12px; font-size: 0.82rem;
  color: var(--ink-2); }

/* ── the ledger sheet: one surface per view ── */
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; animation: unfold 0.2s ease-out; }
.sheet-sec { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left;
  padding: 14px 18px; background: var(--surface); border-top: 1px solid var(--line-strong);
  transition: background 0.15s; }
.sheet > .sheet-sec:first-child { border-top: none; }
.sheet-sec:hover { background: var(--surface-2); }
.sheet-sec h2 { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.sheet-sec .kind-count { font-size: 0.75rem; color: var(--ink-3); }
.sheet-sec .kind-chevron { color: var(--ink-3); font-size: 0.8rem; transition: transform 0.2s ease;
  display: inline-block; align-self: center; }
.sec-help { width: 16px; height: 16px; flex-shrink: 0; align-self: center;
  display: inline-grid; place-items: center; border: 1px solid var(--line-strong);
  border-radius: 99px; font-size: 0.66rem; font-weight: 600; color: var(--ink-3);
  cursor: help; transition: all 0.15s; }
.sheet-sec:hover .sec-help { border-color: var(--accent); color: var(--accent-deep); }
/* styled hover explanation: a small dark cover card */
.help-tip { position: fixed; z-index: 20; display: none; max-width: 320px;
  background: linear-gradient(170deg, var(--cover-2) 0%, var(--cover) 80%);
  color: var(--cover-bright); border: 1px solid var(--cover-line);
  border-radius: 10px; padding: 10px 14px; font-size: 0.8rem; line-height: 1.55;
  box-shadow: 0 6px 22px rgba(21, 23, 28, 0.35); pointer-events: none;
  animation: fade-up 0.15s ease-out; }
.sheet-sec.open .kind-chevron { transform: rotate(90deg); }
.sheet-sec .kind-sum { font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 0.9rem; font-weight: 600; color: var(--accent); }
.sec-meter { margin-left: auto; width: 46px; height: 3px; background: var(--surface-2);
  border-radius: 2px; align-self: center; overflow: hidden; flex-shrink: 0; }
.sec-meter > span { display: block; height: 100%; background: var(--accent-grad); }

/* discipline annotation, read from the clinician's real invoice items */
.disc-tag { font-family: var(--serif); font-style: italic; font-size: 0.8rem;
  color: var(--ink-3); }

/* mode tags (clinician billing mode) */
.mode-tag { font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; border-radius: 99px; padding: 3px 9px; align-self: center;
  background: var(--surface-2); color: var(--ink-2); }
.mode-tag.mixed { background: var(--accent-tint); color: var(--accent-deep); }
.mode-tag.external { background: rgba(180, 83, 9, 0.12); color: var(--warn); }
.mode-tag.none { background: var(--surface-2); color: var(--ink-3); }

/* item rows: ruled entries on the sheet */
.item-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px 11px 40px;
  border-top: 1px solid var(--line); background: var(--surface); transition: background 0.15s; }
.item-row:hover { background: var(--surface-2); }
.item-row .tick { width: 22px; height: 22px; flex-shrink: 0; border: 1.5px solid var(--line-strong);
  border-radius: 7px; display: grid; place-items: center; color: transparent;
  transition: all 0.15s; background: var(--surface); }
.item-row .tick:hover { border-color: var(--recovered); color: var(--recovered);
  box-shadow: 0 0 0 3px rgba(11, 127, 102, 0.12); }
.item-row.done .tick, .item-row.cleared .tick { border-color: var(--recovered); background: var(--recovered);
  color: #fff; animation: pop 0.25s ease-out; }
.item-row .item-main { min-width: 0; }
.item-row .item-title { font-size: 0.9rem; font-weight: 500; }
.item-row .item-client { font-size: 0.78rem; color: var(--ink-3); }
.item-row .item-amount { margin-left: auto; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 0.92rem; font-weight: 600; white-space: nowrap; }
.item-row.done .item-title, .item-row.dismissed .item-title { text-decoration: line-through; color: var(--ink-3); }
.item-row .dismiss { color: var(--ink-3); font-size: 1.05rem; padding: 2px 7px; border-radius: 6px;
  transition: all 0.15s; opacity: 0; }
/* quick action: one-click dismissal with a standard reason */
.item-row .row-act { font-size: 0.72rem; font-weight: 600; color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 99px; padding: 3px 10px;
  white-space: nowrap; transition: all 0.15s; opacity: 0; }
.item-row .row-act:hover { color: var(--accent-deep); border-color: var(--accent);
  background: var(--accent-tint); }
.item-row:hover .dismiss, .item-row .dismiss:focus-visible,
.item-row:hover .row-act, .item-row .row-act:focus-visible { opacity: 1; }
@media (hover: none) { .item-row .dismiss, .item-row .row-act { opacity: 1; } }
.item-row .dismiss:hover { color: var(--fail); background: rgba(179, 38, 30, 0.08); }
.item-row .reason { font-size: 0.75rem; color: var(--ink-3); font-style: italic; }
.item-row .verify-hint { font-size: 0.75rem; color: var(--warn); margin-top: 2px; }
/* inline dismiss-reason form, slides out under its row */
.dismiss-form { display: flex; gap: 8px; align-items: center; padding: 10px 18px 12px 40px;
  background: var(--surface-2); border-top: 1px solid var(--line);
  animation: unfold 0.15s ease-out; }
.dismiss-form input { flex: 1; padding: 7px 10px; font-size: 0.85rem; }
.btn-small { background: var(--ink); color: #fff; font-size: 0.8rem; font-weight: 600;
  border-radius: 7px; padding: 7px 14px; transition: background 0.15s; }
.btn-small:hover { background: #000; }
.btn-ghost { color: var(--ink-3); font-size: 0.82rem; }
.btn-ghost:hover { color: var(--ink); }

/* clinician profile body, inset on the sheet */
.profile-body { padding: 18px 20px 20px; border-top: 1px solid var(--line);
  background: #fbfbf8; animation: unfold 0.2s ease-out; }
.profile-body label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem;
  font-weight: 500; color: var(--ink-2); margin: 12px 0; max-width: 380px; }

.empty-note { display: block; color: var(--ink-3); font-family: var(--serif); font-style: italic;
  font-size: 1rem; text-align: center; border: 1px dashed var(--line-strong); border-radius: 12px;
  padding: 36px 20px 40px; margin-top: 4px; }
.empty-note::before { content: "\2766"; display: block; font-size: 1.4rem; margin-bottom: 10px;
  opacity: 0.45; font-style: normal; }

/* ── tables (buckets, trends, clients) ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { text-align: left; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line-strong);
  background: var(--surface-2); }
.data-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2);
  transition: background 0.15s; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink); }
.data-table th.num { text-align: right; }
.data-table td input, .data-table td select { padding: 6px 9px; font-size: 0.83rem; border-radius: 6px; }
.data-table td input { width: 100%; min-width: 150px; }
.table-wrap { border: 1px solid var(--line); border-radius: 14px; overflow-x: auto;
  background: var(--surface); box-shadow: var(--shadow); animation: unfold 0.2s ease-out; }
.table-cap { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  font-family: var(--serif); font-weight: 600; font-size: 0.98rem; }
.table-cap .cap-n { font-family: var(--sans); font-weight: 400; font-size: 0.75rem;
  color: var(--ink-3); white-space: nowrap; }
.cap-tools { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.cap-filter { padding: 5px 11px; font-size: 0.78rem; font-family: var(--sans); font-weight: 400;
  border-radius: 99px; width: 170px; }

/* bucket tables: caption stays put, rows scroll inside the card */
.table-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  box-shadow: var(--shadow); overflow: hidden; animation: unfold 0.2s ease-out; }
.table-scroll { max-height: 64vh; overflow: auto; }
.table-scroll .data-table th { position: sticky; top: 0; z-index: 1; }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--ink); }
.data-table th .sort-arrow { margin-left: 4px; font-size: 0.6rem; }
.data-table tr.dim td { opacity: 0.55; }
.data-table td.warn-num { color: var(--warn); font-weight: 600; }
.data-table td.nowrap { white-space: nowrap; }
.data-table td.warn-cell { color: var(--warn); text-align: center; cursor: help; }
/* client rule registry */
.data-table tr.add-row td { background: var(--surface-2); border-bottom: 1px solid var(--line-strong); }
.data-table tr.removed td { opacity: 0.5; }
.data-table tr.removed td:first-child { text-decoration: line-through; }
.data-table .row-x { color: var(--ink-3); font-size: 1.02rem; padding: 2px 8px;
  border-radius: 6px; transition: all 0.15s; }
.data-table .row-x:hover { color: var(--fail); background: rgba(179, 38, 30, 0.08); }
.data-table td.hint { padding: 22px 14px; text-align: center; font-family: var(--serif);
  font-style: italic; color: var(--ink-3); }

/* ── trends chart ── */
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.chart-card svg { display: block; }
.chart-card rect { transition: opacity 0.15s; }
.chart-card rect:hover { opacity: 0.85; }
.chart-legend { display: flex; gap: 18px; font-size: 0.8rem; color: var(--ink-2); margin-bottom: 12px; }
.chart-legend .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart-legend .swatch.dash { height: 0; border-radius: 0; background: transparent;
  border-top: 2px dashed #dfa94d; vertical-align: middle; }
.data-table td.warn { color: var(--warn); font-style: italic; font-size: 0.78rem; }
.chart-tip { position: fixed; pointer-events: none; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 8px 10px; font-size: 0.78rem; z-index: 10; display: none;
  box-shadow: var(--shadow-lift); }
.chart-tip .num { font-family: var(--mono); font-weight: 600; }

/* ── settings: ruled sheets, label left / control right ── */
.settings-sheet { margin-bottom: 22px; max-width: 760px; }
.sheet-sec.static { cursor: default; }
.sheet-sec.static:hover { background: var(--surface); }
.set-row { display: flex; gap: 24px; align-items: center; justify-content: space-between;
  padding: 13px 18px; border-top: 1px solid var(--line); }
.set-info { display: flex; flex-direction: column; gap: 3px; max-width: 400px; }
.set-label { font-size: 0.86rem; font-weight: 500; }
.set-static { font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: 0.95rem; }
.set-ctl { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.set-ctl input[type="number"] { width: 92px; }
.set-ctl input[type="date"] { width: 155px; }
.set-ctl input:not([type="number"]):not([type="date"]):not([type="checkbox"]) { width: 250px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.save-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px;
  padding: 14px 0 12px; background: linear-gradient(transparent, var(--bg) 40%); }
.foot-name { color: var(--cover-bright); font-weight: 600; }
.settings-actions { margin-top: 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.save-note { font-size: 0.82rem; color: var(--recovered); }
.save-note.err { color: var(--fail); }

/* ── outbox (the action layer) ── */
.outbox-sheet { margin-bottom: 22px; }
.outbox-notice { border: 1px solid var(--line); border-left: 4px solid var(--ink-3);
  background: var(--surface); border-radius: 10px; padding: 12px 16px; margin-bottom: 18px;
  font-size: 0.85rem; color: var(--ink-2); box-shadow: var(--shadow); }
.outbox-notice.paused { border-left-color: var(--warn); }
.outbox-row { padding-left: 18px; }
.outbox-row input[type="checkbox"] { flex-shrink: 0; }
.outbox-row .row-act { opacity: 1; }
.outbox-row .row-act.primary { color: #fff; background: var(--accent-grad);
  border-color: transparent; font-weight: 700; }
.outbox-row .row-act.primary:hover { box-shadow: 0 2px 8px rgba(30, 70, 184, 0.35); color: #fff; }
.bulk-bar { display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.bulk-bar .btn-small:disabled { opacity: 0.45; cursor: default; }
/* email state chip on Leaks/Follow-ups rows */
.email-chip { font-size: 0.72rem; color: var(--accent-deep); margin-top: 2px; }
.email-chip.call { color: var(--warn); font-weight: 600; }
.email-chip.skip { color: var(--ink-3); font-style: italic; }
/* review modal */
.modal-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center;
  background: rgba(21, 23, 28, 0.45); padding: 20px; animation: fade-up 0.15s ease-out; }
.modal-card { width: 100%; max-width: 620px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 26px 28px; box-shadow: var(--shadow-lift); display: flex;
  flex-direction: column; gap: 14px; }
.modal-card h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.modal-meta { font-size: 0.83rem; color: var(--ink-2); display: flex;
  flex-direction: column; gap: 3px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.modal-body { min-height: 220px; resize: vertical; font: inherit; font-size: 0.9rem;
  line-height: 1.5; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 12px 14px; }
.modal-body:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
/* template editor */
.template-explainer { margin: -8px 0 18px; }
.template-sheet .template-body { padding: 16px 18px 4px; border-top: 1px solid var(--line); }
.template-sheet label { display: flex; flex-direction: column; gap: 6px; font-size: 0.82rem;
  font-weight: 500; color: var(--ink-2); margin-bottom: 14px; }
.template-text { min-height: 240px; resize: vertical; font: inherit; font-size: 0.9rem;
  line-height: 1.5; border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 12px 14px; background: var(--surface); color: var(--ink); }
.template-text:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.template-actions { padding: 0 18px 18px; margin-top: 4px; }
.template-actions input { width: 230px; }
.template-actions .row-act { opacity: 1; }
/* hour wheel: scroll-to-pick time, iOS-style, on ledger paper */
.hour-wheel { position: relative; width: 108px; height: 78px; overflow: hidden;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  user-select: none; }
.hour-wheel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wheel-list { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory;
  padding: 26px 0; scrollbar-width: none; }
.wheel-list::-webkit-scrollbar { display: none; }
.wheel-item { height: 26px; line-height: 26px; text-align: center; scroll-snap-align: center;
  font-size: 0.78rem; color: var(--ink-3); cursor: pointer; transition: color 0.15s; }
.wheel-item:hover { color: var(--ink); }
.wheel-item.active { color: var(--accent-deep); font-family: var(--serif);
  font-weight: 600; font-size: 0.94rem; font-variant-numeric: lining-nums; }
/* the selection band: two ruled hairlines, like a ledger row */
.wheel-band { position: absolute; top: 26px; left: 8px; right: 8px; height: 26px;
  border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong);
  pointer-events: none; }
/* fade the neighbours out at the edges */
.hour-wheel::before, .hour-wheel::after { content: ""; position: absolute; left: 1px;
  right: 1px; height: 22px; pointer-events: none; z-index: 1; }
.hour-wheel::before { top: 1px; background: linear-gradient(var(--surface) 25%, transparent); border-radius: 9px 9px 0 0; }
.hour-wheel::after { bottom: 1px; background: linear-gradient(transparent, var(--surface) 75%); border-radius: 0 0 9px 9px; }

/* per-email-type mode switch: Off | Approve each | Automatic */
.mode-ctl { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.mode-seg .seg-btn:first-child.active { background: var(--surface); color: var(--ink-2); }
.cadence-ctl { display: flex; gap: 8px; align-items: center; transition: opacity 0.15s; }
.cadence-ctl input[type="number"] { width: 64px; }
.cadence-ctl.dim { opacity: 0.4; }

/* signature editor */
.sig-mode-seg { align-self: flex-start; }
.sig-text { min-height: 120px; }
.sig-builder input:not([type="color"]) { max-width: 380px; }
.sig-builder input[type="color"] { width: 52px; height: 34px; padding: 3px; cursor: pointer; }
.sig-upload-row { display: flex; gap: 10px; align-items: center; }
.sig-upload-row .row-act { opacity: 1; }
.sig-drop { flex: 1; max-width: 380px; border: 1.5px dashed var(--line-strong);
  border-radius: 10px; padding: 16px 14px; text-align: center; cursor: pointer;
  color: var(--ink-2); font-size: 0.82rem; transition: border-color 0.15s, background 0.15s; }
.sig-drop:hover { border-color: var(--accent); color: var(--ink); }
.sig-drop.over { border-color: var(--accent); background: var(--accent-tint); color: var(--accent-deep); }
.sig-preview { margin: 6px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.sig-preview-box { border: 1px dashed var(--line-strong); border-radius: 10px;
  padding: 18px 20px; background: #fffdf8; }
.sig-prev-text { white-space: pre-line; font-size: 0.9rem; }
.sig-prev-img { max-width: 420px; height: auto; display: block; margin-top: 12px; }
.sig-prev-card { display: flex; gap: 16px; padding-top: 12px; max-width: 460px; }
.sig-prev-logo { max-height: 56px; max-width: 160px; display: block; }
.sig-prev-lines { display: flex; flex-direction: column; gap: 2px; font-size: 0.84rem; }
.sig-prev-lines em { color: var(--ink-2); }
.sig-prev-addr { color: var(--ink-3); }

/* sender domain setup */
.domain-status { font-family: var(--sans); font-weight: 500; font-size: 0.84rem; }
.dns-records { width: 100%; }
.dns-records .hint { margin-bottom: 10px; }
.dns-table { font-size: 0.78rem; }
.dns-table td.mono-cell { font-family: var(--mono); font-size: 0.72rem; word-break: break-all; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
    flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
  .sidebar nav { flex-direction: row; margin-top: 0; margin-left: auto; flex-wrap: wrap; }
  .nav-eyebrow { display: none; }
  .product-mark { margin-top: 0; }
  .product-expansion { display: none; }
  .sidebar-foot { display: none; }
  main { padding: 18px 14px 48px; }
  .ledger-amount { font-size: 1.5rem; }
  .set-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .set-ctl { flex-wrap: wrap; }
  .panel-head h1 { font-size: 1.5rem; }
  .figure-value { font-size: 1.5rem; }
  .item-row { padding-left: 18px; }
  .dismiss-form { padding-left: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
