/* ==========================================================================
   Pynix affiliate panel — design system
   Ink (structure) + amber (money & primary actions), from the Pynix mark.
   Type: Archivo; expanded width for figures and headings.
   ========================================================================== */

:root {
  --ink: #161A2B;
  --ink-2: #20253A;
  --ink-3: #2C3250;
  --ink-text: #C9CDE0;
  --ink-muted: #8A90A6;
  --band: #161A2B;

  --paper: #F3F4F8;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --line: #E3E6EE;
  --line-2: #D3D8E3;
  --text: #161A2B;
  --muted: #646B83;
  --subtle: #8A90A6;

  --amber: #F2A33A;
  --amber-hover: #F5B357;
  --amber-text: #9A5B05;
  --amber-soft: #FFF3E0;

  --green: #16865B;  --green-text: #0F6E4A; --green-soft: #E3F5EC;
  --red: #C93B3B;    --red-text: #A8322F;   --red-soft: #FCE9E9;
  --yellow-text: #8A5A00; --yellow-soft: #FFF4DB;
  --blue: #2F6FD6;   --blue-text: #245CB8;  --blue-soft: #E7EFFC;
  --grey-soft: #EEF0F5;

  --r-s: 8px;
  --r: 10px;
  --r-l: 14px;
  --shadow-pop: 0 12px 32px rgba(22, 26, 43, .16), 0 2px 6px rgba(22, 26, 43, .08);
  --focus: 0 0 0 3px rgba(242, 163, 58, .45);

  --font: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --wide: 116%;

  --side-w: 252px;
  --top-h: 60px;
  --tab-h: 64px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --ink: #0E1120;
  --ink-2: #191D30;
  --ink-3: #262B45;
  --band: #21284A;
  --paper: #0F1220;
  --surface: #171B2C;
  --surface-2: #1C2135;
  --line: #2A3049;
  --line-2: #363D5C;
  --text: #E7E9F2;
  --muted: #9AA1BA;
  --subtle: #7D849C;
  --amber-text: #F2A33A;
  --amber-soft: rgba(242, 163, 58, .14);
  --green-text: #4CC79A; --green-soft: rgba(22, 134, 91, .2);
  --red-text: #F08080;   --red-soft: rgba(201, 59, 59, .2);
  --yellow-text: #F2C14E; --yellow-soft: rgba(242, 193, 78, .14);
  --blue-text: #7FA9F0;  --blue-soft: rgba(47, 111, 214, .2);
  --grey-soft: #22273D;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --ink: #0E1120;
    --ink-2: #191D30;
    --ink-3: #262B45;
    --band: #21284A;
    --paper: #0F1220;
    --surface: #171B2C;
    --surface-2: #1C2135;
    --line: #2A3049;
    --line-2: #363D5C;
    --text: #E7E9F2;
    --muted: #9AA1BA;
    --subtle: #7D849C;
    --amber-text: #F2A33A;
    --amber-soft: rgba(242, 163, 58, .14);
    --green-text: #4CC79A; --green-soft: rgba(22, 134, 91, .2);
    --red-text: #F08080;   --red-soft: rgba(201, 59, 59, .2);
    --yellow-text: #F2C14E; --yellow-soft: rgba(242, 193, 78, .14);
    --blue-text: #7FA9F0;  --blue-soft: rgba(47, 111, 214, .2);
    --grey-soft: #22273D;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--amber-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; font-stretch: var(--wide); line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.25rem 0; }
code, .mono { font-family: var(--mono); font-size: .86em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.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; }
.figure { font-stretch: var(--wide); font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: -.02em; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.pos { color: var(--green-text); }
.neg { color: var(--red-text); }
.hidden { display: none !important; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--ink);
  color: var(--ink-text);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 14px;
  color: #fff;
  font-weight: 800;
  font-stretch: 125%;
  font-size: 1.15rem;
  letter-spacing: .06em;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; }

.nav { padding: 6px 12px 16px; flex: 1; }
.nav-group { margin-top: 18px; }
.nav-title { padding: 0 10px 6px; font-size: .78rem; color: var(--ink-muted); font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px;
  margin: 1px 0;
  border-radius: var(--r-s);
  color: var(--ink-text);
  font-weight: 500;
  font-size: .94rem;
}
.nav a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.nav a[aria-current="page"] { background: var(--ink-3); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.nav a[aria-current="page"] svg { color: var(--amber); }
.nav svg { width: 19px; height: 19px; flex: 0 0 19px; color: var(--ink-muted); }

.side-foot { padding: 14px 16px 18px; border-top: 1px solid var(--ink-3); font-size: .82rem; color: var(--ink-muted); }
.side-foot a { color: var(--ink-text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--top-h);
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand-mini { display: none; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-stretch: 125%; letter-spacing: .06em; }
.topbar .brand-mini img { width: 30px; height: 30px; border-radius: 7px; }
.topbar .spacer { flex: 1; }

.balance-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 999px;
  background: var(--band);
  color: #fff;
  font-weight: 700;
  font-stretch: var(--wide);
  font-variant-numeric: tabular-nums;
  font-size: .92rem;
}
.balance-pill:hover { text-decoration: none; background: var(--ink-3); }
.balance-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }

.user-menu { position: relative; }
.avatar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 3px 10px 3px 3px; cursor: pointer;
  color: var(--text); font: inherit; font-size: .9rem;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-grid; place-items: center;
  background: var(--amber); color: var(--ink);
  font-weight: 800; font-size: .82rem; font-stretch: var(--wide);
}
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 230px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 60;
}
.menu-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head strong { display: block; }
.menu a, .menu button {
  display: flex; width: 100%; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  color: var(--text); background: none; border: 0; font: inherit; font-size: .92rem; cursor: pointer; text-align: left;
}
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }
.menu svg { width: 18px; height: 18px; color: var(--muted); }

