:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1b1f24;
    --muted: #5d6673;
    --line: #dde1e7;
    --accent: #1f5fbf;
    --good: #14803c;
    --bad: #b42318;
    --warn: #a15c00;
    --paper: #6b4fbb;
    --live: #b42318;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101318;
        --surface: #181c23;
        --text: #e8ebf0;
        --muted: #9aa4b2;
        --line: #2b323d;
        --accent: #6aa5ff;
        --good: #4cc27a;
        --bad: #ff7b72;
        --warn: #e3a03a;
        --paper: #a99bff;
        --live: #ff7b72;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--accent); }

h1 { font-size: 1.4rem; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.1rem; margin: 1.4rem 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.4rem; }

main { padding: 0 16px 48px; max-width: 72rem; margin: 0 auto; }

header.top {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.logout { margin-left: auto; }

.badge { font-weight: 700; padding: 2px 10px; border-radius: 999px; border: 2px solid currentColor; }
.badge.paper { color: var(--paper); }
.badge.live { color: var(--live); }
.pending { color: var(--warn); font-size: 0.9rem; }

.picker summary { cursor: pointer; }
.picker ul { list-style: none; margin: 6px 0 0; padding: 0; }
.picker li { padding: 4px 0; }
.picker .current { font-weight: 700; }

.nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; white-space: nowrap; color: var(--text); }
.nav a.active { background: var(--accent); color: #fff; }

.card, .account .card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin: 12px 0;
}

main.account { max-width: 26rem; padding-top: 32px; }
.brand { font-weight: 700; letter-spacing: 0.04em; margin: 0 0 8px; color: var(--muted); }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
.grid > .card { margin: 0; }

.big { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 0.9rem; }
.good { color: var(--good); }
.bad, .error { color: var(--bad); }
.warn { color: var(--warn); }
.ok { color: var(--good); }

.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--good); }

label { display: block; margin: 10px 0; font-weight: 600; font-size: 0.95rem; }
label.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 400; }
input, select, textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 9px 10px;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
}
input[type=checkbox], input[type=radio] { display: inline-block; width: auto; margin: 0 6px 0 0; }
textarea { min-height: 5rem; }

button, a.button {
    display: inline-block;
    padding: 9px 16px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button.danger { background: var(--bad); }
button.link { background: none; color: var(--accent); padding: 4px 0; font-weight: 400; text-decoration: underline; }
button:disabled { opacity: 0.6; cursor: progress; }

.row { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); align-items: end; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; align-items: center; }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }

@media (max-width: 640px) {
    table, thead, tbody, tr, th, td { display: block; }
    thead { position: absolute; left: -9999px; }
    tr { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; padding: 6px 10px; }
    td { border: 0; display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; text-align: right; }
    td::before { content: attr(data-label); color: var(--muted); font-weight: 600; text-align: left; }
}

.codes { columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; }
.qr { max-width: 14rem; background: #fff; padding: 8px; border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
pre { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; }

.chat .q { margin: 12px 0 2px; font-weight: 600; }
.chat .a { margin: 0 0 14px; padding: 8px 10px; background: var(--bg); border-radius: 8px; white-space: pre-wrap; }
.chip { display: inline-block; padding: 0 8px; border-radius: 999px; background: var(--line); font-size: 0.8rem; }
.check { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
ul.plain li:last-child { border-bottom: 0; }
