/* Celmir console: the merchant cabinet (light rail) and the admin panel (dark rail). */
:root {
  --paper: #f4f5f2;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #5d6a64;
  --line: #d9dfdb;
  --accent: #0f5c4a;
  --accent-hover: #0b4a3c;
  --accent-soft: #e2eee8;
  --ok: #1d7a4f;
  --ok-soft: #e3f2ea;
  --warn: #8a5207;
  --warn-soft: #fbf0dc;
  --bad: #a8261d;
  --bad-soft: #fbe7e5;
  --wait: #2f5d8a;
  --wait-soft: #e4edf6;
  --rail: #ffffff;
  --rail-ink: var(--ink);
  --rail-muted: var(--muted);
  --rail-active: var(--accent-soft);
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--paper);
}
.realm-staff {
  --rail: #15201c;
  --rail-ink: #eef3f0;
  --rail-muted: #9fb0a8;
  --rail-active: #24352e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); }
.boot { padding: 2rem; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.rail { background: var(--rail); color: var(--rail-ink); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 18px; }
.realm-staff .rail { border-right: 0; }
.brand { padding: 0 10px; }
.brand b { font-size: 1.15rem; letter-spacing: -0.01em; }
.brand span { display: block; color: var(--rail-muted); font-size: 0.82rem; margin-top: 2px; }
.realm-staff .brand span { color: #f0c36a; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--rail-ink); text-decoration: none; padding: 8px 10px; border-radius: 6px; }
.nav a:hover { background: var(--rail-active); }
.nav a[aria-current="page"] { background: var(--rail-active); font-weight: 600; }
.who { margin-top: auto; padding: 0 10px; font-size: 0.85rem; color: var(--rail-muted); word-break: break-all; }
.who button { margin-top: 8px; }
.main { padding: 28px 32px 48px; min-width: 0; }
.main > h1 { font-size: 1.45rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .who { margin: 0 0 0 auto; }
  .main { padding: 20px 16px 40px; }
}

/* ---------- controls ---------- */
button, .btn {
  font: inherit; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-block;
}
button:hover { border-color: #b9c3be; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--bad); border-color: #e4b8b4; }
button.danger.primary { background: var(--bad); color: #fff; border-color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
.realm-staff .who button { background: transparent; color: var(--rail-ink); border-color: #3b4f46; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 2px solid #2f7dd1; outline-offset: 2px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0;
}
textarea { width: 100%; min-height: 110px; font-family: var(--mono); font-size: 0.9rem; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--ink); font-size: 0.95rem; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.filters { margin-bottom: 16px; }
.hint { font-size: 0.85rem; color: var(--muted); }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 6px; padding: 8px 12px; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 6px; padding: 10px 12px; }
.mono { font-family: var(--mono); font-size: 0.88rem; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- tables and panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 20px; }
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; }
.panel h3 { font-size: 0.95rem; margin: 18px 0 8px; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 0.8rem; font-weight: 600; color: var(--muted); background: #fafbfa; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f6f9f7; }
.panel table th { background: none; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.more { margin-top: 12px; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.badge.success, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.fail, .badge.disabled, .badge.revoked { background: var(--bad-soft); color: var(--bad); }
.badge.in_progress, .badge.waiting_for_payer { background: var(--wait-soft); color: var(--wait); }
.badge.test { background: var(--warn-soft); color: var(--warn); }
.badge.live { background: var(--accent-soft); color: var(--accent); }

.figures { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 20px; }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.figure .t { font-size: 0.85rem; color: var(--muted); }
.figure .v { font-size: 1.5rem; font-variant-numeric: tabular-nums; margin: 4px 0 2px; letter-spacing: -0.01em; }
.figure.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 0.88rem; }
dl.kv dd { margin: 0; word-break: break-all; }

/* ---------- drawer (payment detail) and dialogs ---------- */
.scrim { position: fixed; inset: 0; background: rgba(23, 33, 29, 0.32); z-index: 10; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: var(--surface); z-index: 11; overflow-y: auto; padding: 22px 24px; box-shadow: -8px 0 24px rgba(0,0,0,0.12); }
.drawer header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.drawer h2 { margin: 0; font-size: 1.15rem; }
.dialog { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(480px, calc(100vw - 32px)); background: var(--surface); z-index: 12; border-radius: var(--radius); padding: 22px 24px; box-shadow: 0 12px 40px rgba(0,0,0,0.2); }
.dialog h2 { margin: 0 0 10px; font-size: 1.1rem; }
.secret { font-family: var(--mono); background: #f1f4f2; border: 1px dashed #b9c3be; border-radius: 6px; padding: 10px 12px; word-break: break-all; user-select: all; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px; }
.auth h1 { font-size: 1.3rem; margin: 0 0 4px; }
.auth .side { color: var(--muted); margin: 0 0 20px; }
.realm-staff .auth .side { color: var(--warn); font-weight: 600; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth button.primary { padding: 10px; }
.code-input { font-family: var(--mono); letter-spacing: 0.3em; font-size: 1.2rem; }
ol.steps { padding-left: 1.2rem; margin: 0 0 16px; }
ol.steps li { margin-bottom: 8px; }

@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slide 140ms ease-out; }
  @keyframes slide { from { transform: translateX(24px); } to { transform: none; } }
}

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 20; font-size: 0.92rem; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 8px; }
.section-head h3 { margin: 0; }
button.figure { text-align: left; width: 100%; }
button.figure:hover { border-color: #b9c3be; }
.stack > p { margin: 0; }
