:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-soft: #eef1f7;
    --text: #111827;
    --muted: #5b6779;
    --line: #e2e7f0;
    --brand: #2f5bff;
    --brand-dark: #1e43cd;
    --brand-soft: #e9eeff;
    --up: #0f9d58;
    --up-soft: #e3f6ec;
    --down: #d93a32;
    --down-soft: #fdeceb;
    --unknown: #97a1b2;
    --unknown-soft: #eef1f6;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 14px 32px -24px rgba(16, 24, 40, .35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

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

/* ---------- 布局 ---------- */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 236px;
    padding: 22px 16px;
    background: #0f172a;
    color: #c8d2e0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 30;
}

.admin-sidebar .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 4px 8px 18px;
    color: #fff;
    font-weight: 700;
    letter-spacing: -.01em;
}

.admin-sidebar .brand .mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(140deg, var(--brand), #7b93ff);
    font-size: 15px;
}

.admin-sidebar .brand small {
    display: block;
    font-size: 11.5px;
    font-weight: 500;
    color: #8494ab;
}

.nav-group {
    padding: 10px 10px 6px;
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: #64748b;
}

.side-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    font-size: 13.5px;
    color: #c2cede;
    transition: background .15s ease, color .15s ease;
}

.side-link:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.side-link.active {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 8px 18px -12px rgba(47, 91, 255, .9);
}

.side-link .icon {
    width: 18px;
    text-align: center;
    font-size: 13px;
    opacity: .9;
}

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, .09);
    display: grid;
    gap: 6px;
}

.sidebar-foot form {
    margin: 0;
}

.side-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #c2cede;
    font: inherit;
    font-size: 13.5px;
    cursor: pointer;
    text-align: left;
}

.side-btn:hover {
    background: rgba(255, 255, 255, .07);
    color: #fff;
}

.admin-main {
    flex: 1;
    min-width: 0;
    margin-left: 236px;
    padding: 26px 32px 60px;
}

.admin-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 22px;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -.02em;
}

.admin-topbar p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13.5px;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ---------- 通用组件 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 22px;
}

.card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}

.card-head h2 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -.01em;
}

.card-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12.5px;
}

.card-body {
    padding: 22px;
}

.section + .section {
    margin-top: 22px;
}

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

.small {
    font-size: 12.5px;
}

.mono {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12.5px;
}

/* 统计卡 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

a.stat-card {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: border-color .15s ease, transform .15s ease;
}

a.stat-card:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12.5px;
}

.stat-card strong {
    display: block;
    margin-top: 6px;
    font-size: 27px;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.stat-card.hint strong {
    font-size: 17px;
}

/* 按钮 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9px;
    border: 1px solid transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

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

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

.btn-ghost {
    background: var(--surface-soft);
    color: #3a465c;
}

.btn-ghost:hover {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.btn-outline {
    background: transparent;
    border-color: var(--line);
    color: #3a465c;
}

.btn-outline:hover {
    border-color: var(--brand);
    color: var(--brand-dark);
}

.btn-danger {
    background: var(--down-soft);
    color: var(--down);
}

.btn-danger:hover {
    background: #fbd9d6;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 7px;
}

.btn[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

/* 表单 */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    font-size: 12.5px;
    font-weight: 600;
    color: #374151;
}

.field .hint {
    font-size: 12px;
    color: var(--muted);
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: 0;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(47, 91, 255, .14);
}

textarea {
    resize: vertical;
    min-height: 110px;
    line-height: 1.6;
}

textarea.code {
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    font-size: 12.5px;
    min-height: 160px;
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.mode-panel {
    display: none;
    margin-top: 16px;
    padding: 18px;
    border-radius: 12px;
    background: #f8faff;
    border: 1px dashed rgba(47, 91, 255, .3);
}

.mode-panel.active {
    display: block;
}

.mode-panel h4 {
    margin: 0 0 4px;
    font-size: 13.5px;
}

.mode-panel .hint {
    margin: 0 0 14px;
    font-size: 12.5px;
    color: var(--muted);
}

/* 表格 */
.table-wrap {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data th {
    text-align: left;
    padding: 11px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    white-space: nowrap;
}

table.data td {
    padding: 13px 16px;
    border-bottom: 1px solid #edf1f7;
    vertical-align: middle;
}

table.data tr:last-child td {
    border-bottom: 0;
}

table.data tr:hover td {
    background: #fafbff;
}

.cell-title {
    font-weight: 600;
}

.cell-sub {
    color: var(--muted);
    font-size: 12px;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* 徽标 */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--unknown-soft);
    color: #4f5c70;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--unknown);
}

.badge.up {
    background: var(--up-soft);
    color: #0b7a45;
}

.badge.up::before {
    background: var(--up);
}

.badge.down {
    background: var(--down-soft);
    color: #b02a24;
}

.badge.down::before {
    background: var(--down);
}

.badge.plain {
    background: var(--surface-soft);
    color: #4f5c70;
}

.badge.plain::before {
    display: none;
}

.badge.brand {
    background: var(--brand-soft);
    color: var(--brand-dark);
}

.badge.brand::before {
    display: none;
}

/* 提示条 */
.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    padding: 11px 16px;
    border-radius: 10px;
    font-size: 13.5px;
    border: 1px solid transparent;
    transition: opacity .4s ease, transform .4s ease;
}

