/* ============================================================
   Affiliate Raccoon — monochrome, document-grade UI
   Strictly grayscale. Helvetica/Swiss. Airy. Tabular numerals.
   ============================================================ */

:root {
  /* Type */
  --font: "Helvetica Neue", Helvetica, Arial, "Segoe UI", Roboto, sans-serif;

  /* Grayscale ink + paper (neutral, no tint) */
  --paper:      #ffffff;
  --paper-2:    #fafafa;
  --paper-3:    #f4f4f4;
  --line:       #e7e7e7;
  --line-2:     #dadada;
  --line-3:     #c6c6c6;
  --ink:        #121212;
  --ink-2:      #34343a;  /* faintest cool tint, near-neutral */
  --muted:      #6e6e72;
  --faint:      #9a9a9e;

  /* Geometry — tweakable */
  --radius: 4px;
  --radius-lg: 6px;

  /* Density — tweakable scale (1 = airy) */
  --scale: 1;
  --gap: calc(28px * var(--scale));
  --pad-card: calc(30px * var(--scale));
  --row-pad: calc(18px * var(--scale));

  --shadow: 0 1px 2px rgba(18,18,18,.04), 0 10px 30px rgba(18,18,18,.06);
  --shadow-pop: 0 18px 60px rgba(18,18,18,.18), 0 2px 8px rgba(18,18,18,.08);

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper-3);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "kern" 1;
}

body { min-height: 100vh; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--ink); color: var(--paper); }

/* ---------- eyebrow / labels ---------- */
.eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
}

/* ============================================================
   App shell
   ============================================================ */
.app { display: none; }
.app.is-active { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px clamp(20px, 4vw, 40px);
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line-2);
  flex: none;
  object-fit: cover;
}
.brand-mark.hide-mascot, .login-mark.hide-mascot { display: none; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { color: var(--faint); font-size: 12px; font-weight: 500; margin-top: 1px; }

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.role-chip {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
  border: 1px solid var(--line-2);
  padding: 5px 10px; border-radius: 100px;
}

/* account menu */
.acct {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-2); background: var(--paper);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: var(--ink-2);
}

/* ============================================================
   Page canvas
   ============================================================ */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(28px, 4vw, 52px) clamp(20px, 4vw, 40px) 120px;
}
.page--narrow { max-width: 760px; }

