:root {
    --ink: #1c1915;
    --muted: #5e584f;
    --paper: #f3efe7;
    --card: #fbfaf6;
    --line: #e3dcd0;
    --side: #1c2822;
    --side-text: #e7e1d6;
    --brass: #8d6840;
    --brass-deep: #6d4e2e;
    --good: #1d6b45;
    --danger: #8d2f2f;
    --shadow: 0 16px 40px rgba(40, 32, 20, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Avenir Next", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    color: var(--ink);
    background: var(--paper);
    font-size: 15px;
    line-height: 1.5;
}
code, pre {
    font-family: "IBM Plex Mono", "Source Code Pro", "SFMono-Regular", ui-monospace, monospace;
}
a { color: var(--brass-deep); }
h1, h2 { font-weight: 560; letter-spacing: -0.02em; }
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 18px; margin: 28px 0 12px; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
    background: var(--side);
    color: var(--side-text);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: white;
    text-decoration: none;
    font-size: 16px;
}
.brand span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    background: #c6a36a;
    color: #1c1915;
    border-radius: 8px;
    font-weight: 700;
}
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a {
    color: var(--side-text);
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 8px;
}
.side nav a.active, .side nav a:hover { background: rgba(255,255,255,0.08); }
.logout { margin-top: auto; }
.logout button {
    width: 100%;
    background: transparent;
    color: #cfc6b8;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
}
.main { padding: 28px 32px 64px; max-width: 1180px; }
.top { margin-bottom: 18px; }

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 6px; font-size: 22px; font-variant-numeric: tabular-nums; }

.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.grid th, .grid td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
.grid th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f7f4ee; }
.grid td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid tr.sub td { color: var(--danger); font-size: 13px; background: #fbf6f4; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.split { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.row { display: flex; gap: 12px; align-items: end; }
.row.wrap { flex-wrap: wrap; }
.row header, .card header.row { display: flex; justify-content: space-between; align-items: center; }
.card header h2 { margin: 0; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
    font: inherit;
    color: var(--ink);
    background: white;
    border: 1px solid #d9d1c4;
    border-radius: 8px;
    padding: 9px 10px;
}
.tiny-input { width: 88px; padding: 6px 8px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; }
fieldset.stack {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0;
}
fieldset.stack legend {
    padding: 0 6px;
    color: var(--ink);
    font-size: 13px;
}

.btn {
    font: inherit;
    background: var(--ink);
    color: #f6f1e8;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    cursor: pointer;
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid #cfc6b8; }
.btn.danger { background: var(--danger); }
.btn.tiny { padding: 4px 10px; font-size: 13px; }
.btn:hover { background: #000; }
.btn.secondary:hover { background: #f6f1e8; }
.btn.danger:hover { background: #6f2222; }

.banner, .hint {
    background: #f3ead7;
    border: 1px solid #e2d2b0;
    color: #4d3b22;
    border-radius: 12px;
    padding: 12px 14px;
}
.alert {
    background: #f8ecec;
    color: var(--danger);
    border-radius: 12px;
    padding: 12px 14px;
}
.lede { color: var(--muted); max-width: 68ch; }
.fine, .fine-list { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); }
.result { font-variant-numeric: tabular-nums; }
.inline-form { margin-top: 22px; }
pre {
    background: #17211c;
    color: #f3ecdf;
    padding: 16px;
    border-radius: 14px;
    overflow: auto;
    line-height: 1.45;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, rgba(198, 163, 106, 0.28), transparent 32%),
        var(--paper);
}
.login-card {
    width: min(440px, calc(100% - 32px));
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.eyebrow { margin: 0; color: var(--brass); letter-spacing: 0.08em; font-size: 12px; text-transform: uppercase; }
.login-card h1 { margin: 8px 0; }
.hint { margin-top: 18px; }
.hint p { margin: 6px 0; }

@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .side { padding: 14px; }
    .side nav { flex-direction: row; flex-wrap: wrap; }
    .logout { margin-top: 0; }
    .logout button { width: auto; }
    .main { padding: 18px 14px 48px; }
    .stats, .split { grid-template-columns: 1fr; }
    .grid { display: block; overflow-x: auto; }
}
