:root {
  --paper: #f6f2ec;
  --white: #ffffff;
  --ink: #171615;
  --muted: #5f5a55;
  --line: #e6e2de;
  --line-2: #d8d3ce;
  --side: #faf8f5;
  --accent: #680020;
  --accent-2: #4f0018;
  --tint: #f4e9eb;
  --ok: #2f7a4a;
  --warn: #9a6a00;
  --bad: #b3261e;
  --display: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* buttons + fields */
.btn { height: 42px; padding: 0 18px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-family: var(--display); font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn:disabled { opacity: .45; cursor: default; background: var(--accent); }
.btn-2 { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn-2:hover { background: #fff; border-color: var(--ink); }
.btn-2:disabled { background: #fff; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; }
.btn-bad { background: #fff; color: var(--bad); border-color: var(--line-2); }
.btn-bad:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; }
.link:hover { text-decoration: underline; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line-2); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; border-color: var(--line-2); color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { font-size: 12px; color: var(--muted); }
.input, .textarea, .select { width: 100%; height: 42px; border: 1px solid var(--line-2); background: #fff; padding: 0 12px; border-radius: 0; outline: 0; }
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink); }
.input.bad { border-color: var(--bad); }
.money { display: flex; align-items: center; border: 1px solid var(--line-2); background: #fff; height: 42px; }
.money:focus-within { border-color: var(--ink); }
.money b { padding: 0 0 0 12px; color: var(--muted); font-weight: 600; }
.money input { border: 0; outline: 0; height: 100%; width: 100%; padding: 0 10px 0 4px; background: transparent; font-family: var(--display); font-weight: 700; font-size: 16px; }

/* toggle */
.tog { position: relative; width: 44px; height: 24px; flex: none; }
.tog input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.tog i { position: absolute; inset: 0; background: #d8d3ce; transition: background .15s; }
.tog i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; transition: transform .15s; }
.tog input:checked + i { background: var(--accent); }
.tog input:checked + i::after { transform: translateX(20px); }
.tog input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented */
.seg { display: inline-grid; grid-auto-flow: column; border: 1px solid var(--ink); }
.seg button { height: 38px; padding: 0 16px; border: 0; background: #fff; font-family: var(--display); font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--ink); color: #fff; }

/* auth screens */
.auth { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 16px; gap: 28px; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--ink); padding: 36px; display: flex; flex-direction: column; gap: 18px; }
.auth-card h1 { font-size: 28px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 22px; letter-spacing: -0.03em; }
.auth-brand small { font-family: var(--body); font-weight: 500; font-size: 13px; letter-spacing: 0; color: var(--muted); }
.auth .btn { height: 50px; font-size: 16px; }
.form-err { color: var(--bad); font-size: 14px; min-height: 0; }
.form-ok { color: var(--ok); font-size: 14px; }

/* shell */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; font-family: var(--display); font-weight: 800; font-size: 18px; letter-spacing: -0.03em; text-decoration: none; color: var(--ink); }
.side-site { margin: 0 20px 14px; }
.side-site .select { height: 38px; font-weight: 600; }
.side-site-name { font-family: var(--display); font-weight: 700; font-size: 15px; }
.side-group { padding: 6px 0 12px; }
.side-group > b { display: block; padding: 6px 20px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.side a.nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 20px 9px 17px; font-family: var(--display); font-size: 14.5px; font-weight: 500; color: var(--muted); text-decoration: none; border-left: 3px solid transparent; }
.side a.nav:hover { color: var(--ink); }
.side a.nav.on { color: var(--ink); font-weight: 700; background: #fff; border-left-color: var(--accent); }
.side a.nav .count { font-family: var(--body); font-size: 11px; font-weight: 700; color: #fff; background: var(--bad); padding: 1px 6px; }
.side-foot { margin-top: auto; padding: 16px 20px 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.side-foot .who { font-weight: 600; word-break: break-all; }
.side-foot .row { display: flex; gap: 14px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 40px; min-height: 74px; }
.topbar h1 { font-size: 24px; }
.topbar .sub { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-weight: 600; }
.live::before { content: ""; width: 8px; height: 8px; background: currentColor; }
.live.off { color: var(--bad); }
.live.idle { color: var(--muted); }
.save-bar { display: flex; align-items: center; gap: 12px; }
.save-bar .state { font-size: 13px; color: var(--muted); }
.save-bar .state.dirty { color: var(--warn); font-weight: 600; }
.content { padding: 32px 40px 80px; display: flex; flex-direction: column; gap: 24px; max-width: 1240px; }
.menu-btn { display: none; }

/* panels */
.panel { background: #fff; border: 1px solid var(--line); padding: 26px 28px; display: flex; flex-direction: column; gap: 18px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-head p { margin-top: 6px; color: var(--muted); font-size: 14px; max-width: 62ch; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.split > .stick { position: sticky; top: 98px; }

/* amounts editor */
.amt-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.amt-list { display: flex; flex-direction: column; gap: 8px; }
.amt-row { display: grid; grid-template-columns: 40px 120px minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
.amt-row .def { width: 18px; height: 18px; accent-color: var(--accent); margin: 0 auto 0 4px; }
.amt-head { display: grid; grid-template-columns: 40px 120px minmax(0, 1fr) 34px; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.amt-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }

/* feature rows */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; }
.row + .row { border-top: 1px solid #efebe6; }
.row b { display: block; font-family: var(--display); font-size: 15.5px; font-weight: 700; }
.row small { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; max-width: 60ch; }
.tag { display: inline-block; font-family: var(--body); font-size: 11px; font-weight: 600; padding: 1px 6px; border: 1px solid var(--line-2); color: var(--muted); margin-left: 6px; vertical-align: 2px; }

/* theme */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sw { width: 40px; height: 40px; border: 1px solid var(--line-2); padding: 0; }
.sw.on { outline: 2px solid var(--ink); outline-offset: 3px; }
.sw-custom { display: flex; align-items: center; gap: 8px; margin-left: 6px; }
.sw-custom input[type="color"] { width: 40px; height: 40px; border: 1px solid var(--line-2); padding: 2px; background: #fff; }
.sw-custom .input { width: 110px; font-family: var(--mono); }
.layouts { display: grid; grid-template-columns: repeat(2, minmax(0, 220px)); gap: 14px; }
.layout-opt { border: 1px solid var(--line-2); background: #fff; padding: 12px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.layout-opt.on { border-color: var(--ink); outline: 1px solid var(--ink); }
.layout-opt b { font-family: var(--display); font-size: 14px; }
.lo-pic { height: 92px; background: #c9bfb4; position: relative; }
.lo-pic i { position: absolute; background: #fff; }
.lo-kiosk i { left: 50%; top: 14px; bottom: 14px; width: 42%; transform: translateX(-50%); }
.lo-split { background: #fff; border: 1px solid var(--line); }
.lo-split::before { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 48%; background: #c9bfb4; }
.lo-split i { left: 8px; top: 14px; bottom: 14px; width: 42%; background: #f4f1ee; }

/* lists (add-ons, links) */
.item { border: 1px solid var(--line); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 14px; }
.item-head .btns { display: flex; gap: 6px; }
.empty { border: 1px dashed var(--line-2); padding: 22px; text-align: center; color: var(--muted); font-size: 14px; }

/* preview (mirrors the donate page) */
.pv { background: #fff; border: 1px solid var(--line); padding: 26px; font-family: var(--display); color: var(--pv-ink, #171615); }
.pv-label { font-family: var(--body); font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; }
.pv h4 { font-size: 24px; letter-spacing: -0.02em; margin-bottom: 6px; color: var(--pv-ink); }
.pv .pv-sub { font-family: var(--body); font-size: 13px; color: #5f5a55; margin-bottom: 16px; }
.pv-freq { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--pv-ink); margin-bottom: 12px; }
.pv-freq button { height: 40px; border: 0; background: #fff; font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--pv-ink); }
.pv-freq button.on { background: var(--pv-ink); color: #fff; }
.pv-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.pv-presets[data-n="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pv-presets > span { height: 60px; border: 1px solid #d8d3ce; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 0 4px; text-align: center; }
.pv-presets > span.on { background: var(--pv-primary); border-color: var(--pv-primary); color: #fff; }
.pv-presets .a { font-size: 17px; font-weight: 800; }
.pv-presets .l { font-family: var(--body); font-size: 10.5px; line-height: 1.2; min-height: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-other { height: 44px; border: 1px solid #d8d3ce; display: flex; align-items: center; padding: 0 12px; color: #8b857f; font-family: var(--body); font-size: 14px; margin-bottom: 10px; }
.pv-round { background: var(--pv-tint); padding: 10px 12px; font-family: var(--body); font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.pv-round em { font-style: normal; border: 1px solid var(--pv-primary); color: var(--pv-primary); font-family: var(--display); font-weight: 700; padding: 4px 8px; background: #fff; }
.pv-go { height: 50px; background: var(--pv-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 14px; background: var(--side); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #efebe6; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #fbfaf8; }
td .name { font-family: var(--display); font-weight: 700; font-size: 15px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.pill::before { content: ""; width: 7px; height: 7px; background: currentColor; }
.pill.ok { color: var(--ok); }
.pill.bad { color: var(--bad); }
.pill.warn { color: var(--warn); }
.pill.idle { color: var(--muted); }
.type { font-family: var(--mono); font-size: 11.5px; padding: 2px 6px; border: 1px solid currentColor; white-space: nowrap; }
.type.fallback, .type.error { color: var(--bad); }
.type.structure { color: var(--warn); }
.type.snapshot, .type.baseline { color: var(--muted); }
.ev-msg { font-weight: 600; word-break: break-word; }
.ev-meta { font-size: 12px; color: var(--muted); margin-top: 4px; word-break: break-all; }
details.stack summary { cursor: pointer; font-size: 12px; color: var(--muted); margin-top: 6px; }
details.stack pre { white-space: pre-wrap; word-break: break-all; font-family: var(--mono); font-size: 11.5px; background: var(--side); padding: 10px; margin: 6px 0 0; max-height: 260px; overflow: auto; }

/* stats bars */
.bars { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 3px; align-items: end; height: 90px; border-bottom: 1px solid var(--line); }
.bars span { background: var(--ink); min-height: 1px; position: relative; }
.bars span.f { background: var(--bad); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); background: #fff; }
.kpi { padding: 18px 20px; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi b { display: block; font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.kpi span { font-size: 12.5px; color: var(--muted); }

/* code + snapshot */
.code { position: relative; background: #171615; color: #f1ece6; font-family: var(--mono); font-size: 12px; padding: 16px; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
.code-actions { display: flex; gap: 10px; align-items: center; }
.snap-frame { width: 100%; height: 72vh; border: 1px solid var(--line); background: #fff; }
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(23, 22, 21, .5); display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal-box { background: #fff; border: 1px solid var(--ink); width: 100%; max-width: 1100px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-box.narrow { max-width: 520px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; font-weight: 600; font-size: 14px; z-index: 80; }
.toast.bad { background: var(--bad); }
.loading { padding: 60px 40px; color: var(--muted); }
.note { background: var(--tint); padding: 12px 14px; font-size: 13.5px; }
.note.warn { background: #fbf3dc; }
.note.bad { background: #fbe9e7; }

@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > .stick { position: static; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu-open .side { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 20px 16px 80px; }
  .panel { padding: 20px 16px; }
  .amt-cols, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .amt-row, .amt-head { grid-template-columns: 40px 100px minmax(0, 1fr) 34px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .layouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .topbar .sub > span:last-child { display: none; }
  .topbar h1 { font-size: 20px; }
}
