/* =============================================================
   管理系统 · 全局样式
   基于 Bootstrap 5 的二次封装，无外部依赖
   配色：主色 #2563eb（专业蓝），辅助 #0f172a（深底）
   ============================================================= */

:root {
    --c-primary: #2563eb;
    --c-primary-dark: #1d4ed8;
    --c-primary-soft: #eff6ff;
    --c-sidebar: #0f172a;
    --c-sidebar-2: #1e293b;
    --c-bg: #f1f5f9;
    --c-card: #ffffff;
    --c-border: #e2e8f0;
    --c-text: #1e293b;
    --c-muted: #64748b;
    --c-success: #16a34a;
    --c-danger: #dc2626;
    --c-warn: #d97706;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}

/* ---------- 布局骨架 ---------- */
html, body {
    margin: 0;
    padding: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

.app-shell { display: flex; min-height: 100dvh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: linear-gradient(180deg, var(--c-sidebar) 0%, var(--c-sidebar-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    z-index: 1040;
}

.brand {
    height: 62px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: contain;
    background: #fff;
    padding: 2px;
}

.brand-logo-text {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-primary);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}

.brand-name {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }

.nav-group {
    font-size: 11px;
    color: #64748b;
    padding: 10px 10px 6px;
    letter-spacing: 1px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    margin-bottom: 2px;
    transition: all .15s;
    font-size: 14px;
}

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

.nav-link.active {
    background: var(--c-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}

.nav-icon { width: 17px; height: 17px; flex: 0 0 17px; }

.nav-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 5px;
}

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
}

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

.sb-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--c-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
}

.sb-meta { min-width: 0; }
.sb-name { color: #fff; font-size: 13px; }
.sb-role { font-size: 11px; color: #94a3b8; }

.sb-actions { display: flex; gap: 8px; margin-top: 10px; }

.sb-btn {
    flex: 1;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(255, 255, 255, .08);
    color: #cbd5e1;
    transition: all .15s;
}

.sb-btn:hover { background: var(--c-primary); color: #fff; text-decoration: none; }

/* ---------- 主区域 ---------- */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 62px;
    background: #fff;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.btn-toggle {
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: 8px;
    width: 36px; height: 36px;
    display: none;
    align-items: center; justify-content: center;
    color: var(--c-text);
}

.topbar-title h1 { font-size: 17px; margin: 0; font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.role-tag {
    background: var(--c-primary-soft);
    color: var(--c-primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
}

.top-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--c-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
}

.top-name { font-size: 13px; color: var(--c-text); }

.expiry-bar {
    background: #fffbeb;
    color: #92400e;
    border-bottom: 1px solid #fde68a;
    padding: 8px 20px;
    font-size: 13px;
}

.expiry-bar a { color: var(--c-primary); text-decoration: none; font-weight: 600; }
.expiry-bar.expires-soon { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.content { padding: 22px; flex: 1; }

/* ---------- 卡片 ---------- */
.card-panel {
    background: var(--c-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

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

.card-panel .card-head h5 { margin: 0; font-size: 15px; font-weight: 600; }
.card-panel .card-body { padding: 18px; }

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

.stat-card {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--c-primary);
}

.stat-card.s-green::before { background: var(--c-success); }
.stat-card.s-orange::before { background: var(--c-warn); }
.stat-card.s-red::before { background: var(--c-danger); }

.stat-label { color: var(--c-muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--c-text); line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--c-muted); margin-top: 6px; }

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

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

.table th, .table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--c-border);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.table thead th {
    background: #f8fafc;
    color: var(--c-muted);
    font-weight: 600;
    font-size: 12.5px;
    border-bottom: 1px solid var(--c-border);
}

.table tbody tr:hover { background: #f8fafc; }
.table tbody tr.row-pending { background: #fffbeb; }
.table .mono { font-variant-numeric: tabular-nums; }
.table .td-strong { font-weight: 600; }

/* ---------- 徽章 ---------- */
.badge-soft {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 12px;
    line-height: 1.7;
}

.b-plain   { background: #f1f5f9; color: #475569; }
.b-blue    { background: #dbeafe; color: #1d4ed8; }
.b-green   { background: #dcfce7; color: #15803d; }
.b-orange  { background: #ffedd5; color: #c2410c; }
.b-red     { background: #fee2e2; color: #b91c1c; }
.b-purple  { background: #ede9fe; color: #6d28d9; }

/* ---------- 工具栏 ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar .grow { flex: 1 1 auto; }

.input-line {
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13.5px;
    outline: none;
    min-width: 150px;
}

.input-line:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

/* ---------- 按钮 ---------- */
.btn-brand {
    background: var(--c-primary);
    border: 1px solid var(--c-primary);
    color: #fff;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .15s;
}

.btn-brand:hover { background: var(--c-primary-dark); color: #fff; }
.btn-brand svg { width: 15px; height: 15px; }

.btn-ghost {
    background: #fff;
    border: 1px solid var(--c-border);
    color: var(--c-text);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 13.5px;
    display: inline-flex; align-items: center; gap: 6px;
}

.btn-ghost:hover { background: #f8fafc; }
.btn-ghost svg { width: 15px; height: 15px; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; border-radius: 8px; padding: 8px 14px; font-size: 13.5px; }

/* ---------- 表单 ---------- */
.form-label { font-size: 13px; color: var(--c-muted); margin-bottom: 5px; display: block; font-weight: 500; }

.form-control-custom {
    width: 100%;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.form-control-custom:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.form-control-custom[readonly] { background: #f8fafc; color: var(--c-muted); }

.readonly-box {
    background: #f8fafc;
    border: 1px dashed var(--c-border);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--c-muted);
    font-size: 14px;
}

.help-text { font-size: 12px; color: var(--c-muted); margin-top: 5px; }

.calc-preview {
    background: var(--c-primary-soft);
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 14px 16px;
    margin-top: 8px;
}

.calc-preview .row-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; }
.calc-preview .row-line b { color: var(--c-primary); font-size: 15px; }

/* ---------- 对比表 ---------- */
.diff-table td { vertical-align: top; }
.diff-old { color: var(--c-danger); text-decoration: line-through; }
.diff-new { color: var(--c-success); font-weight: 600; }

/* ---------- 空状态 / 提示 ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--c-muted); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; opacity: .5; }

.tip-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 14px;
}

/* ---------- 图表条 ---------- */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.bar-label { width: 96px; flex: 0 0 96px; font-size: 13px; color: var(--c-muted); text-align: right; }
.bar-track { flex: 1; background: #f1f5f9; border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 6px; transition: width .4s; }
.bar-val { width: 108px; flex: 0 0 108px; font-size: 13px; font-weight: 600; }

/* ---------- 分页 ---------- */
.pagination-wrap { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.pagination { margin: 0; }
.page-link { border-radius: 7px; margin: 0 2px; font-size: 13px; padding: 6px 11px; }
.pagination .active .page-link { background: var(--c-primary); border-color: var(--c-primary); }
.pagination-info { color: var(--c-muted); font-size: 13px; }

/* ---------- 登录页 ---------- */
.login-page {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #2563eb 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 14px;
    padding: 38px 34px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}

.login-card .lc-title { font-size: 21px; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-card .lc-sub { text-align: center; color: var(--c-muted); font-size: 13px; margin-bottom: 26px; }

/* ---------- 移动端 ---------- */
.main-mask { display: none; }

@media (max-width: 991.98px) {
    .btn-toggle { display: flex; }
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, .18);
    }
    .sidebar.open { transform: translateX(0); }
    .main-mask {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .5);
        z-index: 1035;
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
    }
    .main-mask.show { opacity: 1; pointer-events: auto; }
    .content { padding: 16px; }
    .topbar-title h1 { font-size: 16px; }
}

@media (max-width: 575.98px) {
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 19px; }
    .toolbar .input-line { min-width: 120px; }
}