.flash-success {
    background: var(--up-soft);
    color: #0b7a45;
    border-color: rgba(15, 157, 88, .22);
}

.flash-error {
    background: var(--down-soft);
    color: #a82922;
    border-color: rgba(217, 58, 50, .22);
}

.flash.hide {
    opacity: 0;
    transform: translateY(-4px);
}

/* 空状态 */
.empty {
    padding: 42px 20px;
    text-align: center;
    color: var(--muted);
}

.empty strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 15px;
}

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(760px 420px at 20% 0%, rgba(47, 91, 255, .16), transparent 60%),
        radial-gradient(620px 380px at 90% 100%, rgba(15, 157, 88, .12), transparent 55%),
        #0f172a;
}

.login-card {
    width: min(400px, 100%);
    background: #fff;
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, .7);
}

.login-card .mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(140deg, var(--brand), #7b93ff);
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 18px;
}

.login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
    letter-spacing: -.02em;
}

.login-card p.sub {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 13.5px;
}

.login-card .field + .field {
    margin-top: 14px;
}

.login-card .btn {
    width: 100%;
    margin-top: 22px;
    padding: 11px;
    font-size: 14px;
}

.login-foot {
    margin-top: 22px;
    text-align: center;
    font-size: 12.5px;
    color: #8a94a6;
}

.login-foot a {
    color: #c9d2e0;
}

/* 详情工具条 */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}

.toolbar form {
    margin: 0;
}

.toolbar .spacer {
    flex: 1;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 4px 4px 12px;
}

.search-box input {
    border: 0;
    padding: 6px 0;
    width: 220px;
    background: transparent;
}

.search-box input:focus {
    box-shadow: none;
}

.search-box .btn {
    padding: 6px 12px;
}

details.panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcff;
    padding: 0;
    margin-top: 12px;
}

details.panel > summary {
    padding: 13px 18px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    list-style: none;
}

details.panel > summary::-webkit-details-marker {
    display: none;
}

details.panel > summary::before {
    content: "+";
    display: inline-block;
    width: 18px;
    color: var(--brand);
    font-weight: 700;
}

details.panel[open] > summary::before {
    content: "−";
}

details.panel .panel-body {
    padding: 0 18px 18px;
}

.kv {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.kv div {
    padding: 11px 14px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #eef2f8;
}

.kv span {
    display: block;
    font-size: 11.5px;
    color: var(--muted);
}

.kv strong {
    display: block;
    margin-top: 2px;
    font-size: 13.5px;
    word-break: break-all;
}

.notice {
    padding: 12px 16px;
    border-radius: 10px;
    background: #fff8e6;
    border: 1px solid #f3e2b3;
    color: #8a6100;
    font-size: 12.5px;
}

.notice.blue {
    background: var(--brand-soft);
    border-color: rgba(47, 91, 255, .2);
    color: #1f3fa8;
}

.job-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 6px;
    background: #fff8e6;
    color: #8a6100;
    font-size: 11.5px;
}

@media (max-width: 960px) {
    .admin-sidebar {
        position: static;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 12px 16px;
        gap: 4px;
    }

    .admin-sidebar .brand {
        padding: 0 12px 0 0;
    }

    .nav-group {
        display: none;
    }

    .side-link {
        padding: 7px 10px;
    }

    .sidebar-foot {
        margin: 0 0 0 auto;
        padding: 0;
        border: 0;
        display: flex;
    }

    .admin-shell {
        flex-direction: column;
    }

    .admin-main {
        margin-left: 0;
        padding: 22px 18px 50px;
    }
}

@media (max-width: 620px) {
    .admin-sidebar .brand small {
        display: none;
    }

    .search-box input {
        width: 140px;
    }
}
