:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-strong: #ffffff;
    --text: #162032;
    --muted: #61708a;
    --border: rgba(28, 43, 76, 0.12);
    --primary: #1366d6;
    --primary-soft: rgba(19, 102, 214, 0.14);
    --success: #138a52;
    --warning: #b7791f;
    --danger: #c53030;
    --shadow: 0 20px 60px rgba(13, 28, 56, 0.08);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0d1422;
    --surface: rgba(16, 25, 42, 0.84);
    --surface-strong: #131d31;
    --text: #edf2ff;
    --muted: #9eacc8;
    --border: rgba(163, 181, 226, 0.14);
    --primary: #69a9ff;
    --primary-soft: rgba(105, 169, 255, 0.18);
    --success: #3ecf8e;
    --warning: #f6ad55;
    --danger: #fc8181;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(19, 102, 214, 0.18), transparent 28%),
        radial-gradient(circle at top right, rgba(19, 138, 82, 0.14), transparent 24%),
        var(--bg);
    color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.site-shell { min-height: 100vh; display: flex; flex-direction: column; }
.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.55);
    border-bottom: 1px solid var(--border);
}
html[data-theme="dark"] .site-header { background: rgba(13, 20, 34, 0.65); }
.nav-bar, .footer-inner, .hero, .stats, .toolbar, .table-wrap, .detail-grid, .gallery {
    display: flex;
}
.nav-bar {
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    gap: 16px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #17a1b9);
    color: #fff;
    font-weight: 800;
}
.nav-links { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 84px;
}
.theme-toggle, .btn, button, input, select, textarea { font: inherit; }
.theme-toggle, .btn, button {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    color: var(--text);
    padding: 10px 14px;
    cursor: pointer;
    transition: 0.2s ease;
}
.btn:hover, button:hover, .theme-toggle:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-secondary { background: var(--surface); }
.main-content { flex: 1; padding: 28px 0 48px; }
.hero {
    gap: 24px;
    padding: 32px;
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    align-items: stretch;
    justify-content: space-between;
}
.hero-copy { flex: 1; }
.hero-copy h1 { margin: 0 0 12px; font-size: clamp(1.9rem, 3vw, 3rem); }
.hero-copy p { margin: 0 0 20px; color: var(--muted); line-height: 1.7; }
.hero-card, .panel, .auth-card, .empty-state, .stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 24px;
}
.hero-card, .panel, .auth-card, .empty-state { padding: 24px; }
.hero-card { min-width: 280px; }
.badge, .status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
}
.stats, .detail-grid, .gallery, .toolbar { gap: 18px; }
.stats, .detail-grid { flex-wrap: wrap; }
.stat-card, .panel { flex: 1 1 220px; }
.stat-card { padding: 22px; }
.stat-card .value { font-size: 2rem; font-weight: 800; margin-top: 8px; }
.panel h2, .panel h3, .auth-card h1, .hero-card h3 { margin-top: 0; }
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group.full { grid-column: 1 / -1; }
.required-mark {
    color: var(--danger);
    margin-left: 4px;
    font-weight: 700;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    border-radius: 14px;
    padding: 12px 14px;
}
textarea { min-height: 120px; resize: vertical; }
input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0;
    border-radius: 6px;
    vertical-align: middle;
    flex: 0 0 auto;
    accent-color: var(--primary);
}
label > input[type="checkbox"],
label > input[type="radio"] {
    margin-right: 8px;
}
p > label:has(> input[type="checkbox"]),
p > label:has(> input[type="radio"]) {
    display: inline-flex;
    align-items: center;
}
.toolbar {
    margin-bottom: 16px;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}
form .toolbar {
    margin-top: 18px;
}
form .toolbar:last-child {
    margin-bottom: 0;
}
.table-wrap {
    overflow: auto;
    border-radius: 20px;
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
    background: var(--surface);
}
th, td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
th { color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.detail-grid .panel { min-width: 280px; }
.gallery { flex-wrap: wrap; }
.gallery a {
    width: 120px;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--border);
}
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.muted { color: var(--muted); }
.alert {
    margin: 20px auto 0;
    padding: 14px 18px;
    border-radius: 16px;
    border: 1px solid transparent;
}
.alert-success {
    background: rgba(19, 138, 82, 0.12);
    color: var(--success);
    border-color: rgba(19, 138, 82, 0.2);
}
.alert-danger {
    background: rgba(197, 48, 48, 0.12);
    color: var(--danger);
    border-color: rgba(197, 48, 48, 0.2);
}
.alert-warning {
    background: rgba(183, 121, 31, 0.12);
    color: var(--warning);
    border-color: rgba(183, 121, 31, 0.2);
}
.auth-wrap { max-width: 560px; margin: 32px auto; }
.empty-state {
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 180px;
}
.site-footer { padding: 20px 0 30px; }
.footer-inner {
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.92rem;
}
.batch-dialog {
    width: min(560px, calc(100% - 24px));
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 0;
    background: var(--surface-strong);
    color: var(--text);
    box-shadow: var(--shadow);
}
.batch-dialog::backdrop {
    background: rgba(10, 18, 34, 0.45);
}
.batch-dialog-form {
    padding: 24px;
}
@media (max-width: 860px) {
    .hero, .footer-inner { flex-direction: column; align-items: stretch; }
    .form-grid { grid-template-columns: 1fr; }
    .nav-bar {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        padding: 14px 0;
    }
    .brand {
        flex: 1;
        min-width: 0;
    }
    .nav-toggle {
        display: inline-flex;
    }
    .nav-links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding-top: 14px;
        margin-top: 8px;
        border-top: 1px solid var(--border);
    }
    .nav-links.is-open {
        display: flex;
    }
    .nav-links a,
    .nav-links .theme-toggle {
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 12px 14px;
        border-radius: 14px;
        background: var(--surface);
        border: 1px solid var(--border);
    }
    .nav-links .theme-toggle {
        display: inline-flex;
        justify-content: center;
    }
}

@media (min-width: 861px) {
    .nav-links {
        display: flex !important;
    }
}
