/* PayGuardian CRM console — served at /admin/static/dashboard.css
   Tokens first (light on :root, dark under prefers-color-scheme / data-theme),
   every component reads the tokens. No inline styles anywhere in templates
   (the CSP for app.payguardian.io has no 'unsafe-inline'). */
:root {
  --ground:#f6f8f9; --surface:#ffffff; --surface-2:#eef2f4; --ink:#182530; --muted:#5b6b77;
  --faint:#8a99a5; --line:#dde4e8; --accent:#0f766e; --accent-ink:#ffffff; --accent-soft:#e2f1ee;
  --good:#1a8a55; --good-soft:#e3f3ea; --warn:#a96a08; --warn-soft:#f7eedd;
  --crit:#c0392f; --crit-soft:#f9e8e6; --info:#2563eb; --info-soft:#e7eefc;
  --shadow:0 1px 2px rgba(24,37,48,.06),0 4px 16px rgba(24,37,48,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ground:#0f151a; --surface:#161e26; --surface-2:#1d2731; --ink:#e2e9ee; --muted:#93a3ae;
  --faint:#6b7b87; --line:#29343f; --accent:#2fa596; --accent-ink:#07211d; --accent-soft:#143530;
  --good:#3cb878; --good-soft:#14301f; --warn:#d79b3a; --warn-soft:#33270f;
  --crit:#e26d5c; --crit-soft:#3a1d18; --info:#6d9cf5; --info-soft:#1a2740;
  --shadow:0 1px 2px rgba(0,0,0,.4),0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --ground:#0f151a; --surface:#161e26; --surface-2:#1d2731; --ink:#e2e9ee; --muted:#93a3ae;
  --faint:#6b7b87; --line:#29343f; --accent:#2fa596; --accent-ink:#07211d; --accent-soft:#143530;
  --good:#3cb878; --good-soft:#14301f; --warn:#d79b3a; --warn-soft:#33270f;
  --crit:#e26d5c; --crit-soft:#3a1d18; --info:#6d9cf5; --info-soft:#1a2740;
  --shadow:0 1px 2px rgba(0,0,0,.4),0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing:border-box; }
html,body { margin:0; }
body { background:var(--ground); color:var(--ink); font-family:"Archivo","Segoe UI",-apple-system,sans-serif; font-size:14px; line-height:1.45; }
a { color:var(--accent); }
.mono { font-family:"IBM Plex Mono",ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.92em; }
.sm-mono { font-size:12px; }
.sans { font-family:"Archivo","Segoe UI",sans-serif; }
.small { font-size:12px; }
.nowrap { white-space:nowrap; }
.warn-text { color:var(--warn); }
button { font:inherit; cursor:pointer; }
button:focus-visible,input:focus-visible,select:focus-visible,a:focus-visible { outline:2px solid var(--accent); outline-offset:2px; }
[hidden] { display:none !important; }
.inline-form { display:inline; margin:0; }

/* login */
.login-wrap { min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px; }
.login-card { width:360px; max-width:100%; background:var(--surface); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow); padding:28px; margin:0; }
.login-brand { display:flex; align-items:center; gap:10px; margin-bottom:18px; }
.login-card label { font-size:12px; font-weight:600; color:var(--muted); display:block; margin:12px 0 4px; }
.login-card input { width:100%; background:var(--surface-2); border:1px solid var(--line); color:var(--ink); border-radius:8px; padding:9px 11px; font:inherit; }
.login-err { color:var(--crit); font-size:13px; margin-top:10px; min-height:1.2em; }
.login-foot { margin-top:14px; font-size:12px; color:var(--faint); }
.login-foot a { color:inherit; }