.page-head { margin-bottom: var(--gap); }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 0; }
.page-desc { color: var(--muted); font-size: 14px; margin: 8px 0 0; max-width: 52ch; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 600; letter-spacing: -.005em;
  padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  transition: transform .04s ease, background .15s ease, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: #2b2b2b; border-color: #2b2b2b; }

.btn--ghost { background: var(--paper); color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { background: var(--paper-3); border-color: var(--line-3); }

.btn--text {
  background: transparent; border-color: transparent; color: var(--muted);
  padding: 8px 10px;
}
.btn--text:hover { background: var(--paper-3); color: var(--ink); }

.btn--sm { padding: 7px 11px; font-size: 12.5px; }
.btn--lg { padding: 13px 20px; font-size: 15px; }
.btn--block { width: 100%; justify-content: center; }

.btn[disabled] { opacity: .4; pointer-events: none; }

.iconbtn {
  width: 34px; height: 34px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--paper); color: var(--ink-2);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.iconbtn:hover { background: var(--paper-3); border-color: var(--line-3); }

/* ============================================================
   KPI strip
   ============================================================ */
.kpis {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: var(--gap);
}
.kpi { padding: calc(26px * var(--scale)) calc(28px * var(--scale)); border-left: 1px solid var(--line); }
.kpi:first-child { border-left: 0; }
.kpi-label { display: flex; align-items: center; gap: 7px; }
.kpi-value { margin-top: 14px; font-weight: 700; letter-spacing: -.03em; line-height: 1; color: var(--ink); }
.kpi--hero .kpi-value { font-size: clamp(40px, 5vw, 60px); }
.kpi--hero .kpi-cur { font-size: .5em; font-weight: 600; color: var(--muted); margin-right: 4px; vertical-align: 6%; }
.kpi-value { font-size: 30px; }
.kpi-meta { margin-top: 10px; font-size: 12.5px; color: var(--faint); }
.kpi-delta { font-weight: 600; color: var(--ink-2); }

/* ============================================================
   Panel / card
   ============================================================ */
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; gap: 14px;
  padding: calc(20px * var(--scale)) var(--pad-card);
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.panel-head .sub { color: var(--faint); font-size: 12.5px; font-weight: 500; }
.panel-head .spacer { flex: 1; }

/* ============================================================
   Affiliate table
   ============================================================ */
.tablewrap { width: 100%; overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; min-width: 880px; }
.grid thead th {
  text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
  padding: 14px 13px;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
  background: var(--paper);
}
.grid tbody td {
  padding: var(--row-pad) 13px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-2);
  vertical-align: middle;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr { transition: background .12s ease; cursor: pointer; }
.grid tbody tr:hover { background: var(--paper-2); }
.num-col { text-align: right; font-variant-numeric: tabular-nums; }
th.num-col { text-align: right; }

/* table style variants (tweakable) */
.grid--zebra tbody tr:nth-child(even) { background: var(--paper-2); }
.grid--zebra tbody tr:hover { background: var(--paper-3); }
.grid--borderless tbody td { border-bottom: 0; }
.grid--borderless thead th { border-bottom-color: var(--line); }

.cell-name { font-weight: 600; color: var(--ink); white-space: nowrap; }
.grid tbody tr:hover .cell-name { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line-3); }
.muted-act { font-size: 12px; color: var(--faint); font-style: italic; white-space: nowrap; }
.cell-dash { color: var(--line-3); }

/* black invoice buttons (manager status column + affiliate list) — echo the Paid pill */
.btn-inv {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: var(--paper);
  border: 1px solid var(--ink);
  font-size: 12px; font-weight: 600; letter-spacing: -.005em;
  padding: 7px 14px; border-radius: 100px; white-space: nowrap;
  transition: background .15s, transform .04s;
}
.btn-inv:hover { background: #2b2b2b; }
.btn-inv:active { transform: translateY(1px); }
.btn-inv--lg { font-size: 13px; padding: 9px 18px; }

/* big generate button at the foot of the invoice document */
.btn-generate {
  width: 100%; border: 0; background: var(--ink); color: var(--paper);
  font-size: 15.5px; font-weight: 700; letter-spacing: -.01em;
  padding: 20px; cursor: pointer;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transition: background .15s;
}
.btn-generate:hover { background: #2b2b2b; }
.btn-generate:active { transform: translateY(1px); }

/* affiliate invoice list tags */
.inv-tag { font-size: 12px; font-weight: 600; color: var(--muted); }
.inv-current { color: var(--faint); font-weight: 600; font-size: 12px; }
.invrow--current { background: var(--paper-2); }
.invrow--current .inv-amt { color: var(--muted); }

/* period picker */
.periodbar { display: flex; align-items: center; gap: 8px; }
.period-selects { display: flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; transition: opacity .15s; }
.period-selects.off { opacity: .4; pointer-events: none; }
.period-sel {
  border: 0; background: var(--paper); color: var(--ink);
  font-size: 12.5px; font-weight: 600; padding: 8px 10px;
  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' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236e6e72' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 26px;
}
.period-sel#period-month { border-right: 1px solid var(--line-2); }
.period-sel:focus { outline: none; background-color: var(--paper-3); }
.period-all {
  border: 1px solid var(--line-2); background: var(--paper); color: var(--muted);
  font-size: 12.5px; font-weight: 600; padding: 8px 13px; border-radius: var(--radius);
  transition: background .15s, color .15s, border-color .15s;
}
.period-all:hover { border-color: var(--line-3); color: var(--ink); }
.period-all.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* current-month in-progress note */
.current-note {
  display: flex; align-items: center; gap: 10px;
  padding: 12px var(--pad-card);
  font-size: 12.5px; color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--paper-2);
}
.current-note .cn-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); flex: none;
  box-shadow: 0 0 0 3px rgba(52,52,58,.12);
}

