:root {
    color-scheme: light;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --text: #17202a;
    --muted: #64748b;
    --line: #d9e2ec;
    --primary: #176b87;
    --primary-dark: #10536b;
    --success: #16794c;
    --warning: #a56300;
    --danger: #b42318;
    --shadow: 0 12px 30px rgba(27, 39, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.auth-body {
    display: grid;
    place-items: center;
    padding: 32px 16px;
}

.auth-shell {
    width: min(440px, 100%);
}

.auth-panel,
.panel,
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel {
    padding: 28px;
}

.auth-panel h1 {
    margin: 0 0 20px;
    font-size: 26px;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--primary);
    color: white;
}

.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.nav a {
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--muted);
}

.nav a.active {
    background: var(--surface-2);
    color: var(--primary);
    font-weight: 700;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-head h1 {
    margin: 0;
    font-size: 28px;
}

.page-head p {
    margin: 6px 0 0;
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.span-4 {
    grid-column: span 4;
}

.span-8 {
    grid-column: span 8;
}

.span-12 {
    grid-column: span 12;
}

.panel,
.card {
    padding: 20px;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric small,
.muted {
    color: var(--muted);
}

.metric strong {
    font-size: 30px;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--text);
    font: inherit;
}

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

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 6px;
    font: inherit;
    cursor: pointer;
}

.button.primary {
    background: var(--primary);
    color: white;
}

.button.primary:hover {
    background: var(--primary-dark);
}

.button.secondary {
    background: var(--surface-2);
    color: var(--text);
    border-color: var(--line);
}

.button.danger {
    background: #fff1f0;
    color: var(--danger);
    border-color: #ffccc7;
}

.button.full {
    width: 100%;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.notice {
    margin: 0 0 14px;
    padding: 11px 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
}

.notice.success {
    background: #ecfdf3;
    color: var(--success);
    border-color: #abefc6;
}

.notice.danger,
.notice.error {
    background: #fff1f0;
    color: var(--danger);
    border-color: #ffccc7;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    background: #fbfcfe;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-ok {
    color: var(--success);
    background: #ecfdf3;
}

.badge-warn {
    color: var(--warning);
    background: #fff7e6;
}

.badge-danger {
    color: var(--danger);
    background: #fff1f0;
}

.badge-muted {
    color: var(--muted);
    background: var(--surface-2);
}

.inline-form {
    display: inline;
}

.qr-preview {
    display: grid;
    gap: 8px;
}

.qr-preview img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
}

.qr-thumb {
    display: inline-flex;
    margin-top: 8px;
}

.qr-thumb img {
    width: 86px;
    height: 86px;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
}

.auth-switch {
    margin-top: 16px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 820px) {
    .topbar,
    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .span-4,
    .span-8,
    .span-12 {
        grid-column: span 12;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 12px 14px;
        gap: 12px;
    }

    .brand {
        width: 100%;
    }

    .nav {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
        padding: 8px;
        text-align: center;
    }

    .container {
        width: min(100% - 20px, 1180px);
        margin: 16px auto 32px;
    }

    .page-head h1 {
        font-size: 24px;
    }

    .panel,
    .card,
    .auth-panel {
        padding: 16px;
        border-radius: 6px;
    }

    .metric strong {
        font-size: 24px;
    }

    .actions {
        width: 100%;
    }

    .actions .button,
    .actions input {
        flex: 1 1 140px;
    }

    .button.full,
    .form-stack .button,
    .form-grid .button {
        width: 100%;
    }

    input,
    select,
    textarea,
    .button {
        min-width: 0;
        max-width: 100%;
    }

    table {
        min-width: 680px;
    }
}

@media (max-width: 420px) {
    .nav {
        grid-template-columns: 1fr;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
    }

    .auth-body {
        padding: 16px 10px;
    }

    th,
    td {
        padding: 10px 8px;
    }
}