.content { padding: 26px 28px 48px; max-width: 1280px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Mobile tab bar */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--ink);
  border-top: 1px solid var(--ink-3);
}
.tabbar a, .tabbar button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-muted); background: none; border: 0; font: inherit; font-size: .7rem; font-weight: 600; cursor: pointer;
}
.tabbar a:hover { text-decoration: none; color: #fff; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar [aria-current="page"] { color: var(--amber); }

.scrim { position: fixed; inset: 0; background: rgba(10, 12, 22, .55); z-index: 45; }

@media (max-width: 1023px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-pop);
  }
  body.nav-open .sidebar { transform: none; }
  .topbar { padding: 0 16px; }
  .topbar .brand-mini { display: inline-flex; }
  .tabbar { display: flex; }
  .content { padding: 20px 16px calc(var(--tab-h) + 32px); }
  .avatar-btn .name { display: none; }
  .avatar-btn { padding: 3px; }
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  min-width: 0;
}
.panel + .panel, .panel + .grid, .grid + .panel, .grid + .grid { margin-top: 18px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.panel-body { padding: 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); align-items: start; }
.grid > .panel, .grid > div > .panel:first-child { margin-top: 0; }
@media (max-width: 1023px) {
  .grid-2, .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Balance band (the one bold element) ---------- */
.band {
  position: relative;
  background: var(--band);
  color: #fff;
  border-radius: var(--r-l);
  padding: 24px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 28px;
  align-items: center;
  overflow: hidden;
  clip-path: polygon(0 0, calc(100% - 34px) 0, 100% 34px, 100% 100%, 0 100%);
}
.band::after {
  content: '';
  position: absolute; right: -60px; bottom: -90px;
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(242, 163, 58, .22), transparent 65%);
  pointer-events: none;
}
.band-label { color: var(--ink-text); font-size: .9rem; }
.band-amount { font-size: clamp(2.1rem, 5vw, 3.1rem); color: var(--amber); line-height: 1.05; margin: 4px 0 6px; }
.band-meta { display: flex; gap: 22px; flex-wrap: wrap; color: var(--ink-text); font-size: .88rem; }
.band-meta strong { color: #fff; font-stretch: var(--wide); font-variant-numeric: tabular-nums; }
.band-actions { display: flex; gap: 10px; flex-wrap: wrap; position: relative; z-index: 1; }
.band .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .18); background: transparent; }
.band .btn-ghost:hover { background: var(--ink-2); }
@media (max-width: 640px) {
  .band { grid-template-columns: 1fr; padding: 20px; clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%); }
}