/* info note (invite modal) */
.infonote {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; margin-top: 16px;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.55;
}
.infonote-mark {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: var(--paper); font-size: 11px; font-weight: 700;
  display: grid; place-items: center; margin-top: 1px;
}

/* mini stats (edit modal) */
.mini-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 24px;
}
.mini-stats .ms { padding: 14px 16px; border-left: 1px solid var(--line); }
.mini-stats .ms:first-child { border-left: 0; }
.mini-stats .ms .l { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.mini-stats .ms .v { font-size: 19px; font-weight: 700; margin-top: 7px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

/* read-only partner details (edit modal) */
.ro-grid { display: flex; flex-direction: column; gap: 16px; }
.ro-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ro-l { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.ro-hint { font-weight: 500; color: var(--faint); font-size: 11.5px; margin-left: 6px; }
.ro-v {
  font-size: 14px; color: var(--ink); padding: 11px 13px;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); min-height: 42px;
}
.ro-v.num { font-variant-numeric: tabular-nums; }
.grid th:first-child, .grid td:first-child { min-width: 160px; padding-left: 24px; }
.grid th:last-child, .grid td:last-child { padding-right: 24px; text-align: left; }
.cell-firm { font-size: 12px; color: var(--faint); margin-top: 2px; font-weight: 500; white-space: nowrap; }

.code-chip {
  display: inline-flex; align-items: center; gap: 0;
  font-weight: 700; letter-spacing: .02em; color: var(--ink);
  font-size: 13px;
}
.code-disc { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.dotsep { color: var(--line-3); margin: 0 7px; }

.rate-strong { font-weight: 700; color: var(--ink); }
.type-tag { font-size: 12px; color: var(--muted); }

/* status pills (grayscale progression) */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 4px 10px; border-radius: 100px; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--draft   { color: var(--faint); border: 1px dashed var(--line-3); background: transparent; }
.pill--pending { color: var(--muted); border: 1px dashed var(--line-3); background: var(--paper-2); }
.pill--accruing { color: var(--ink-2); border: 1px solid var(--line-2); background: var(--paper); }
.pill--accruing .dot { background: var(--ink-2); animation: accpulse 1.8s ease-in-out infinite; }
@keyframes accpulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.pill--issued  { color: var(--ink); border: 1px solid var(--line-3); background: var(--paper); }
.pill--accepted{ color: var(--ink-2); background: var(--paper-3); border: 1px solid var(--line); }
.pill--paid    { color: var(--paper); background: var(--ink); }
.pill--disputed{ color: var(--ink); background: transparent; border: 1.5px solid var(--ink); font-weight: 700; }

/* row actions */
.rowacts { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.linkbtn {
  background: none; border: 0; padding: 6px 8px; border-radius: var(--radius);
  font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap;
  transition: background .12s, color .12s;
}
.linkbtn:hover { background: var(--paper-3); color: var(--ink); }
.linkbtn--primary { color: var(--ink); }

/* ============================================================
   Unattributed redemptions (quiet zone)
   ============================================================ */
.quietzone { margin-top: var(--gap); }
.quiet {
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-lg);
  background: var(--paper-2);
  padding: calc(20px * var(--scale)) var(--pad-card);
}
.quiet-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.quiet-head h3 { font-size: 13.5px; font-weight: 700; margin: 0; color: var(--ink-2); }
.quiet-count {
  font-size: 11px; font-weight: 700; color: var(--paper); background: var(--ink-2);
  padding: 2px 8px; border-radius: 100px;
}
.quiet-row {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
  padding: 12px 0; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}
.quiet-row:first-of-type { border-top: 0; }
.quiet-row .store { font-weight: 600; color: var(--ink); }
.quiet-row .meta { color: var(--faint); font-size: 12px; }
.quiet-amt { display: inline-flex; align-items: baseline; gap: 12px; }
.quiet-amt b { font-weight: 700; color: var(--ink); }
.assign {
  border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--paper);
  padding: 7px 10px; font-size: 12.5px; color: var(--ink); min-width: 150px;
}

/* ============================================================
   Affiliate page — code block
   ============================================================ */
.codeblocks { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: var(--gap); }
.codeblocks .codeblock { margin-bottom: 0; height: 100%; }
@media (max-width: 620px) { .codeblocks { grid-template-columns: 1fr; } }

.codeblock {
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius-lg);
  padding: calc(34px * var(--scale)) var(--pad-card);
  box-shadow: var(--shadow);
  margin-bottom: var(--gap);
}
.codeblock .eyebrow { color: rgba(255,255,255,.55); }
.codeline { display: flex; align-items: center; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.codeval {
  font-size: clamp(30px, 5vw, 44px); font-weight: 700; letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
}
.copybtn {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); color: var(--paper);
  border: 1px solid rgba(255,255,255,.22); border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.copybtn:hover { background: rgba(255,255,255,.2); }
.copybtn.copied { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.codedisc { margin-top: 16px; font-size: 14px; color: rgba(255,255,255,.72); }
.codedisc b { color: var(--paper); font-weight: 600; }

/* affiliate numbers — three stat cards */
.statrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow); margin-bottom: var(--gap); }
.stat { padding: calc(24px * var(--scale)) var(--pad-card); border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 12px; }
.stat-cur { font-size: .55em; color: var(--muted); font-weight: 600; margin-right: 3px; }
.stat-meta { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* invoice list */
.invlist { }
.invrow {
  display: grid; grid-template-columns: 1fr 120px 132px; gap: 20px; align-items: center;
  padding: var(--row-pad) var(--pad-card);
  border-bottom: 1px solid var(--line);
  cursor: pointer; transition: background .12s;
}
.invrow:hover { background: var(--paper-2); }
.invrow:last-child { border-bottom: 0; }
.inv-period { font-weight: 600; color: var(--ink); font-size: 14px; }
.inv-num { font-size: 12px; color: var(--faint); margin-top: 2px; }
.inv-amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; text-align: right; }
.invrow .right { text-align: left; }
.inv-cur { color: var(--muted); font-weight: 600; font-size: .8em; }

/* ============================================================
   Modals
   ============================================================ */
.scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20,20,22,.42);
  backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center;
  padding: clamp(20px, 6vh, 60px) 20px;
  overflow-y: auto;
}
.scrim.is-open { display: flex; }
.scrim[data-locked] { } /* onboarding gate — no click-out */

