:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #697386;
    --line: #e3e8f1;
    --primary: #1976d2;
    --primary-dark: #115aa3;
    --success: #0f8f61;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}

.app-page { display: flex; min-height: 100vh; }
.sidebar {
    width: 232px;
    background: #111827;
    color: #fff;
    padding: 24px 16px;
    flex-shrink: 0;
}
.brand { font-size: 20px; font-weight: 700; margin-bottom: 28px; }
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 8px;
    font-size: 15px;
}
.sidebar a:hover, .sidebar a.active { background: #243044; color: #fff; }
.main { flex: 1; padding: 28px; min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}
.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 13px;
    letter-spacing: 0;
}
h1, h2 { margin: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; margin-bottom: 16px; }
.button {
    border: 0;
    background: var(--primary);
    color: #fff;
    padding: 11px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}
.button:hover { background: var(--primary-dark); }
.button.secondary { background: #e8eef7; color: #243044; }
.button.danger { background: #dc2626; }
.button.danger:hover { background: #b91c1c; }
.button.mini {
    padding: 7px 10px;
    font-size: 13px;
}
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.actions, .table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.actions.centered { justify-content: center; margin-top: 14px; }
.table-actions form { margin: 0; }
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}
.panel-head h2 { margin-bottom: 0; }
.ops-col { width: 124px; }
.op-group {
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    border: 1px solid #d7deea;
    border-radius: 8px;
    background: #fff;
    white-space: nowrap;
}
.op-group form { margin: 0; }
.op-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    height: 30px;
    padding: 0 10px;
    border: 0;
    border-right: 1px solid #d7deea;
    background: #fff;
    color: #2563eb;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}
.op-group > *:last-child .op-btn,
.op-group > .op-btn:last-child { border-right: 0; }
.op-btn:hover { background: #f4f7fb; }
.op-btn.danger-text { color: #dc2626; }
.scan-panel { text-align: center; }
.qr-box {
    display: inline-grid;
    place-items: center;
    width: 252px;
    height: 252px;
    margin: 8px auto 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.qr-box img {
    display: block;
    width: 220px;
    height: 220px;
}
.muted {
    color: var(--muted);
    line-height: 1.7;
    margin: 8px 0 0;
}
.top-gap { margin-top: 14px; }
.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.metrics div, .panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.metrics div { padding: 20px; }
.metrics span { font-size: 30px; font-weight: 800; }
.metrics p { margin: 8px 0 0; color: var(--muted); }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: minmax(320px, .8fr) minmax(0, 1.2fr); align-items: start; }
.stack { display: grid; gap: 18px; }
.panel { padding: 20px; overflow: auto; }
.form { display: grid; gap: 13px; }
label { display: grid; gap: 7px; color: #374151; font-size: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid #ccd5e1;
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
}
textarea { resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}
th { color: var(--muted); font-weight: 700; background: #fafbfe; }
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    background: #edf6ff;
    color: #145da0;
    font-size: 12px;
    white-space: nowrap;
}
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: #eef3f9;
}
.login-shell { width: min(420px, calc(100vw - 32px)); }
.login-panel {
    display: grid;
    gap: 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 18px 40px rgba(17, 24, 39, .12);
}
.login-panel h1 { font-size: 26px; }
.login-panel p { margin: 0; color: var(--muted); }
.alert {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}
.notice {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.notice.success {
    color: #166534;
    background: #ecfdf3;
    border-color: #bbf7d0;
}
.notice.error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

@media (max-width: 900px) {
    .app-page { display: block; }
    .sidebar { width: 100%; padding: 16px; }
    .sidebar nav { grid-template-columns: repeat(3, 1fr); }
    .main { padding: 18px; }
    .topbar { align-items: flex-start; }
    .metrics { grid-template-columns: repeat(2, 1fr); }
    .grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .sidebar nav { grid-template-columns: repeat(2, 1fr); }
    .metrics { grid-template-columns: 1fr; }
    .row { grid-template-columns: 1fr; }
    .topbar { display: grid; }
}
