/*
 * 【骨架核心文件：禁止修改】
 * 后台基础样式（自建精简框架，零 CDN 依赖）。
 * 类名沿用 Bootstrap 5 命名习惯，便于业务页面直接套用；
 * 主题色与明暗模式通过 CSS 变量控制，可由主题包覆盖。
 */

:root {
    --c-primary: #2563eb;
    --c-primary-dark: #1d4ed8;
    --c-primary-soft: #e8f0fe;
    --c-success: #0f9d58;
    --c-warning: #d97706;
    --c-danger: #dc2626;
    --c-info: #0891b2;
    --bg-body: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-sidebar: #1f2937;
    --bg-sidebar-hover: #374151;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-sidebar: #d1d5db;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
    --sidebar-w: 232px;
}

html[data-theme="dark"] {
    --bg-body: #111827;
    --bg-surface: #1f2937;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }

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

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

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 18px 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-nav { padding: 10px 10px 24px; flex: 1; }
.nav-item { margin-bottom: 2px; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-sidebar);
    font-size: 13.5px;
}
.nav-link:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--c-primary); color: #fff; }
.nav-link svg { width: 16px; height: 16px; flex: none; }
.nav-group-title {
    padding: 14px 12px 6px;
    font-size: 11px;
    letter-spacing: .08em;
    color: #6b7280;
    text-transform: uppercase;
}
.nav-sub { padding-left: 12px; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 56px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .page-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--c-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.content { padding: 22px; flex: 1; }
.content-narrow { max-width: 900px; }

/* ---------- 卡片 ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title { font-size: 14.5px; font-weight: 600; margin: 0; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------- 网格 ---------- */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > [class^="col-"] { padding: 0 8px; }
.col-3 { width: 25%; }
.col-4 { width: 33.333%; }
.col-6 { width: 50%; }
.col-8 { width: 66.666%; }
.col-9 { width: 75%; }
.col-12 { width: 100%; }
@media (max-width: 900px) {
    .col-3, .col-4, .col-6, .col-8, .col-9 { width: 100%; }
}

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: rgba(0, 0, 0, .015); color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.table tbody tr:hover { background: rgba(37, 99, 235, .04); }
.table td.nowrap, .table th.nowrap { white-space: nowrap; }
.table-responsive { overflow-x: auto; }
html[data-theme="dark"] .table th { background: rgba(255, 255, 255, .03); }
html[data-theme="dark"] .table tbody tr:hover { background: rgba(255, 255, 255, .04); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-main);
    font-size: 13.5px; cursor: pointer; line-height: 1.4;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color: #fff; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { opacity: .9; color: #fff; border-color: var(--c-danger); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 表单 ---------- */
.form-label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.form-control, .form-select {
    width: 100%; padding: 8px 12px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-surface); color: var(--text-main);
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-soft); }
textarea.form-control { resize: vertical; min-height: 84px; }
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.mb-3 { margin-bottom: 14px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-inline { display: inline-flex; margin-right: 16px; }
.form-check-input { width: 16px; height: 16px; accent-color: var(--c-primary); }
.form-switch .form-check-input { width: 34px; height: 18px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-control, .inline-form .form-select { width: auto; min-width: 140px; }

/* ---------- 徽标与提示 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; line-height: 1.7; }
.bg-success { background: #dcfce7; color: #166534; }
.bg-danger { background: #fee2e2; color: #991b1b; }
.bg-warning { background: #fef3c7; color: #92400e; }
.bg-primary { background: var(--c-primary-soft); color: var(--c-primary-dark); }
.bg-secondary { background: #f3f4f6; color: #4b5563; }
.bg-info { background: #cffafe; color: #155e75; }
html[data-theme="dark"] .bg-success { background: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .bg-danger { background: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .bg-warning { background: #78350f; color: #fde68a; }
html[data-theme="dark"] .bg-secondary { background: #374151; color: #d1d5db; }
html[data-theme="dark"] .bg-primary { background: #1e3a8a; color: #dbeafe; }
html[data-theme="dark"] .bg-info { background: #164e63; color: #cffafe; }

.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
html[data-theme="dark"] .alert-success { background: #052e16; border-color: #14532d; color: #bbf7d0; }
html[data-theme="dark"] .alert-danger { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }
html[data-theme="dark"] .alert-info { background: #172554; border-color: #1e3a8a; color: #bfdbfe; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 14px;
}
.stat-icon {
    width: 42px; height: 42px; border-radius: 10px; flex: none;
    background: var(--c-primary-soft); color: var(--c-primary);
    display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 12.5px; color: var(--text-muted); }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 14px 0 0; flex-wrap: wrap; }
.pagination a, .pagination span {
    display: inline-block; padding: 5px 11px; border: 1px solid var(--border);
    border-radius: 7px; font-size: 13px; color: var(--text-main); background: var(--bg-surface);
}
.pagination .active span { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.pagination .disabled span { color: var(--text-muted); opacity: .6; }

/* ---------- 其他 ---------- */
.breadcrumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--text-muted); }
.empty { padding: 40px 0; text-align: center; color: var(--text-muted); font-size: 13.5px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 12px; }
pre.json {
    background: rgba(0, 0, 0, .03); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px; overflow-x: auto; font-size: 12px; margin: 0;
}
html[data-theme="dark"] pre.json { background: rgba(255, 255, 255, .04); }
.kv-table td:first-child { width: 180px; color: var(--text-muted); }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.flex-1 { flex: 1; }
.hidden { display: none; }

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #38bdf8 100%);
    padding: 20px;
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 32px 30px; box-shadow: 0 12px 40px rgba(15, 23, 42, .22); }
.login-card h1 { font-size: 18px; margin: 0 0 4px; font-weight: 600; color: #111827; }
.login-card .sub { font-size: 13px; color: #6b7280; margin: 0 0 22px; }
.login-card .form-control { border-color: #d1d5db; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }

/* ---------- 前台 ---------- */
.front-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.front-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 14px; padding: 40px 44px; box-shadow: var(--shadow); max-width: 560px; }