.modal {
  width: 100%; max-width: 560px;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  animation: pop .22s cubic-bezier(.2,.8,.25,1);
}
.modal--wide { max-width: 680px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 26px var(--pad-card) 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 18px; font-weight: 700; margin: 2px 0 0; letter-spacing: -.01em; }
.modal-head .sub { font-size: 13px; color: var(--muted); margin-top: 6px; }
.modal-head .spacer { flex: 1; }
.modal-x {
  width: 32px; height: 32px; border-radius: var(--radius); border: 1px solid transparent;
  background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 18px;
}
.modal-x:hover { background: var(--paper-3); color: var(--ink); }

.modal-body { padding: 22px var(--pad-card); }
.modal-foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 18px var(--pad-card); border-top: 1px solid var(--line);
  background: var(--paper-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-foot .spacer { flex: 1; }

/* forms */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field .hint { font-size: 11.5px; color: var(--faint); font-weight: 500; margin-left: 6px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius);
  padding: 11px 13px; font-size: 13.5px; color: var(--ink); background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(18,18,18,.07);
}
.textarea { resize: vertical; min-height: 84px; line-height: 1.55; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row--3 { grid-template-columns: 1fr 1fr 1fr; }

.inputgroup { display: flex; }
.inputgroup .input { border-radius: var(--radius) 0 0 var(--radius); }
.inputgroup .addon {
  display: grid; place-items: center; padding: 0 13px;
  border: 1px solid var(--line-2); border-left: 0; border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--paper-3); color: var(--muted); font-size: 13px; font-weight: 600;
}

