/* Dashboard: summary, payments table (cards on phones), refund dialog, webhook.
   Light by default, dark when <html data-theme="dark"> (same key and tokens as web/landing/style.css).
   The landing page loads this file too and its own tokens, loaded later, win there. */
:root {
  color-scheme: light;
  --bg: #fafaf7; --surface: #ffffff; --ink: #14171a; --muted: #565c66; --line: #e2e2da; --line-2: #cfcfc6;
  --accent: #0b7a5a; --accent-ink: #ffffff; --ring: rgba(11, 122, 90, 0.25); --err: #b42318; --warn: #8a5a00;
  --sunk: #f4f4ef;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07080a; --surface: #101215; --ink: #eef0ee; --muted: #9ba2aa; --line: #22262b; --line-2: #2f343a;
  --accent: #3fd69a; --accent-ink: #04150d; --ring: rgba(63, 214, 154, 0.3); --err: #ff9a90; --warn: #f1c56b;
  --sunk: #0c0e10;
}
body { font-variant-numeric: tabular-nums; }

/* Flat controls inside the dashboard: hairlines, 8px corners, no glow or lift. */
.totals, .orders, .dlg, .webhook, main.wide { --r: 8px; }
:is(.orders, .dlg, .webhook, .blank, main.wide > .empty) .btn { border-radius: var(--r); height: 44px; padding: 0 18px; }
:is(.orders, .dlg, .webhook, .blank) .btn.sm { height: 34px; padding: 0 12px; font-size: 0.875rem; }
:is(.orders, .dlg, .webhook, .blank, main.wide > .empty) .btn:hover:not(:disabled) { box-shadow: none; transform: none; }
:is(.orders, .dlg, .webhook, .blank) .btn.ghost { background: transparent; border-color: var(--line-2); }
:is(.orders, .dlg, .webhook, .blank) .btn.ghost:hover:not(:disabled) { border-color: var(--muted); box-shadow: none; }
:is(.orders, .dlg, .webhook) .input { height: 44px; border-radius: var(--r); border-color: var(--line-2); background: var(--surface); }
:is(.orders, .dlg, .webhook) .input:focus { box-shadow: none; outline: 2px solid var(--accent); outline-offset: 1px; }
:is(.orders, .dlg, .webhook) .notice { border-radius: var(--r); }
.orders .code, .webhook .code, .dlg .kv { border-radius: var(--r); }

.page.wide { max-width: 1080px; }
.wide-foot { width: min(calc(1080px - 2 * var(--pad)), calc(100% - 2 * var(--pad))); }
.head { display: grid; gap: 4px; padding: clamp(8px, 3vw, 20px) 0 clamp(20px, 4vw, 28px); }
.head .h1 { margin-top: 4px; font-size: clamp(1.5rem, 5vw, 2rem); letter-spacing: -0.03em; }
.siteline { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: 10px; color: var(--muted); font-size: 0.95rem; }
.siteline .mono { color: var(--ink); }
.page > .notice { margin-bottom: 20px; }
.sect { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.count { margin-left: 6px; font-size: 0.875rem; font-weight: 500; color: var(--muted); }
.chip-role { margin-left: 2px; font-weight: 500; }
.chip-role::before { content: "\00b7\00a0"; }
@media (max-width: 480px) { .chip-role { display: none; } }
.badge { border-radius: 6px; }
.bar-end .badge, .bar-end .btn { border-radius: 8px; }
.theme-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; background: transparent; border: 1px solid var(--line-2); border-radius: 8px; color: var(--ink); cursor: pointer; }
.theme-btn:hover { border-color: var(--muted); }
.theme-btn svg { width: 16px; height: 16px; }

