:root {
  --ink: #18201c;
  --ink-2: #4a544e;
  --ink-3: #7b847e;
  --line: #e4e6e1;
  --bg: #f6f5f1;
  --card: #ffffff;
  --brand: #1f2a24;
  --accent: #b88a3e;
  --accent-soft: #f4ead8;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --warn: #9a6a00;
  --warn-soft: #fbf0d6;
  --bad: #a32d2d;
  --bad-soft: #fbe4e4;
  --info: #2c5d8a;
  --info-soft: #e3edf7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(24, 32, 28, 0.06), 0 4px 16px rgba(24, 32, 28, 0.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--ink-3); }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 10% -10%, #e9e3d3 0, transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.2px; }
.brand .mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; }
.brand .mark svg { width: 18px; height: 18px; }
.auth h1 { font-size: 20px; margin: 22px 0 4px; }
.auth p.sub { color: var(--ink-2); margin: 0 0 20px; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; font-weight: 550; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: #fff; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.code-input { letter-spacing: 0.4em; font-variant-numeric: tabular-nums; font-size: 20px !important; text-align: center; }
.qr { display: grid; place-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin: 8px 0 12px; }
.qr svg { width: 190px; height: 190px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg); padding: 8px 10px; border-radius: 8px; word-break: break-all; }
.hint { font-size: 13px; color: var(--ink-3); }
.err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 9px; margin: 0 0 14px; font-size: 14px; }
.okmsg { background: var(--ok-soft); color: var(--ok); padding: 10px 12px; border-radius: 9px; margin: 0 0 14px; font-size: 14px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px; cursor: pointer; text-decoration: none; font-weight: 550; font-size: 14px; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: #fafaf7; border-color: #d4d7d0; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: #2b3a32; }
.btn.block { width: 100%; padding: 11px 14px; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn.danger { color: var(--bad); }
.btn.link { border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; font-weight: 500; }
.btn[disabled] { opacity: 0.55; cursor: default; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #e9ece7; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; padding: 0 8px 18px; }
.side .brand .mark { background: #2e3c34; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; text-decoration: none; color: #c9cfc8; font-weight: 520; }
.nav a:hover { background: #29362f; color: #fff; }
.nav a.on { background: #33433a; color: #fff; }
.nav .soon { margin-left: auto; font-size: 11px; color: #8d978f; border: 1px solid #44534a; border-radius: 99px; padding: 0 7px; }
.side .grow { flex: 1; }
.side .who { font-size: 13px; color: #aab3ab; padding: 10px; border-top: 1px solid #34433a; }
.side .who b { color: #fff; font-weight: 550; display: block; overflow: hidden; text-overflow: ellipsis; }
.main { padding: 28px 34px 60px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 22px; margin: 0; letter-spacing: -0.2px; }
.topbar .crumbs { color: var(--ink-3); font-size: 14px; }
.topbar .crumbs a { text-decoration: none; color: var(--ink-2); }
.topbar .spacer { flex: 1; }

/* ---------- cards, stats, tables ---------- */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card .head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card .head h2 { margin: 0; }
.card .head .spacer { flex: 1; }
.stat .k { font-size: 13px; color: var(--ink-3); }
.stat .v { font-size: 26px; font-weight: 650; letter-spacing: -0.5px; margin-top: 2px; }
.stat .v small { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.section { margin-top: 22px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 560; color: var(--ink-3); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.t td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #fafaf6; }
.t .num { text-align: right; font-variant-numeric: tabular-nums; }
.t .actions { text-align: right; white-space: nowrap; }
.t .actions .btn + .btn { margin-left: 6px; }
.muted { color: var(--ink-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.empty { color: var(--ink-3); padding: 18px 4px; text-align: center; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--bg); color: var(--ink-2); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.gold { background: var(--accent-soft); color: #7d5a1e; }
.bar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin: 0; flex: 1; min-width: 180px; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }
.banner.info { background: var(--info-soft); color: var(--info); }

/* ---------- plans / viewer ---------- */
.plan-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.plan-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.plan-card .art { height: 130px; background: linear-gradient(135deg, #2b3a32, #4b5d52); display: grid; place-items: center; color: #e8c98f; }
.plan-card .art svg { width: 54px; height: 54px; opacity: 0.9; }
.plan-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.plan-card .name { font-weight: 620; font-size: 16px; }
.plan-card .row { display: flex; gap: 8px; align-items: center; margin-top: auto; }
.soon-card { border: 1.5px dashed #d6d6cf; border-radius: var(--radius); padding: 18px 20px; color: var(--ink-3); background: transparent; }
.soon-card b { color: var(--ink-2); display: block; margin-bottom: 4px; }
.viewer-wrap { position: fixed; inset: 0; background: #111; display: flex; flex-direction: column; z-index: 20; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--brand); color: #fff; }
.viewer-bar .btn { background: #2e3c34; color: #fff; border-color: #44534a; }
.viewer-bar .title { font-weight: 600; }
.viewer-bar .spacer { flex: 1; }
.viewer-wrap iframe { flex: 1; border: 0; width: 100%; background: #111; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; z-index: 50; }
dialog { border: 0; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); padding: 22px; max-width: 520px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(20, 26, 22, 0.35); }
dialog h3 { margin: 0 0 10px; }
.copybox { display: flex; gap: 8px; }
.copybox input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px; }
  .side .brand { padding: 0 8px; }
  .side .grow, .side .who { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .main { padding: 18px 14px 50px; }
}