/* ---------- Ledger (today's numbers in one strip) ---------- */
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ledger > div { padding: 18px 20px; border-left: 1px solid var(--line); min-width: 0; }
.ledger > div:first-child { border-left: 0; }
.ledger dt { color: var(--muted); font-size: .86rem; }
.ledger dd { margin: 4px 0 0; }
.ledger .figure { font-size: 1.7rem; display: block; }
.ledger .sub { margin-top: 6px; font-size: .82rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--green-text); }
.delta.down { color: var(--red-text); }
@media (max-width: 860px) {
  .ledger { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger > div:nth-child(3) { border-left: 0; }
  .ledger > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .ledger .figure { font-size: 1.4rem; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 600; font-size: .92rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--subtle); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--amber); border-color: var(--amber); color: #161A2B; }
.btn-primary:hover { background: var(--amber-hover); border-color: var(--amber-hover); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; --spin: #fff; }
.btn-dark:hover { background: var(--ink-3); border-color: var(--ink-3); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red-text); border-color: var(--line-2); background: var(--surface); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-sm { min-height: 32px; padding: 5px 11px; font-size: .84rem; border-radius: var(--r-s); }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid; border-color: var(--spin, #161A2B) transparent var(--spin, #161A2B) transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Forms ---------- */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.label { font-weight: 600; font-size: .9rem; }
.label .opt { color: var(--muted); font-weight: 400; }
.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: .95rem;
}
.input::placeholder, .textarea::placeholder { color: var(--subtle); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--amber); box-shadow: var(--focus); }
.input[readonly] { background: var(--surface-2); color: var(--muted); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23646B83' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.hint { font-size: .82rem; color: var(--muted); }
.field-error { font-size: .82rem; color: var(--red-text); }
.input.is-invalid { border-color: var(--red); }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.input-mono { font-family: var(--mono); font-size: .86rem; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 70px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--amber); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }

.segmented { display: inline-flex; background: var(--grey-soft); border-radius: var(--r); padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a, .segmented button {
  border: 0; background: none; font: inherit; font-size: .86rem; font-weight: 600; color: var(--muted);
  padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented [aria-current="true"], .segmented .is-active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(22, 26, 43, .1); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .82rem; color: var(--muted);
  padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-2); border-bottom: 0; }
.table .sub-row td { color: var(--muted); font-size: .86rem; padding-top: 8px; padding-bottom: 8px; }
.table .sub-row td:first-child { padding-left: 34px; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-title:hover { color: var(--amber-text); }
.cell-sub { color: var(--muted); font-size: .82rem; }
.truncate { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 720px) {
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.stack tbody tr:last-child { border-bottom: 0; }
  .table.stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .84rem; text-align: left; flex: 0 0 auto; }
  .table.stack td.num { text-align: right; }
  .table.stack td[data-label=""]::before { content: none; }
  .table.stack td.cell-main { display: block; text-align: left; padding-bottom: 6px; }
  .table.stack td.cell-main::before { content: none; }
  .table.stack tbody tr:hover td { background: none; }
  .table.stack tfoot { display: block; }
  .table.stack tfoot tr { display: flex; flex-wrap: wrap; justify-content: space-between; }
  .table.stack .sub-row td:first-child { padding-left: 0; }
  .truncate { max-width: 60vw; }
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 600; white-space: nowrap;
  background: var(--grey-soft); color: var(--muted);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { content: none; }
.badge.ok { background: var(--green-soft); color: var(--green-text); }
.badge.warn { background: var(--yellow-soft); color: var(--yellow-text); }
.badge.bad { background: var(--red-soft); color: var(--red-text); }
.badge.info { background: var(--blue-soft); color: var(--blue-text); }
.badge.brand { background: var(--amber-soft); color: var(--amber-text); }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--grey-soft); color: var(--muted); font-size: .78rem; font-weight: 600; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 34px; height: 34px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-s); font-weight: 600; font-size: .86rem; color: var(--text);
  border: 1px solid transparent;
}
.pager a:hover { background: var(--surface-2); border-color: var(--line); text-decoration: none; }
.pager .is-current { background: var(--ink); color: #fff; }
.pager .is-disabled { color: var(--subtle); }

/* ---------- Empty, alerts ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.empty svg { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--subtle); }
.empty .btn { margin-top: 14px; }

.alert { display: flex; gap: 12px; padding: 12px 16px; border-radius: var(--r); font-size: .92rem; border: 1px solid transparent; }
.alert svg { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; }
.alert.info { background: var(--blue-soft); color: var(--blue-text); }
.alert.warn { background: var(--yellow-soft); color: var(--yellow-text); }
.alert.bad { background: var(--red-soft); color: var(--red-text); }
.alert.ok { background: var(--green-soft); color: var(--green-text); }
.alert a { color: inherit; text-decoration: underline; }

/* ---------- Definition list ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 10px 20px; margin: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Copy field / chips ---------- */
.copy-field { display: flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.copy-field input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 10px 12px; font-family: var(--mono); font-size: .85rem; color: var(--text); }
.copy-field input:focus { outline: none; }
.copy-field .btn { border: 0; border-left: 1px solid var(--line-2); border-radius: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px dashed var(--line-2); background: var(--surface-2); color: var(--text);
  border-radius: 7px; padding: 4px 9px; font-family: var(--mono); font-size: .8rem; cursor: pointer;
}
.chip:hover { border-color: var(--amber); border-style: solid; background: var(--amber-soft); }

/* ---------- Campaign cards (mobile-friendly list) ---------- */
.offer-list { display: grid; }
.offer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.offer:last-child { border-bottom: 0; }
.offer-title { font-weight: 650; font-size: 1rem; color: var(--text); }
.offer-title:hover { color: var(--amber-text); }
.offer-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .84rem; margin-top: 4px; }
.offer-side { display: flex; align-items: center; gap: 16px; }
.offer-payout { text-align: right; }
.offer-payout .figure { font-size: 1.15rem; display: block; }
.offer-payout small { color: var(--muted); font-size: .78rem; }
.offer-action { min-width: 104px; display: flex; justify-content: flex-end; }
@media (max-width: 640px) {
  .offer { grid-template-columns: 1fr; }
  .offer-side { justify-content: space-between; }
  .offer-payout { text-align: left; }
  .offer-action { min-width: 0; }
}

