/* ============================================================
 * 企业综合管理系统 · 后台管理端
 * 设计系统：精工浅色（Precision Light）
 * 冷灰白底 + 实底面板 + hairline 描边 + 单一深蓝强调（#2452E0）
 * 无玻璃拟态 / 无渐变 / 无光晕与漂浮动画
 * ============================================================ */

:root {
    /* —— 基础 tokens —— */
    --bg: #F4F5F7;
    --surface: #FFFFFF;
    --surface-2: #FAFBFC;
    --line: #E4E7EB;
    --line-strong: #D3D8DE;
    --line-soft: #EEF0F3;
    --ink: #1B1F27;
    --ink-2: #5A6472;
    --ink-3: #98A0AB;
    --accent: #2452E0;
    --accent-deep: #1E45C4;
    --accent-soft: rgba(36, 82, 224, .08);
    --shadow-1: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-2: 0 4px 16px rgba(16, 24, 40, .08);

    /* —— 兼容层：保留原变量名（指向新体系） —— */
    --glass-bg: #FFFFFF;
    --glass-bg-strong: #FFFFFF;
    --glass-border: #E4E7EB;
    --glass-shadow: var(--shadow-1);
    --glass-shadow-hover: var(--shadow-2);
    --primary: #2452E0;
    --primary-2: #1E45C4;
    --primary-grad: #2452E0;
    --text-main: #1B1F27;
    --text-sub: #5A6472;
    --text-light: #98A0AB;
    --danger: #D92D20;
    --success: #0E9F6E;
    --warning: #B45309;
    --radius: 10px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--ink);
    background-color: var(--bg);
    /* 极淡静态网格衬底 */
    background-image:
        linear-gradient(rgba(27, 31, 39, .03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(27, 31, 39, .03) 1px, transparent 1px);
    background-size: 32px 32px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

/* ---------- 面板卡片 ---------- */
.glass {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.glass-hover:hover { border-color: var(--line-strong); box-shadow: var(--shadow-2); }

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

.sidebar {
    width: 236px;
    margin: 12px 0 12px 12px;
    padding: 16px 10px;
    border-radius: 12px;
    position: sticky;
    top: 12px;
    height: calc(100vh - 24px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; }
.brand .logo {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 17px;
}
.brand .title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.brand .sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.nav { flex: 1; }
.nav-group { margin-bottom: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; margin: 2px 0;
    border-radius: var(--radius-sm);
    color: var(--ink-2); font-size: 13.5px; cursor: pointer;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
    position: relative;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-parent {
    display: flex; align-items: center; justify-content: space-between;
    padding: 9px 12px; margin-top: 6px;
    font-size: 12px; font-weight: 600; color: var(--ink-3);
    letter-spacing: .06em; cursor: pointer; border-radius: var(--radius-sm);
}
.nav-parent:hover { color: var(--ink); background: var(--bg); }
.nav-parent .arrow { transition: transform .15s ease; font-size: 10px; }
.nav-group.collapsed .nav-children { display: none; }
.nav-group.collapsed .arrow { transform: rotate(-90deg); }
.nav-children { overflow: hidden; }

/* ---------- 主区域 ---------- */
.main { flex: 1; min-width: 0; padding: 12px 16px 24px 12px; display: flex; flex-direction: column; gap: 12px; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-radius: 12px; gap: 14px;
    position: sticky; top: 12px; z-index: 50;
}
.page-title { font-size: 16px; font-weight: 700; }
.page-title .crumb { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    flex-shrink: 0;
}
.userbox { display: flex; align-items: center; gap: 10px; }
.userbox .uname { font-size: 13px; font-weight: 600; }
.userbox .udept { font-size: 11px; color: var(--ink-3); }

/* ---------- 内容卡片 ---------- */
.card { padding: 18px; }
.card-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.card-hd h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-hd h3::before {
    content: ''; width: 3px; height: 14px; border-radius: 2px;
    background: var(--accent); display: inline-block;
}
.card-hd .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat { padding: 16px; }
.stat .s-label { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; }
.stat .s-value { font-size: 26px; font-weight: 700; margin: 8px 0 2px; letter-spacing: -.02em; }
.stat .s-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.stat .s-foot { font-size: 11.5px; color: var(--ink-3); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 7px 14px; cursor: pointer; outline: none;
    border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; font-family: inherit;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn:active { background: var(--line-soft); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn-primary:active { background: #1A3DC0; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #B42318; border-color: #B42318; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #0B8A5E; border-color: #0B8A5E; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-ghost { background: transparent; border-color: rgba(36, 82, 224, .35); color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.field label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
    width: 100%; padding: 8px 12px; font-size: 13.5px; font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none; transition: border-color .15s ease, box-shadow .15s ease;
    -webkit-appearance: none;
    appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 84px; resize: vertical; }
.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A6472' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 34px;
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tbl thead th {
    text-align: left; padding: 10px 14px;
    font-size: 12px; font-weight: 700; color: var(--ink-2);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.tbl thead th:first-child { border-radius: 8px 0 0 0; }
table.tbl thead th:last-child { border-radius: 0 8px 0 0; }
table.tbl tbody td {
    padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
table.tbl tbody tr { transition: background-color .15s ease; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- 标签 ---------- */
.tag {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; line-height: 1.6;
}
.tag-blue { background: rgba(36, 82, 224, .08); color: #2452E0; }
.tag-green { background: rgba(14, 159, 110, .10); color: #0E9F6E; }
.tag-red { background: rgba(217, 45, 32, .08); color: #D92D20; }
.tag-orange { background: rgba(180, 83, 9, .10); color: #B45309; }
.tag-gray { background: rgba(27, 31, 39, .05); color: #5A6472; }
.tag-purple { background: rgba(105, 65, 198, .08); color: #6941C6; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.pager .pinfo { font-size: 12px; color: var(--ink-3); margin-right: auto; }
.pager button {
    min-width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--surface);
    cursor: pointer; font-size: 12.5px; color: var(--ink-2);
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.pager button:hover { color: var(--accent); border-color: var(--accent); }
.pager button.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 弹窗 ---------- */
.mask {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(17, 24, 39, .45);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.mask.show { opacity: 1; pointer-events: auto; }
.modal {
    width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
    padding: 20px; border-radius: 12px;
    transform: translateY(8px); transition: transform .15s ease;
    background: var(--surface);
}
.mask.show .modal { transform: translateY(0); }
.modal-hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-hd h3 { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--ink-3); line-height: 1; padding: 4px; transition: color .15s; background: none; border: none; }
.modal-close:hover { color: var(--ink); }
.modal-ft { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 提示 ---------- */
#toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center;
    pointer-events: none;
}
.toast-item {
    padding: 9px 18px; border-radius: 8px; font-size: 13px; font-weight: 600;
    background: #1B1F27; color: #fff;
    box-shadow: var(--shadow-2);
    animation: toastIn .15s ease-out;
    display: flex; align-items: center; gap: 8px;
}
.toast-item.ok { color: #8FE3BA; }
.toast-item.err { color: #FFB0A6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 420px; padding: 36px 32px; border-radius: 14px; }
.login-card .brand-lg { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-card .brand-lg .logo {
    width: 64px; height: 64px; border-radius: 16px; font-size: 26px;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.login-card h1 { font-size: 20px; font-weight: 700; text-align: center; }
.login-card .sub { font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* ---------- 进度 ---------- */
.bar { height: 6px; border-radius: 3px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); transition: width .2s ease; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--ink-3); font-size: 13px; }
.empty .ico { font-size: 40px; display: block; margin-bottom: 10px; opacity: .5; }

/* ---------- 工具类 ---------- */
.flex { display: flex; align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt14 { margin-top: 14px; } .mt20 { margin-top: 20px; }
.mb8 { margin-bottom: 8px; }
.muted { color: var(--ink-3); font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.loading { text-align: center; padding: 30px; color: var(--ink-3); font-size: 13px; }
.hide { display: none !important; }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; margin: 10px 10px 0; }
    .main { padding: 10px; }
    .grid2, .grid3, .grid4, .form-grid { grid-template-columns: 1fr; }
    .topbar { position: static; }
}