/* Summary */
.totals { container: totals / inline-size; margin-bottom: clamp(28px, 5vw, 40px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.totals dl { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; }
.stat { padding: 18px 20px; border-left: 1px solid var(--line); min-width: 0; }
.stat:first-child { border-left: 0; }
.stat dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.stat dd { margin-top: 6px; font-size: 1.35rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; overflow-wrap: anywhere; }
.stat.big dd { font-size: 2rem; letter-spacing: -0.03em; }
.stat small { margin-left: 5px; font-size: 0.8125rem; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.stat-note { margin-top: 2px; font-size: 0.8125rem; color: var(--muted); }
.totals > .hint { padding: 10px 20px; border-top: 1px solid var(--line); font-size: 0.8125rem; }
@container totals (max-width: 720px) {
  .totals dl { grid-template-columns: 1fr 1fr; }
  .stat { padding: 14px 16px; border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .stat:nth-child(1), .stat:nth-child(4) { grid-column: 1 / -1; }
  .stat:nth-child(3) { border-left: 1px solid var(--line); }
  .stat.big dd { font-size: 1.75rem; }
}

/* Payments */
.orders { container: orders / inline-size; display: grid; gap: 14px; margin-bottom: clamp(32px, 6vw, 48px); }
.orders-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 14px; }
.export { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.export-text { min-width: 0; flex: 1 1 320px; }
.export-text strong { font-weight: 600; }
.export-text p { margin-top: 2px; font-size: 0.8125rem; color: var(--muted); overflow-wrap: anywhere; }
.export-text .mono { font-size: 0.78rem; color: var(--ink); }
.export .btn { flex: none; }
@media (max-width: 480px) { .export .btn { width: 100%; } }

.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } /* phone: hidden, still announced */
.tr {
  display: grid; gap: 6px 12px; align-items: center; padding: 14px 16px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "order amt" "time buyer" "status status" "act act";
}
.tr + .tr, .thead + [role="rowgroup"] > .tr:first-child { border-top: 1px solid var(--line); }
.tr > * { min-width: 0; }
.c-order { grid-area: order; } .c-amt { grid-area: amt; text-align: right; } .c-time { grid-area: time; }
.c-buyer { grid-area: buyer; justify-self: end; } .c-status { grid-area: status; } .c-act { grid-area: act; }
.order { font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.order.mono { font-weight: 500; }
.c-time { color: var(--muted); font-size: 0.875rem; white-space: nowrap; }
.c-buyer { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); white-space: nowrap; }
.c-amt { font-weight: 600; white-space: nowrap; }
.c-amt small { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.c-status { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.pst { display: inline-block; padding: 1px 8px; border: 1px solid var(--line-2); border-radius: 6px; font-size: 0.8125rem; font-weight: 600; line-height: 1.5; white-space: nowrap; color: var(--muted); }
.pst.ok { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.pst.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.pst-note { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
.c-act { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.c-act .btn { margin-left: auto; }
.c-act .exlink { color: var(--muted); font-size: 0.875rem; padding: 8px 0; }
.c-act .exlink:hover { color: var(--ink); }
.copy-mini { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.copy-mini:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.copy-mini.done { color: var(--accent); }
.copy-mini .icon { width: 14px; height: 14px; }

@container orders (min-width: 860px) {
  .thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; border-bottom: 1px solid var(--line); background: var(--sunk); }
  .thead .tr { padding-block: 9px; border: 0; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
  .tr {
    grid-template-columns: 104px minmax(0, 1fr) 124px 150px 126px 232px;
    grid-template-areas: none; gap: 12px; padding: 11px 20px;
  }
  .tr > *, .c-order, .c-amt, .c-time, .c-buyer, .c-status, .c-act { grid-area: auto; }
  .num { text-align: right; }
  .c-buyer { justify-self: start; }
  .c-status { flex-direction: column; align-items: flex-start; gap: 2px; }
  .c-act { display: grid; grid-template-columns: 52px 74px 66px; justify-content: end; gap: 12px; padding: 0; border: 0; }
  .c-act .btn { margin: 0; }
  .thead span:last-child { text-align: right; }
}

.skeleton-rows { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.skel-row { display: grid; gap: 10px; padding: 18px 16px; }
.skel-row + .skel-row { border-top: 1px solid var(--line); }
.skel { display: block; height: 14px; width: 70%; border-radius: 4px; background: color-mix(in srgb, var(--ink) 9%, transparent); }
.skel.short { width: 40%; }
.stat dd .skel { height: 24px; width: 70%; }
@media (prefers-reduced-motion: no-preference) {
  .skel { animation: pulse 1.4s ease-in-out infinite; }
  @keyframes pulse { 50% { opacity: 0.45; } }
}
.more { display: flex; justify-content: center; padding-top: 6px; }

/* Empty state: says what to do next */
.blank { display: grid; justify-items: start; gap: 10px; padding: clamp(20px, 4vw, 28px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.blank h3 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.02em; }
.blank p { color: var(--muted); max-width: 56ch; }
.blank ol { display: grid; gap: 8px; max-width: 56ch; padding-left: 20px; list-style: decimal; }
.blank li { padding-left: 4px; color: var(--muted); }
.blank li strong { color: var(--ink); font-weight: 600; }
.blank .row { margin-top: 6px; }
main.wide > .empty { justify-items: start; text-align: left; padding: clamp(24px, 6vw, 48px) 0; }
main.wide > .empty .empty-mark { display: none; }
main.wide > .empty h2 { margin-top: 0; }

/* Webhook */
.webhook { display: grid; gap: 14px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.webhook > .hint { max-width: 70ch; }
.webhook .live, .dlg .live { display: grid; gap: 10px; }
.webhook .live:empty, .dlg .live:empty { display: none; }
.sample summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; padding: 6px 0; border-radius: 6px; }
.sample summary:hover { color: var(--ink); }
.sample .code { margin-top: 8px; }

/* Refund dialog */
.dlg { width: min(460px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18); overflow: auto; }
.dlg::backdrop { background: rgba(10, 12, 14, 0.5); }
.dlg-body { display: grid; gap: 16px; padding: 20px; }
.dlg-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dlg-top h2 { font-size: 1.25rem; font-weight: 650; letter-spacing: -0.025em; line-height: 1.3; overflow-wrap: anywhere; }
.icon-btn { flex: none; width: 36px; height: 36px; margin: -6px -8px 0 0; border: 0; border-radius: 8px; background: transparent; font-size: 1.6rem; line-height: 1; color: var(--muted); cursor: pointer; }
.icon-btn:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.dlg .explain { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--sunk); font-size: 0.9375rem; }
.dlg .facts { display: grid; gap: 12px; }
.dlg .facts dt { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.dlg .facts dd { margin-top: 2px; font: 0.9rem/1.5 var(--mono); overflow-wrap: anywhere; word-break: break-all; }
.dlg .facts dd:has(.addr) { display: flex; align-items: flex-start; gap: 6px; }
.dlg .addr { min-width: 0; font-size: 0.8125rem; }
.dlg .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amt-row { display: flex; gap: 8px; }
.dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.dlg-actions .btn { flex: 1 1 auto; }
@media (min-width: 480px) { .dlg-actions .btn { flex: 0 0 auto; } }
@media (prefers-reduced-motion: no-preference) {
  .dlg[open] { animation: pop 0.2s var(--ease); }
  @keyframes pop { from { opacity: 0; transform: translateY(6px); } }
}