/* ---------- Steps (tracking link builder) ---------- */
.subparams { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

/* ---------- Chart ---------- */
.chart-box { position: relative; height: 300px; }
@media (max-width: 640px) { .chart-box { height: 240px; } }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 100; display: grid; gap: 10px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--r);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-pop);
  font-size: .92rem;
  animation: toast-in .2s ease-out;
}
.toast .t-icon { width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; }
.toast.success .t-icon { color: #4CC79A; }
.toast.error .t-icon { color: #F08080; }
.toast.info .t-icon, .toast.warning .t-icon { color: var(--amber); }
.toast .t-close { margin-left: auto; background: none; border: 0; color: var(--ink-muted); cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 1023px) { .toasts { top: auto; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom)); right: 16px; } }

/* ---------- Dialog ---------- */
dialog.modal {
  border: 0; padding: 0; border-radius: var(--r-l);
  width: min(460px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-pop);
}
dialog.modal::backdrop { background: rgba(10, 12, 22, .55); }
.modal-body { padding: 22px 22px 8px; }
.modal-body h2 { margin-bottom: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; }

/* ---------- Auth pages ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  background: var(--paper);
}
.auth-side {
  position: relative;
  background: var(--ink);
  color: var(--ink-text);
  padding: 40px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 56px), calc(100% - 56px) 100%, 0 100%);
}
.auth-side::after {
  content: ''; position: absolute; left: -120px; bottom: -160px; width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(242, 163, 58, .18), transparent 65%);
}
.auth-side .brand { padding: 0; font-size: 1.4rem; }
.auth-side .brand img { width: 44px; height: 44px; border-radius: 10px; }
.auth-pitch { position: relative; z-index: 1; max-width: 30rem; }
.auth-pitch h1 { color: #fff; font-size: clamp(1.8rem, 3.2vw, 2.6rem); font-stretch: 120%; line-height: 1.1; margin-bottom: 14px; }
.auth-pitch p { font-size: 1.02rem; color: var(--ink-text); }
.auth-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; }
.auth-points li { display: flex; gap: 10px; align-items: flex-start; }
.auth-points svg { width: 20px; height: 20px; color: var(--amber); flex: 0 0 20px; margin-top: 2px; }
.auth-foot { position: relative; z-index: 1; font-size: .84rem; color: var(--ink-muted); }
.auth-foot a { color: var(--ink-text); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card.wide { max-width: 560px; }
.auth-card h2 { font-size: 1.6rem; font-stretch: var(--wide); margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-alt { margin-top: 22px; text-align: center; color: var(--muted); font-size: .92rem; }
.auth-mobile-brand { display: none; }
.recaptcha { min-height: 78px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { align-items: flex-start; padding: 28px 16px 40px; }
  .auth-mobile-brand { display: flex; margin-bottom: 26px; color: var(--text); padding: 0; }
}

/* ---------- Error page ---------- */
.error-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.error-box { max-width: 440px; text-align: center; }
.error-box img { margin: 0 auto 18px; border-radius: 14px; }
.error-box h1 { margin-bottom: 10px; }
.error-box p { color: var(--muted); }

