:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #5d6270;
  --line: #e3e1da;
  --accent: #0f6b4f;
  --accent-soft: #e3f1eb;
  --warn: #9a5b00;
  --warn-soft: #fbf0dc;
  --bad: #a3262d;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1114;
    --panel: #171a1f;
    --ink: #e8e6e1;
    --muted: #9aa0ab;
    --line: #2a2e35;
    --accent: #4cc39a;
    --accent-soft: #15302a;
    --warn: #e8b35a;
    --warn-soft: #33270f;
    --bad: #ef7d82;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.mark { font-size: 26px; color: var(--accent); }
.name { font-weight: 650; font-size: 16px; letter-spacing: .2px; }
.sub { color: var(--muted); font-size: 12px; }
.mode { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--warn-soft); color: var(--warn); }
.mode.live { background: var(--accent-soft); color: var(--accent); }
.login { display: flex; gap: 8px; flex-wrap: wrap; }
input, select { font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
button { font: inherit; font-weight: 600; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--ink); color: var(--bg); cursor: pointer; }
button:disabled { opacity: .5; cursor: progress; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
button.link { background: none; color: var(--bad); padding: 0; font-weight: 500; }

main { max-width: 1280px; margin: 0 auto; padding: 20px 16px 48px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .value { font: 600 22px/1.2 var(--mono); margin-top: 4px; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.accent .value { color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; font-family: var(--mono); }
tr:last-child td { border-bottom: 0; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.pill.off { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.good { color: var(--accent); }

.ticket { display: grid; gap: 10px; }
.ticket label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.ticket input, .ticket select { color: var(--ink); font-size: 14px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sides label { display: flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 6px; padding: 8px; color: var(--ink); font-size: 14px; cursor: pointer; }
.sides label:has(input:checked) { border-color: var(--ink); font-weight: 600; }
.sessions { border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; }
.sessions legend { color: var(--muted); font-size: 12px; padding: 0 4px; }
.sessions label { display: flex; gap: 5px; align-items: center; color: var(--ink); font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin: 0; }
.status { font-family: var(--mono); font-size: 12px; min-height: 1.4em; white-space: pre-wrap; }
.status.error { color: var(--bad); }
.status.ok { color: var(--accent); }
.hint.trust { border-left: 3px solid var(--accent); padding-left: 8px; }
.hint.trust.warn { border-left-color: var(--warn); color: var(--warn); }
.ghost-link { color: var(--muted); font-size: 13px; text-decoration: none; border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; }

/* wallet panel (live mode) */
.wsteps { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; counter-reset: ws; }
.wsteps li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; counter-increment: ws; }
.wsteps li span::before { content: counter(ws) ". "; color: var(--muted); font-family: var(--mono); }
.wsteps li.done { border-color: transparent; background: var(--accent-soft); }
.wsteps li.done span::before { content: "✓ "; color: var(--accent); }
.wsteps li.done button { display: none; }
.wsteps button { padding: 6px 10px; font-size: 13px; }
.wtable { margin: 8px 0 12px; }
.wmove { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.wmove label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.wbuttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.wbuttons button { font-size: 13px; }
@media (min-width: 1100px) { #wallet-panel { grid-column: span 2; } }