/* segmented radio (type, currency) */
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: block; padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-left: 1px solid var(--line-2); transition: background .12s, color .12s;
}
.segmented label:first-child span { border-left: 0; }
.segmented input:checked + span { background: var(--ink); color: var(--paper); }

/* checkbox */
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.check input { position: absolute; opacity: 0; }
.check .box {
  width: 20px; height: 20px; border: 1.5px solid var(--line-3); border-radius: 4px;
  flex: none; display: grid; place-items: center; margin-top: 1px; transition: background .12s, border-color .12s;
}
.check input:checked + .box { background: var(--ink); border-color: var(--ink); }
.check input:checked + .box::after { content: "✓"; color: #fff; font-size: 13px; font-weight: 700; }
.check .txt { font-size: 13px; color: var(--ink-2); line-height: 1.55; }

/* settings — fee rows */
.feerow { display: grid; grid-template-columns: 1fr 120px 36px; gap: 10px; align-items: center; margin-bottom: 10px; }
.feerow .iconbtn { width: 36px; height: 38px; }

.divider { height: 1px; background: var(--line); margin: 24px 0; }
.section-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); margin: 0 0 14px; }

/* connection row */
.connrow { display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.connrow .ci { display: flex; align-items: center; gap: 12px; }
.connrow .cn { font-weight: 600; font-size: 13.5px; }
.connrow .cs { font-size: 12px; color: var(--faint); margin-top: 2px; }
.conn-ok { font-size: 11.5px; font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.conn-ok .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }

/* ============================================================
   Self-billed invoice document (A4 sheet)
   ============================================================ */
.docmodal { max-width: 720px; width: 100%; }
.sheet {
  background: var(--paper); color: var(--ink);
  padding: clamp(34px, 5vw, 56px);
}
.sheet-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; }
.doc-badge {
  display: inline-block; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  font-weight: 700; color: var(--ink); border: 1.5px solid var(--ink);
  padding: 6px 11px; border-radius: 3px;
}
.doc-issuer { text-align: right; }
.doc-issuer .nm { font-weight: 700; font-size: 15px; }
.doc-issuer .ad { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 6px; }

.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 40px; }
.doc-meta .lab { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin-bottom: 8px; }
.doc-party .nm { font-weight: 700; font-size: 14px; }
.doc-party .ad { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin-top: 5px; }