/* shell */
.shell { display:flex; min-height:100vh; }
.rail { width:216px; flex:none; background:var(--surface); border-right:1px solid var(--line); display:flex; flex-direction:column; gap:4px; padding:18px 12px; position:sticky; top:0; height:100vh; }
.brand { display:flex; align-items:center; gap:10px; padding:2px 10px 16px; text-decoration:none; color:inherit; }
.brand-mark { width:36px; height:36px; display:block; flex:none; }
.brand-name { font-weight:700; font-size:15px; }
.brand-name small { display:block; font-weight:500; font-size:10.5px; color:var(--muted); letter-spacing:.08em; text-transform:uppercase; }
.nav-label { font-size:10.5px; letter-spacing:.1em; text-transform:uppercase; color:var(--faint); padding:14px 10px 4px; }
.nav-btn { display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:none; border:0; border-radius:8px; padding:8px 10px; color:var(--muted); font-weight:500; text-decoration:none; }
.nav-btn:hover { background:var(--surface-2); color:var(--ink); }
.nav-btn.active { background:var(--accent-soft); color:var(--accent); font-weight:600; }
.nav-btn .ico { width:17px; height:17px; flex:none; }
.nav-btn .count { margin-left:auto; font-size:11px; background:var(--crit-soft); color:var(--crit); border-radius:99px; padding:1px 7px; font-weight:600; }
.rail-foot { margin-top:auto; padding:10px; font-size:11.5px; color:var(--faint); border-top:1px solid var(--line); }
.main { flex:1; min-width:0; display:flex; flex-direction:column; }
.topbar { display:flex; align-items:center; gap:14px; padding:12px 26px; background:var(--surface); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20; }
.store-switcher { display:flex; align-items:center; gap:8px; min-width:0; }
.store-switcher label { margin:0; font-size:12px; font-weight:600; }
.store-switcher select { width:auto; max-width:320px; min-width:100px; margin:0; }
@media (max-width:760px) {
  .topbar { flex-wrap:wrap; padding:12px 16px; }
  .store-switcher { width:100%; }
  .store-switcher select { flex:1; max-width:none; min-width:0; }
}
.who { font-weight:600; font-size:13px; text-align:right; }
.who small { display:block; font-weight:500; color:var(--faint); font-size:11px; }
.env-pill { font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; padding:3px 9px; border-radius:99px; background:var(--warn-soft); color:var(--warn); }
.env-pill.live { background:var(--good-soft); color:var(--good); }
.spacer { margin-left:auto; }
.content { padding:24px 26px 60px; }
.page-head { display:flex; align-items:baseline; gap:12px; margin-bottom:18px; flex-wrap:wrap; }
.page-head h1 { font-size:21px; font-weight:700; margin:0; }
.page-head .sub { color:var(--muted); font-size:13px; }
.page-head .actions { margin-left:auto; display:flex; gap:8px; }

.btn { display:inline-block; border:1px solid var(--line); background:var(--surface); color:var(--ink); border-radius:8px; padding:7px 13px; font-weight:600; font-size:13px; text-decoration:none; line-height:1.3; }
.btn:hover { background:var(--surface-2); }
.btn.primary { background:var(--accent); border-color:var(--accent); color:var(--accent-ink); }
.btn.primary:hover { filter:brightness(1.06); }
.btn:disabled { opacity:.6; cursor:default; }
.btn.danger { color:var(--crit); border-color:var(--crit); background:none; }
.btn.danger:hover { background:var(--crit-soft); }
.btn.sm { padding:4px 10px; font-size:12px; border-radius:7px; }
.btn.ghost { border-color:transparent; background:none; color:var(--muted); }
.btn.ghost:hover { background:var(--surface-2); color:var(--ink); }
.btn.block { width:100%; padding:10px; margin-top:16px; }

.card { background:var(--surface); border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); }
.card-head { display:flex; align-items:center; gap:10px; padding:14px 18px; border-bottom:1px solid var(--line); }
.card-head h2 { font-size:14px; font-weight:700; margin:0; }
.card-head .hint { color:var(--faint); font-size:12px; }
.card-head .right { margin-left:auto; display:flex; gap:8px; align-items:center; }

