:root {
    --green: #18794e;
    --green-dark: #12603e;
    --green-soft: #e7f5ee;
    --ink: #1d2b23;
    --muted: #6b7c72;
    --line: #e2e9e4;
    --bg: #f3f6f4;
    --card: #ffffff;
    --danger: #c0392b;
    --danger-soft: #fdecea;
    --warn: #b7791f;
    --warn-soft: #fdf5e5;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(23, 46, 33, .04), 0 8px 24px rgba(23, 46, 33, .05);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background:
        radial-gradient(900px 420px at 15% 0%, #dbefe4 0%, transparent 60%),
        radial-gradient(700px 380px at 90% 100%, #e6f2eb 0%, transparent 55%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 34px 32px 28px;
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand .mark { width: 42px; height: 42px; border-radius: 12px; font-size: 20px; }
.login-brand strong { display: block; font-size: 17px; letter-spacing: .2px; }
.login-brand small { color: var(--muted); font-size: 12px; }

.login-card h1 { font-size: 20px; margin: 0 0 6px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }

.login-foot { margin-top: 20px; color: var(--muted); font-size: 12px; text-align: center; }

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

.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: #12271e;
    color: #cfe0d6;
    display: flex;
    flex-direction: column;
    padding: 22px 16px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 22px; }
.mark {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2fa06a, #18794e);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex: 0 0 auto;
}
.brand strong { display: block; color: #fff; font-size: 15px; line-height: 1.3; }
.brand small { color: #7fa08e; font-size: 11px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #b9cec2;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .9; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(47, 160, 106, .18); color: #fff; box-shadow: inset 2px 0 0 #39b27c; }
.nav-group {
    padding: 12px 12px 3px;
    color: #6f8d7c;
    font-size: 10.5px;
    letter-spacing: .12em;
}
.nav-group:first-child { padding-top: 2px; }

.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.admin-chip { padding: 0 6px 10px; font-size: 13px; color: #e7f3ec; }
.admin-chip small { display: block; color: #7fa08e; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; padding: 26px 30px 40px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: .2px; }
.topbar p { margin: 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- 卡片 / 栅格 ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 15px; margin: 0; }
.card-head .hint { color: var(--muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.stat .value.green { color: var(--green); }
.stat .value.warn { color: var(--warn); }
.stat .foot { color: var(--muted); font-size: 11px; margin-top: 2px; }

/* ---------- 图表 ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; }
.chart-value { font-size: 11px; color: var(--muted); }
.chart-bar { width: 100%; max-width: 46px; background: var(--green-soft); border-radius: 8px; display: flex; align-items: flex-end; overflow: hidden; flex: 1; min-height: 6px; }
.chart-fill { width: 100%; background: linear-gradient(180deg, #3aae79, #18794e); border-radius: 8px 8px 0 0; min-height: 4px; }
.chart-date { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 40px 0; text-align: center; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left;
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid #edf2ee; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; color: var(--muted); }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { text-align: center; color: var(--muted); padding: 36px 0; }

/* ---------- 徽章 ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.7;
    white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-on { background: var(--green-soft); color: var(--green); }
.badge-off { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: #eef2ef; color: var(--muted); }
.badge-neutral::before { display: none; }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-warn::before { display: none; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.btn:hover { background: #f6faf7; border-color: #cfdad3; color: var(--ink); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f0cfca; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: #e7b8b0; }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .18); color: #cfe0d6; }
.btn-ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; border-color: rgba(255, 255, 255, .28); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.input, select.input, textarea.input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--ink);
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: #6fbf98; box-shadow: 0 0 0 3px rgba(24, 121, 78, .10); }
.input.is-invalid { border-color: #d98a7d; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { margin: 0; }
.filters .input { width: auto; min-width: 200px; }
.filters select.input { min-width: 130px; }

/* ---------- 二级导航 ---------- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.subnav a { padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--muted); border: 1px solid transparent; }
.subnav a:hover { background: #f6faf7; color: var(--ink); }
.subnav a.active { background: var(--green-soft); color: var(--green); border-color: #cbe8d8; font-weight: 600; }

/* ---------- 提示 ---------- */
.flash {
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    border: 1px solid #cbe8d8;
    background: var(--green-soft);
    color: #145c3b;
}
.flash.error { border-color: #f0cfca; background: var(--danger-soft); color: var(--danger); }

/* ---------- 分页 ---------- */
.pagination-wrap { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pagination-wrap .summary { color: var(--muted); font-size: 12.5px; }
.pagination { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.pagination li { display: inline-flex; }
.pagination .page-link,
.pagination li > span,
.pagination li > a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    font-size: 12.5px;
}
.pagination .page-link:hover, .pagination li > a:hover { border-color: #cfdad3; background: #f6faf7; }
.pagination .active > span, .pagination .active .page-link { background: var(--green); border-color: var(--green); color: #fff; }
.pagination .disabled > span, .pagination .disabled .page-link { color: #b9c5be; background: #fafcfb; }

/* ---------- 键值列表 ---------- */
.kv { display: grid; grid-template-columns: 84px 1fr; gap: 10px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

.token-list { list-style: none; margin: 0; padding: 0; }
.token-list li { padding: 10px 0; border-bottom: 1px dashed #e8efea; font-size: 12.5px; }
.token-list li:last-child { border-bottom: 0; }
.token-list .token-meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

.section-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }

/* ---------- 网站设置 ---------- */
.field-wide { grid-column: 1 / -1; }
.setting-masked { margin-top: 6px; color: var(--muted); font-size: 12px; }
.setting-masked code {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #f4f8f5;
    font-size: 12px;
    letter-spacing: .04em;
}

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .admin-shell { flex-direction: column; }
    .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
    .brand { padding: 0 8px 0 0; }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { display: none; }
    .sidebar-foot { border-top: 0; padding: 0; margin-left: auto; display: flex; align-items: center; gap: 8px; }
    .admin-chip { padding: 0; }
    .main { padding: 20px 16px 32px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
