:root {
    --bg: #f4f0ea;
    --paper: #fffdf9;
    --ink: #241c18;
    --muted: #74685f;
    --line: #e6ddd3;
    --wine: #8c2f39;
    --wine-dark: #6e2430;
    --sidebar: #1c1714;
    --ok: #1d7a3a;
    --ok-bg: #e7f6ec;
    --warn: #8a5a00;
    --warn-bg: #fdecc8;
    --danger: #8c2f39;
    --danger-bg: #f8e6e4;
    --shadow: 0 10px 30px rgba(36, 28, 24, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--wine); text-decoration: none; }
a:hover { text-decoration: underline; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex: none;
    background: var(--sidebar);
    color: #f6efe8;
    padding: 24px 16px;
}

.brand { padding: 0 10px 22px; }
.brand strong { display: block; font-size: 18px; letter-spacing: 0.04em; }
.brand span { color: #b7a89d; font-size: 12px; }

.sidebar a {
    display: block;
    color: #e7ddd4;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.sidebar a.active,
.sidebar a:hover { background: rgba(255, 255, 255, 0.08); color: white; text-decoration: none; }

.main { flex: 1; min-width: 0; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 28px;
    background: rgba(255, 253, 249, 0.9);
    border-bottom: 1px solid var(--line);
}

.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; }

.content { padding: 24px 28px 48px; }

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 18px;
    margin-bottom: 16px;
}

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat strong { display: block; font-size: 24px; margin-top: 4px; }
.stat span { color: var(--muted); font-size: 12px; }

.row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.grow { flex: 1; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }

input[type="radio"],
input[type="checkbox"] { width: auto; }

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: white;
    border-radius: 8px;
    padding: 9px 10px;
    color: var(--ink);
    font: inherit;
}

textarea { min-height: 140px; resize: vertical; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    background: var(--wine);
    color: white;
    padding: 9px 14px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}

button:hover, .button:hover { background: var(--wine-dark); text-decoration: none; }

.button.ghost, button.ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 12px;
    background: #eee;
    color: #555;
}
.badge-matched, .badge-settled, .badge-active { background: var(--ok-bg); color: var(--ok); }
.badge-conflict, .badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-unmatched, .badge-disabled, .badge-cancelled { background: var(--danger-bg); color: var(--danger); }

.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.success { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--danger-bg); color: var(--danger); }

.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; }
.muted { color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); }
.hint { color: var(--muted); font-size: 12px; margin-top: 12px; }
.split { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 16px; }
.field { margin-bottom: 12px; }

@media (max-width: 960px) {
    .shell { display: block; }
    .sidebar { width: auto; }
    .grid, .split { grid-template-columns: 1fr; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
