:root {
    --bg: #0a0d14;
    --panel: #111827;
    --panel-2: #151f31;
    --line: #263244;
    --text: #eef3ff;
    --muted: #94a3b8;
    --blue: #5b8cff;
    --green: #4ade80;
    --red: #fb7185;
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

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

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.site-head,
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 20px;
}

.admin-link,
.back-link,
.btn,
.mini-btn {
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.admin-link,
.back-link,
.btn.ghost {
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 10px 15px;
}

.public-grid,
.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

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

.card {
    min-height: 150px;
    padding: 24px;
    display: grid;
    align-content: space-between;
}

.card.wide {
    grid-column: 1 / -1;
}

.card span,
.metric span {
    color: var(--muted);
    font-size: 15px;
}

.card strong,
.metric strong {
    display: block;
    margin-top: 14px;
    font-size: 32px;
    overflow-wrap: anywhere;
}

.auth-wrap {
    min-height: calc(100vh - 130px);
    display: grid;
    place-items: center;
}

.auth {
    width: min(420px, 100%);
    padding: 24px;
}

.form {
    display: grid;
    gap: 14px;
    margin-top: 18px;
}

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

input,
textarea {
    width: 100%;
    color: var(--text);
    background: #0d1320;
    border: 1px solid var(--line);
    border-radius: 16px;
    outline: none;
    padding: 12px 14px;
}

input[type="checkbox"] {
    accent-color: var(--blue);
}

textarea {
    resize: vertical;
    min-height: 150px;
    font-family: Consolas, "Cascadia Mono", monospace;
}

input:focus,
textarea:focus {
    border-color: var(--blue);
}

.btn {
    padding: 12px 16px;
}

.btn.primary {
    color: #fff;
    background: var(--blue);
}

.btn.secondary {
    color: #07120d;
    background: var(--green);
}

.notice {
    margin-bottom: 18px;
    padding: 13px 15px;
    color: var(--text);
}

.notice.error {
    color: #ffe4e9;
    border-color: rgba(251, 113, 133, 0.55);
}

.admin-grid {
    display: grid;
    gap: 18px;
}

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

.metric {
    min-height: 112px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

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

.work-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 18px;
}

.panel {
    padding: 20px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.switch-list {
    display: grid;
    gap: 10px;
    margin-top: 16px;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: var(--text);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 11px 13px;
}

.switch-row input {
    width: 20px;
    height: 20px;
    accent-color: var(--blue);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
}

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

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

th {
    color: var(--muted);
    background: var(--panel-2);
    font-size: 13px;
}

td {
    color: #dbe5f7;
}

.check-cell {
    width: 46px;
    text-align: center;
}

.check-cell input {
    width: 18px;
    height: 18px;
    padding: 0;
}

code {
    display: inline-block;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    font-family: Consolas, "Cascadia Mono", monospace;
}

small {
    color: var(--muted);
}

.balance {
    color: var(--green);
    font-weight: 800;
}

.pill {
    display: inline-flex;
    max-width: 160px;
    padding: 5px 10px;
    border-radius: 999px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 800;
}

.pill.ok {
    color: var(--green);
    background: rgba(74, 222, 128, 0.12);
}

.pill.bad {
    color: var(--red);
    background: rgba(251, 113, 133, 0.12);
}

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

.mini-btn {
    padding: 8px 10px;
    color: #dce8ff;
    background: #1d2a44;
}

.mini-btn.danger {
    color: #ffe2e6;
    background: rgba(251, 113, 133, 0.18);
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 28px;
}

@media (max-width: 960px) {
    .metric-grid,
    .public-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 640px) {
    .page,
    .admin-page {
        width: min(100% - 20px, 1120px);
        padding-top: 18px;
    }

    .site-head,
    .topbar,
    .panel-head {
        align-items: stretch;
        flex-direction: column;
    }

    h1 {
        font-size: 28px;
    }

    .public-grid,
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

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

    .card {
        min-height: 120px;
    }

    .card strong,
    .metric strong {
        font-size: 22px;
    }

    .btn,
    .admin-link,
    .back-link {
        width: 100%;
        text-align: center;
    }

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

    .actions {
        flex-direction: column;
    }
}