/* ---------- Invoice ---------- */
.invoice { max-width: 860px; }
.invoice-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 24px; border-bottom: 1px solid var(--line); }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 24px; }
@media (max-width: 640px) { .invoice-parties { grid-template-columns: 1fr; } }
.invoice-total { display: flex; justify-content: flex-end; padding: 18px 24px; border-top: 1px solid var(--line); gap: 24px; align-items: baseline; }
.invoice-total .figure { font-size: 1.6rem; }

@media print {
  .sidebar, .topbar, .tabbar, .page-actions, .toasts, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .panel { border: 0; }
}

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

/* ---------- Page-specific pieces ---------- */
.steps-list { margin: 0; padding: 20px 20px 20px 40px; display: grid; gap: 12px; }
.steps-list li::marker { color: var(--amber-text); font-weight: 700; font-stretch: var(--wide); }

.prose { line-height: 1.65; overflow-wrap: anywhere; }
.prose p, .prose ul, .prose ol { margin: 0 0 .8rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose a { text-decoration: underline; }

.methods { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.methods legend { margin-bottom: 8px; padding: 0; }
.method-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border: 1px solid var(--line-2); border-radius: var(--r);
  cursor: pointer; background: var(--surface);
}
.method-card input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--amber); flex: 0 0 18px; }
.method-card > span { display: grid; gap: 2px; min-width: 0; }
.method-card > span .muted { overflow-wrap: anywhere; }
.method-card.is-selected { border-color: var(--amber); box-shadow: var(--focus); }
.method-card.is-off { cursor: default; background: var(--surface-2); }
.method-card.is-off strong { color: var(--muted); }

.col-chooser { position: relative; }
.col-chooser > summary { list-style: none; }
.col-chooser > summary::-webkit-details-marker { display: none; }
.col-menu { display: grid; gap: 2px; max-height: 360px; overflow: auto; padding: 10px 12px; min-width: 200px; }
.col-menu .check { padding: 4px 0; }

.macro-table td { padding: 6px 8px 6px 0; border: 0; }
.macro-table tbody tr:hover td { background: none; }

@media (max-width: 720px) { .table.stack .sub-row td:empty { display: none; } }
.table .empty { padding: 32px 16px; }

/* Wide data tables scroll sideways instead of squeezing columns */
.table.data td, .table.data th { white-space: nowrap; }
.table.data td.cell-main { min-width: 180px; white-space: normal; }
@media (max-width: 720px) { .table.data td { white-space: normal; } }