.pill { display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:600; border-radius:99px; padding:2px 9px; white-space:nowrap; margin-right:4px; }
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; }
.pill.good { background:var(--good-soft); color:var(--good); }
.pill.warn { background:var(--warn-soft); color:var(--warn); }
.pill.crit { background:var(--crit-soft); color:var(--crit); }
.pill.info { background:var(--info-soft); color:var(--info); }
.pill.dim { background:var(--surface-2); color:var(--muted); }
.chip { display:inline-block; font-size:11px; font-weight:600; background:var(--surface-2); color:var(--muted); border-radius:6px; padding:2px 7px; }

table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
thead th { text-align:left; font-size:11px; letter-spacing:.07em; text-transform:uppercase; color:var(--faint); font-weight:600; padding:10px 14px; border-bottom:1px solid var(--line); white-space:nowrap; }
tbody td { padding:11px 14px; border-bottom:1px solid var(--line); vertical-align:middle; }
tbody tr:last-child td { border-bottom:0; }
tbody tr.rowlink { cursor:pointer; }
tbody tr.rowlink:hover { background:var(--surface-2); }
.rowmain { color:inherit; text-decoration:none; font-weight:600; }
.rowmain:hover { color:var(--accent); }
.num { text-align:right; }
.tablewrap { overflow-x:auto; }
.cell-main { font-weight:600; }
.cell-sub { font-size:12px; color:var(--muted); }
.empty { padding:30px; text-align:center; color:var(--faint); }

.kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:14px; margin-bottom:18px; }
.kpi { padding:16px 18px; }
.kpi .label { font-size:11.5px; letter-spacing:.07em; text-transform:uppercase; color:var(--faint); font-weight:600; }
.kpi .value { font-size:26px; font-weight:700; margin-top:4px; font-variant-numeric:tabular-nums; }
.kpi .delta { font-size:12px; margin-top:2px; font-weight:600; color:var(--muted); }
.grid-2 { display:grid; grid-template-columns:1.6fr 1fr; gap:14px; align-items:start; }
@media (max-width:980px) { .grid-2 { grid-template-columns:1fr; } .rail { display:none; } }
.chart-wrap { padding:12px 18px 6px; }
#volChart { width:100%; display:block; }
.legend { display:flex; gap:16px; padding:0 18px 14px; font-size:12px; color:var(--muted); }
.legend i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:6px; vertical-align:-1px; }
.sw-accent { background:var(--accent); } .sw-crit { background:var(--crit); }
.health-list { list-style:none; margin:0; padding:6px 0; }
.health-list li { display:flex; align-items:center; gap:10px; padding:10px 18px; border-bottom:1px solid var(--line); }
.health-list li:last-child { border-bottom:0; }
.health-list .grow { min-width:0; flex:1; }

.back { display:inline-flex; align-items:center; gap:6px; color:var(--muted); text-decoration:none; font-weight:600; margin-bottom:12px; }
.back:hover { color:var(--accent); }
.detail-grid { display:grid; grid-template-columns:320px 1fr; gap:14px; align-items:start; }
@media (max-width:980px) { .detail-grid { grid-template-columns:1fr; } }
.profile { padding:18px; }
.profile h2 { margin:0 0 2px; font-size:17px; }
.profile .mail { color:var(--muted); font-size:13px; word-break:break-all; }
.kv { display:grid; grid-template-columns:110px 1fr; gap:7px 10px; margin:14px 0 0; font-size:13px; }
.kv dt { color:var(--faint); } .kv dd { margin:0; min-width:0; overflow-wrap:anywhere; }
.stack { display:grid; gap:14px; }
.pm-row { display:flex; align-items:center; gap:12px; padding:12px 18px; border-bottom:1px solid var(--line); }
.pm-row:last-child { border-bottom:0; }
.pm-brand { width:44px; height:30px; border-radius:6px; border:1px solid var(--line); background:var(--surface-2); display:grid; place-items:center; font-size:10px; font-weight:700; color:var(--muted); flex:none; }
.pm-info { min-width:0; flex:1; }
.pm-info .cell-main.mono { font-size:13px; }
.pm-actions { display:flex; gap:6px; }

