* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: #17211b;
    background: #f5f7f4;
}

body {
    min-height: 100vh;
    margin: 0;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: #eef3ee;
}

.auth-box {
    width: min(420px, 100%);
    padding: 28px;
    border: 1px solid #dfe7df;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(20, 32, 22, 0.08);
}

.auth-box h1,
.admin-head h1,
.panel h1,
.panel h2,
.public-card h1 {
    margin: 0;
    line-height: 1.2;
}

.auth-box p,
.admin-head p,
.public-card p {
    margin: 10px 0 0;
    color: #607066;
}

.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 22px;
}

.stack-form label {
    display: grid;
    gap: 8px;
    color: #334038;
    font-size: 14px;
    font-weight: 650;
}

.stack-form input,
.stack-form select,
.stack-form textarea {
    width: 100%;
    border: 1px solid #d7e0d7;
    border-radius: 8px;
    padding: 12px 13px;
    color: #16231a;
    background: #fff;
    outline: none;
}

.stack-form textarea {
    resize: vertical;
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
    border-color: #1b8f5a;
    box-shadow: 0 0 0 3px rgba(27, 143, 90, 0.14);
}

.primary-btn,
.ghost-btn,
.danger-btn {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

.primary-btn {
    color: #fff;
    background: #147a4c;
}

.ghost-btn {
    border: 1px solid #ccd8cd;
    color: #1f2a23;
    background: #fff;
}

.danger-btn {
    color: #fff;
    background: #c73737;
}

.danger-link {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    color: #b62b2b;
    font-weight: 750;
}

.notice {
    margin: 16px 0;
    border-radius: 8px;
    padding: 12px 14px;
}

.notice.error {
    border: 1px solid #f0c5c5;
    color: #8d2424;
    background: #fff1f1;
}

.notice.success {
    border: 1px solid #bee5cf;
    color: #147a4c;
    background: #ecf8f1;
}

.admin-page {
    background: #f6f8f6;
}

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid #e1e8e1;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

.brand {
    color: #142019;
    font-size: 18px;
    font-weight: 850;
    text-decoration: none;
}

.admin-topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.admin-topbar nav a {
    color: #314038;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.admin-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 56px;
}

.admin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.metric-grid.wide {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-grid div,
.panel,
.table-wrap,
.empty-state {
    border: 1px solid #e0e7e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(24, 34, 26, 0.05);
}

.metric-grid div {
    padding: 18px;
}

.metric-grid b {
    display: block;
    font-size: 30px;
    line-height: 1;
}

.metric-grid span {
    display: block;
    margin-top: 8px;
    color: #637267;
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
}

.table-wrap.spaced {
    margin-top: 18px;
}

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

th,
td {
    border-bottom: 1px solid #edf1ed;
    padding: 15px 16px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: #607066;
    font-size: 13px;
    font-weight: 750;
}

td strong {
    display: block;
    color: #17211b;
}

td small {
    display: block;
    margin-top: 5px;
    color: #6d7b70;
}

.actions {
    white-space: nowrap;
}

.actions a {
    margin-right: 12px;
    color: #147a4c;
    font-weight: 750;
    text-decoration: none;
}

.pill {
    display: inline-flex;
    min-width: 48px;
    justify-content: center;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
}

.pill.ok {
    color: #107047;
    background: #e4f6ec;
}

.pill.off {
    color: #777;
    background: #ededed;
}

.empty-state {
    padding: 28px;
}

.empty-state h2 {
    margin: 0;
}

.empty-state p {
    color: #637267;
}

.editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.85fr);
    gap: 18px;
    align-items: start;
}

.panel {
    padding: 22px;
}

.checkline {
    grid-template-columns: auto 1fr !important;
    align-items: center;
}

.checkline input {
    width: auto;
}

.qr-preview {
    width: 164px;
    height: 164px;
    border: 1px solid #e0e7e0;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
}

.form-note {
    margin: -6px 0 0;
    color: #68766c;
    font-size: 13px;
    line-height: 1.5;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.danger-panel {
    max-width: 560px;
}

.public-page {
    display: grid;
    min-height: 100vh;
    padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
    background: var(--page-bg);
    color: var(--text);
}

.theme-green {
    --page-bg: #edf7f1;
    --card-bg: #ffffff;
    --accent: #158451;
    --accent-soft: #e3f5eb;
    --text: #15251b;
    --muted: #607066;
}

.theme-blue {
    --page-bg: #eef5fb;
    --card-bg: #ffffff;
    --accent: #1769aa;
    --accent-soft: #e4f0fb;
    --text: #142232;
    --muted: #5d6c79;
}

.theme-rose {
    --page-bg: #fff1f4;
    --card-bg: #ffffff;
    --accent: #bb365f;
    --accent-soft: #fde4eb;
    --text: #301820;
    --muted: #775e66;
}

.theme-dark {
    --page-bg: #111815;
    --card-bg: #1b2520;
    --accent: #70d49d;
    --accent-soft: #24382d;
    --text: #f2fff7;
    --muted: #adc1b4;
}

.public-shell {
    display: grid;
    width: min(440px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    place-items: center;
    padding: 28px 0;
}

.public-card {
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    background: var(--card-bg);
    box-shadow: 0 22px 70px rgba(18, 38, 24, 0.14);
}

.status-dot {
    display: inline-flex;
    margin-bottom: 18px;
    border-radius: 999px;
    padding: 6px 12px;
    color: var(--accent);
    background: var(--accent-soft);
    font-size: 13px;
    font-weight: 800;
}

.public-card h1 {
    font-size: 26px;
    letter-spacing: 0;
}

.public-card .subtitle {
    margin-top: 10px;
    color: var(--muted);
}

.qr-frame {
    width: min(280px, 100%);
    aspect-ratio: 1;
    margin: 24px auto 18px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.qr-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wechat-line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    padding: 10px;
    background: var(--accent-soft);
}

.wechat-line span {
    color: var(--muted);
    font-size: 13px;
}

.wechat-line strong {
    overflow-wrap: anywhere;
    text-align: left;
}

.wechat-line button {
    border: 0;
    border-radius: 8px;
    padding: 8px 10px;
    color: #fff;
    background: var(--accent);
    font-weight: 800;
}

.tips {
    margin-top: 18px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

.open-link {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    font-weight: 800;
    text-decoration: none;
}

pre {
    overflow-x: auto;
    border-radius: 8px;
    padding: 12px;
    color: #d8f9e7;
    background: #101814;
}

@media (max-width: 760px) {
    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 14px 16px;
    }

    .admin-shell {
        width: min(100% - 24px, 1120px);
        padding-top: 20px;
    }

    .admin-head {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-grid,
    .metric-grid.wide,
    .editor-grid {
        grid-template-columns: 1fr;
    }

    .public-card {
        padding: 22px 18px;
    }

    .public-card h1 {
        font-size: 24px;
    }
}
