/* Same dark surfaces and accents as the Maplecord app. */
:root {
  --bg0: #0b0b10;
  --bg1: #14141c;
  --bg2: #1c1c27;
  --bg3: #262634;
  --border: #2e2e3e;
  --text: #e8e8f0;
  --muted: #9a9ab0;
  --accent: #9000ff;
  --accent2: #00ddff;
  --green: #2cfc00;
  --amber: #f19511;
  --red: #ff3b3b;
  color-scheme: dark;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg1); color: var(--text); }
h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; line-height: 1.5; }
a { color: var(--accent2); }
code { font-family: Consolas, ui-monospace, monospace; background: var(--bg0); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 13px; overflow-wrap: anywhere; }

button { font: inherit; color: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--bg3); border-radius: 4px; padding: 6px 12px; font-weight: 600; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.4; cursor: default; filter: none; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
button.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.subtle { background: transparent; border-color: transparent; color: var(--muted); padding: 4px 8px; }
button.subtle:hover { color: var(--text); background: var(--bg3); }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg0); border: 1px solid var(--border); border-radius: 4px; padding: 7px 9px; min-width: 0; }
textarea { resize: vertical; min-height: 80px; width: 100%; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.hidden { display: none !important; }
.mono { font-family: Consolas, ui-monospace, monospace; }

/* ---- Sign-in and second step ---- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 24px; background: var(--bg0); }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 24px; width: min(440px, 100%); display: grid; gap: 16px; }
.card .buttons { display: grid; gap: 8px; }
.card .buttons button { padding: 10px; }
.qr { background: #fff; border-radius: 6px; padding: 8px; width: 196px; max-width: 100%; height: auto; aspect-ratio: 1; justify-self: center; }
.card > *, .card form > * { min-width: 0; }
.code-input { font-size: 22px; letter-spacing: 0.3em; text-align: center; font-family: Consolas, ui-monospace, monospace; width: 100%; }
.recovery { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: Consolas, ui-monospace, monospace; font-size: 15px; background: var(--bg0); border: 1px solid var(--border); border-radius: 6px; padding: 12px; }
.notice { border-radius: 6px; padding: 10px 12px; border: 1px solid var(--border); background: var(--bg0); }
.notice.bad { border-color: var(--red); color: #ffb3b3; }
.notice.good { border-color: #2b8a1a; color: #b9f5ac; }
.notice.warn { border-color: var(--amber); color: #ffd9a0; }

/* ---- Panel ---- */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100%; }
.side { background: var(--bg0); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 8px; gap: 2px; overflow-y: auto; }
.brand { padding: 0 10px 14px; display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 16px; }
.brand img, .gate-brand img { flex: none; object-fit: contain; }
.gate-brand { display: flex; align-items: center; gap: 12px; }
.side button.nav { text-align: left; background: transparent; border-color: transparent; color: var(--muted); padding: 8px 10px; font-weight: 500; }
.side button.nav:hover { background: var(--bg2); color: var(--text); filter: none; }
.side button.nav[aria-current="page"] { background: var(--bg3); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side .who { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); display: grid; gap: 6px; }
.main { overflow-y: auto; padding: 24px; }
.page { max-width: 1040px; display: grid; gap: 20px; }
.page > header { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 16px; display: grid; gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: grid; gap: 2px; }
.stat .value { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }

.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.chart { background: var(--bg2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: grid; gap: 6px; }
.chart .head { display: flex; justify-content: space-between; align-items: baseline; }
.chart .now { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart svg { width: 100%; height: 56px; display: block; }
.chart polyline { fill: none; stroke: var(--accent2); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.chart polygon { fill: var(--accent2); opacity: 0.12; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button { margin-left: 6px; }
.table-wrap { overflow-x: auto; }
.name b { font-weight: 600; }
.name span { display: block; font-size: 12px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 2px 9px; font-size: 12px; border: 1px solid var(--border); background: var(--bg0); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.good::before { background: var(--green); }
.pill.bad::before { background: var(--red); }
.pill.warn::before { background: var(--amber); }
.pill.plain::before { display: none; }

.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--bg3); border: 1px solid var(--border); pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform 0.12s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--accent2); outline-offset: 2px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }

dialog { background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog form { display: grid; gap: 14px; }
dialog .end { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 10px 14px; max-width: 420px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5); }
.toast.bad { border-color: var(--red); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: none; border-bottom: 1px solid var(--border); padding: 8px; }
  .brand, .side .who { display: none; }
  .main { padding: 16px; }
}