/* filters: a plain GET form, applied on submit only */
.filterbar { display:flex; gap:8px; flex-wrap:wrap; margin:0 0 14px; align-items:center; }
.fbtn { border:1px solid var(--line); background:var(--surface); color:var(--muted); border-radius:99px; padding:5px 13px; font-weight:600; font-size:12.5px; text-decoration:none; }
.fbtn:hover { color:var(--ink); }
.fbtn.active { background:var(--ink); color:var(--ground); border-color:var(--ink); }
.filterbar input,.filterbar select { background:var(--surface); border:1px solid var(--line); color:var(--ink); border-radius:8px; padding:6px 10px; font:inherit; font-size:13px; }
.filterbar input[type="search"] { flex:1 1 180px; min-width:160px; max-width:320px; }
.frange { font-size:12px; color:var(--muted); display:inline-flex; align-items:center; gap:5px; }

/* pagination */
.pager { display:flex; align-items:center; gap:14px; flex-wrap:wrap; padding:12px 14px; border-top:1px solid var(--line); font-size:12.5px; color:var(--muted); }
.pager-info b { color:var(--ink); font-weight:600; }
.pager-nav { display:flex; align-items:center; gap:3px; margin-left:auto; }
.pbtn { display:inline-block; min-width:30px; text-align:center; padding:4px 8px; border-radius:7px; border:1px solid transparent; color:var(--muted); text-decoration:none; font-weight:600; font-variant-numeric:tabular-nums; }
a.pbtn:hover { background:var(--surface-2); color:var(--ink); }
.pbtn.current { background:var(--accent-soft); color:var(--accent); border-color:transparent; }
.pbtn.disabled { opacity:.4; cursor:default; }
.pgap { padding:0 4px; color:var(--faint); }
.pager-size { display:inline-flex; align-items:center; gap:6px; }
.pager-size select { background:var(--surface); border:1px solid var(--line); color:var(--ink); border-radius:7px; padding:4px 8px; font:inherit; font-size:12.5px; }