.doc-numrow { display: flex; gap: 40px; margin-top: 30px; padding: 18px 0; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); }
.doc-numrow .item .lab { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.doc-numrow .item .val { font-size: 14px; font-weight: 600; margin-top: 6px; font-variant-numeric: tabular-nums; }
.doc-numrow .item .val input {
  border: 0; border-bottom: 1px dashed var(--line-3); padding: 0 0 3px; font-size: 14px; font-weight: 600;
  font-family: inherit; width: 150px; color: var(--ink);
}
.doc-numrow .item .val input:focus { outline: none; border-bottom-color: var(--ink); }

.doc-lines { width: 100%; border-collapse: collapse; margin-top: 30px; }
.doc-lines th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
.doc-lines th:last-child, .doc-lines td:last-child { text-align: right; }
.doc-lines td { padding: 16px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.doc-lines .desc { font-weight: 600; color: var(--ink); }
.doc-lines .desc small { display: block; font-weight: 500; color: var(--faint); font-size: 11.5px; margin-top: 3px; }
.doc-lines .amt { font-variant-numeric: tabular-nums; font-weight: 600; }

.doc-totals { margin-top: 22px; margin-left: auto; width: 280px; }
.doc-totals .tr { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; color: var(--muted); }
.doc-totals .tr .v { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.doc-totals .grand { border-top: 1.5px solid var(--ink); margin-top: 6px; padding-top: 14px; }
.doc-totals .grand .l { font-weight: 700; color: var(--ink); font-size: 14px; }
.doc-totals .grand .v { font-weight: 700; color: var(--ink); font-size: 19px; }
.doc-foot { margin-top: 40px; font-size: 11.5px; color: var(--faint); line-height: 1.7; border-top: 1px solid var(--line); padding-top: 18px; }

.vat-toggle { display: flex; align-items: center; gap: 12px; margin-top: 22px; padding: 14px 16px; background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius); }
.vat-toggle .lab { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.vat-toggle .grow { flex: 1; }
.vat-toggle input[type=number] { width: 64px; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 6px 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.vat-toggle .note { font-size: 11px; color: var(--faint); }

/* tiny switch */
.switch { position: relative; width: 40px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { position: absolute; inset: 0; background: var(--line-3); border-radius: 100px; transition: background .16s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .16s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track + .knob { transform: translateX(18px); }

/* ============================================================
   Login
   ============================================================ */
#login {
  min-height: 100vh; display: none; place-items: center;
  padding: 40px 20px;
  background:
    radial-gradient(120% 120% at 50% -20%, #ffffff 0%, #f0f0f0 60%, #e8e8e8 100%);
}
#login.is-active { display: grid; }
.login-card {
  width: 100%; max-width: 400px; background: var(--paper);
  border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-pop); padding: 40px 36px 32px; text-align: center;
}
.login-mark { width: 76px; height: 76px; border-radius: 50%; border: 1px solid var(--line-2); margin: 0 auto 18px; display: block; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.login-card .tag { color: var(--muted); font-size: 13.5px; margin: 8px 0 28px; }
.login-card .field { text-align: left; margin-bottom: 14px; }
.login-roles { display: grid; gap: 10px; margin-top: 4px; }
.login-foot { margin-top: 22px; font-size: 12px; color: var(--faint); }
.login-demo { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 600; margin: 26px 0 12px; display: flex; align-items: center; gap: 12px; }
.login-demo::before, .login-demo::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ============================================================
   Tweaks panel (host-toggled, monochrome)
   ============================================================ */
#tweaks {
  position: fixed; right: 22px; bottom: 22px; z-index: 300;
  width: 264px; background: var(--paper);
  border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: var(--shadow-pop);
  display: none; overflow: hidden;
  font-family: var(--font);
}
#tweaks.is-open { display: block; animation: pop .2s cubic-bezier(.2,.8,.25,1); }
.tw-head {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 14px; border-bottom: 1px solid var(--line);
  cursor: grab;
}
.tw-head:active { cursor: grabbing; }
.tw-head .t { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink); }
.tw-head .spacer { flex: 1; }
.tw-x { width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); border-radius: 5px; font-size: 15px; }
.tw-x:hover { background: var(--paper-3); color: var(--ink); }
.tw-body { padding: 6px 14px 14px; }
.tw-sec { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 16px 0 9px; }
.tw-sec:first-child { margin-top: 8px; }
.tw-seg { display: flex; border: 1px solid var(--line-2); border-radius: 6px; overflow: hidden; }
.tw-seg button { flex: 1; border: 0; border-left: 1px solid var(--line-2); background: var(--paper); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 7px 4px; }
.tw-seg button:first-child { border-left: 0; }
.tw-seg button.on { background: var(--ink); color: var(--paper); }
.tw-rowf { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; }
.tw-rowf label { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.tw-rowf .val { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tw-slider { width: 100%; margin-top: 8px; accent-color: var(--ink); height: 3px; }
input[type=range].tw-slider { -webkit-appearance: none; appearance: none; background: var(--line-2); border-radius: 3px; }
input[type=range].tw-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--ink); cursor: pointer; }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 100px; box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* dispute note inline */
.note-inline { font-size: 11.5px; color: var(--muted); margin-top: 4px; font-style: italic; }

/* utility */
.flex { display: flex; align-items: center; }
.gap8 { gap: 8px; }
.mt0 { margin-top: 0; }
.right { text-align: right; }
.hidden { display: none !important; }

@media (max-width: 920px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line); }
}
@media (max-width: 620px) {
  .statrow { grid-template-columns: 1fr; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .field-row, .field-row--3 { grid-template-columns: 1fr; }
  .doc-meta { grid-template-columns: 1fr; }
}