/* modals + toast */
.overlay { position:fixed; inset:0; background:rgba(10,18,24,.45); display:none; align-items:center; justify-content:center; z-index:50; padding:20px; }
.overlay.open { display:flex; }
.modal { width:440px; max-width:100%; }
.modal .card-body { padding:18px; display:grid; gap:12px; }
.modal label { font-size:12px; font-weight:600; color:var(--muted); display:block; margin-bottom:4px; }
.modal input,.modal select { width:100%; background:var(--surface-2); border:1px solid var(--line); color:var(--ink); border-radius:8px; padding:8px 10px; font:inherit; }
.modal .foot { display:flex; justify-content:flex-end; gap:8px; padding:14px 18px; border-top:1px solid var(--line); }
.modal .note { font-size:12px; color:var(--faint); margin:0; }
.toast { position:fixed; bottom:22px; left:50%; transform:translateX(-50%) translateY(8px); background:var(--ink); color:var(--ground); padding:9px 16px; border-radius:9px; font-weight:600; font-size:13px; opacity:0; pointer-events:none; transition:opacity .2s,transform .2s; z-index:60; box-shadow:var(--shadow); }
.toast.show { opacity:1; transform:translateX(-50%) translateY(0); }
.toast.err { background:var(--crit); color:#fff; }
@media (prefers-reduced-motion:reduce) { .toast { transition:none; } }
.footnote { margin-top:22px; font-size:12px; color:var(--faint); max-width:68ch; }
.footnote a { color:inherit; }

/* Shared transaction detail dialog. Native dialog handles focus and Escape. */
.transaction-link { border:0; padding:2px 0; background:none; color:var(--accent); text-decoration:underline; text-underline-offset:3px; font-size:inherit; cursor:pointer; }
.transaction-row { cursor:pointer; }
.transaction-row:hover { background:var(--surface-2); }
.transaction-dialog { padding:0; width:min(1040px,calc(100vw - 32px)); max-width:none; max-height:calc(100dvh - 32px); color:var(--ink); background:var(--surface); border:1px solid var(--line); border-radius:16px; box-shadow:0 24px 80px #0004; }
.transaction-dialog::backdrop { background:rgba(10,18,24,.6); }
.transaction-head { display:flex; justify-content:space-between; align-items:center; gap:16px; padding:20px 24px; border-bottom:1px solid var(--line); }
.transaction-head h2 { margin:4px 0 0; font-size:23px; overflow-wrap:anywhere; }
.transaction-body { max-height:calc(100dvh - 135px); overflow:auto; padding:24px; overscroll-behavior:contain; }
.transaction-summary { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-bottom:20px; }
.transaction-amount { font-size:28px; letter-spacing:-1px; }
.transaction-summary .cell-sub { flex-basis:100%; }
.transaction-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; }
.transaction-section { border:1px solid var(--line); border-radius:10px; padding:18px; margin-bottom:16px; min-width:0; }
.transaction-section h3 { font-size:15px; margin:0 0 16px; }
.transaction-facts { display:grid; grid-template-columns:minmax(110px,1fr) minmax(0,1.7fr); gap:10px 16px; margin:0; font-size:13px; }
.transaction-facts dt { color:var(--muted); }
.transaction-facts dd { margin:0; white-space:pre-wrap; overflow-wrap:anywhere; }
.transaction-section .cell-sub { line-height:1.6; }
.transaction-section .btn { margin-top:12px; }
.address-line { overflow-wrap:anywhere; line-height:1.7; font-size:13px; }
.transaction-items { overflow-x:auto; margin-bottom:18px; }
.transaction-items td:first-child { min-width:170px; max-width:450px; overflow-wrap:anywhere; }
.transaction-map { width:100%; height:260px; border:1px solid var(--line); border-radius:8px; background:var(--surface-2); margin-top:12px; }
.transaction-attempt { display:flex; align-items:center; flex-wrap:wrap; gap:12px; text-align:left; width:100%; padding:12px; background:var(--surface-2); color:var(--ink); border:1px solid var(--line); border-radius:8px; margin-top:8px; cursor:pointer; }
.transaction-attempt:disabled { cursor:default; border-color:var(--accent); }
.transaction-error { color:var(--crit); }
.transaction-link:focus-visible,.transaction-dialog button:focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
@media(max-width:700px) {
  .transaction-dialog { width:calc(100vw - 16px); max-height:calc(100dvh - 16px); }
  .transaction-head { padding:16px; }
  .transaction-head h2 { font-size:20px; }
  .transaction-body { padding:12px; }
  .transaction-columns { grid-template-columns:minmax(0,1fr); gap:0; }
  .transaction-section { padding:14px; }
  .transaction-facts { grid-template-columns:minmax(90px,1fr) minmax(0,1.5fr); gap:9px 12px; }
}

.customer-control-reason { width:100%; box-sizing:border-box; resize:vertical; font:inherit; padding:8px; border:1px solid var(--line); border-radius:6px; }
.customer-control-actions { display:flex; gap:6px; flex-wrap:wrap; }

/* account + staff settings */
.settings-grid { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:14px; align-items:start; margin-bottom:14px; }
.settings-card { overflow:hidden; }
.settings-body { padding:18px; }
.settings-kv { margin-top:0; }
.settings-form { display:grid; gap:7px; }
.settings-form label,.staff-invite label { color:var(--muted); font-size:12px; font-weight:600; }
.settings-form input,.staff-invite input { width:100%; background:var(--surface-2); border:1px solid var(--line); color:var(--ink); border-radius:8px; padding:9px 11px; font:inherit; }
.settings-form .btn { justify-self:start; margin-top:6px; }
.staff-settings { margin-top:14px; }
.staff-invite { display:flex; align-items:end; gap:10px; padding:18px 18px 8px; }
.staff-invite > div { flex:1; max-width:440px; }
.staff-invite label { display:block; margin-bottom:5px; }
.settings-note { color:var(--muted); font-size:12.5px; max-width:82ch; padding:0 18px 12px; margin:0; }
@media(max-width:760px) {
  .settings-grid { grid-template-columns:1fr; }
  .staff-invite { align-items:stretch; flex-direction:column; }
  .staff-invite .btn { align-self:flex-start; }
}
