:root {
    --brand: #2f6bf3;
    --brand-dark: #1f4fd0;
    --brand-soft: #eaf1ff;
    --ink: #1b2437;
    --muted: #6b7688;
    --line: #e9edf5;
    --bg: #f5f7fb;
    --success: #10855c;
    --warning: #b7791f;
    --danger: #d64545;
    --sidebar-w: 248px;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 12px 28px -18px rgba(16, 24, 40, .25);
    --bs-body-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--bs-body-font-family);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 1040;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3f7bff, #6f4dff);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 18px;
    box-shadow: 0 6px 14px -6px rgba(63, 123, 255, .8);
}

.brand-text { line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: .2px; display: block; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: .6px; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: #e3e8f1; border-radius: 6px; }

.nav-group { margin-top: 14px; }
.nav-group-title {
    font-size: 11px;
    color: #98a2b3;
    letter-spacing: .08em;
    padding: 0 10px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    font-weight: 600;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 9px;
    color: #4b5565;
    font-size: 13.5px;
    margin-bottom: 2px;
    transition: background .15s ease, color .15s ease;
}

.nav-link-item i { font-size: 16px; color: #8a94a6; transition: color .15s; }
.nav-link-item:hover { background: #f5f8ff; color: var(--brand); }
.nav-link-item:hover i { color: var(--brand); }
.nav-link-item.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}
.nav-link-item.active i { color: var(--brand); }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: #98a2b3;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: 62px;
    background: rgba(255, 255, 255, .86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-sub { font-size: 12px; color: var(--muted); }

.topbar-spacer { flex: 1; }

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    display: grid;
    place-items: center;
    color: #5a6478;
    position: relative;
}
.icon-btn:hover { color: var(--brand); border-color: #d7e2fb; background: #f8fbff; }
.icon-dot {
    position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
    background: #ef4444; border-radius: 50%; border: 1px solid #fff;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
}
.user-chip:hover { border-color: #d7e2fb; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, #4f86ff, #7c5cff);
    color: #fff; display: grid; place-items: center;
    font-size: 12px; font-weight: 600;
}
.user-meta { line-height: 1.1; }
.user-meta strong { font-size: 13px; display: block; }
.user-meta span { font-size: 11px; color: var(--muted); }

.content { padding: 22px; flex: 1; }
.content-narrow { max-width: 1080px; }
.page-footer {
    padding: 12px 22px 18px;
    color: #98a2b3;
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

/* ---------- Page header ---------- */
.page-head {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.page-head-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- Cards ---------- */
.card-clean {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-clean + .card-clean { margin-top: 16px; }
.card-head {
    padding: 15px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
}
.card-head h6 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-body-pad { padding: 18px; }

/* ---------- Stats ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 16px 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card .stat-ico {
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; font-size: 18px; margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.5px; line-height: 1; }
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.stat-card .stat-extra { font-size: 11.5px; color: #98a2b3; margin-top: 8px; }
.stat-card .stat-extra b { color: var(--ink); font-weight: 600; }

.tone-blue { background: #eaf1ff; color: #2f6bf3; }
.tone-orange { background: #fff4e6; color: #d97706; }
.tone-green { background: #e7f7ef; color: #0f855c; }
.tone-purple { background: #f1ecff; color: #7048e8; }
.tone-red { background: #fdecec; color: #d64545; }
.tone-cyan { background: #e6f7fa; color: #0e7490; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table-clean { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.table-clean thead th {
    background: #fbfcfe;
    color: #8b95a7;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .03em;
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    text-align: left;
}
.table-clean tbody td {
    padding: 12px 12px;
    border-bottom: 1px solid #f1f4fa;
    font-size: 13.2px;
    vertical-align: middle;
    color: #333d4f;
}
.table-clean tbody tr:hover td { background: #fafbff; }
.table-clean tbody tr:last-child td { border-bottom: none; }
.table-clean .cell-strong { font-weight: 600; color: var(--ink); }
.table-clean tbody td:first-child { white-space: nowrap; }
.table-clean td .cell-clip {
    display: block;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #5b6478;
}
.table-clean .cell-muted { color: var(--muted); }
.cell-actions { white-space: nowrap; text-align: right; }
.table-clean tbody td { white-space: nowrap; }
.table-clean td.cell-actions,
.table-clean thead th:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: #fff;
    box-shadow: -6px 0 10px -10px rgba(16, 24, 40, .35);
}
.table-clean thead th:last-child { background: #fbfcfe; }
.table-clean tbody tr:hover td.cell-actions { background: #f8fafe; }
.cell-actions .btn { padding: 3px 9px; font-size: 12px; border-radius: 7px; }

.empty-state { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty-state i { font-size: 34px; color: #cdd5e4; display: block; margin-bottom: 10px; }

/* ---------- Badges ---------- */
.badge-soft {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.badge-soft-success { background: #e7f7ef; color: #0f7b4f; }
.badge-soft-warning { background: #fff5e3; color: #a86400; }
.badge-soft-danger { background: #fdecec; color: #c53030; }
.badge-soft-info { background: #e8f6fa; color: #0e6f86; }
.badge-soft-primary { background: #eaf1ff; color: #2b58c9; }
.badge-soft-secondary { background: #f2f4f8; color: #64748b; }

/* ---------- Forms ---------- */
.form-label { font-size: 13px; font-weight: 600; color: #3c4657; margin-bottom: 6px; }
.form-control, .form-select {
    border-radius: 9px;
    border-color: #dfe5ef;
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--ink);
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: #a9c1f8;
    box-shadow: 0 0 0 3px rgba(47, 107, 243, .12);
}
.form-control::placeholder { color: #adb6c6; }
textarea.form-control { min-height: 84px; }
.form-text { font-size: 12px; color: #98a2b3; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

.btn { border-radius: 9px; font-size: 13.5px; font-weight: 500; padding: 7px 14px; }
.btn-sm { padding: 4px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-light { background: #f4f6fa; border-color: #eaeef6; color: #43506a; }
.btn-light:hover { background: #eaeffa; border-color: #dbe3f2; color: #2f6bf3; }
.btn-outline-secondary { border-color: #dfe5ef; color: #5a6478; }

.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.filter-bar .search-box { position: relative; flex: 1; max-width: 380px; }
.filter-bar .search-box i {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: #98a2b3; font-size: 14px;
}
.filter-bar .search-box input { padding-left: 34px; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; gap: 6px; padding: 14px 16px; border-top: 1px solid var(--line); }
.pager .page-btn {
    min-width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line);
    display: grid; place-items: center; color: #4b5565; font-size: 13px; background: #fff;
}
.pager .page-btn:hover { border-color: #d7e2fb; color: var(--brand); }
.pager .page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager .page-btn.disabled { opacity: .45; pointer-events: none; }
.pager .page-info { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* ---------- Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart-box { position: relative; height: 260px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }

.todo-item {
    display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed #eef1f7;
}
.todo-item:last-child { border-bottom: none; }
.todo-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; font-size: 15px; }
.todo-item h6 { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; }
.todo-item p { margin: 0; font-size: 12.5px; color: var(--muted); }

.activity { display: flex; gap: 12px; padding: 10px 0; }
.activity-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; flex: 0 0 auto; }
.activity h6 { margin: 0; font-size: 13px; font-weight: 600; }
.activity p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.activity time { margin-left: auto; font-size: 11.5px; color: #98a2b3; white-space: nowrap; }

.progress-thin { height: 6px; border-radius: 999px; background: #eef2f8; overflow: hidden; }
.progress-thin > div { height: 100%; border-radius: 999px; background: var(--brand); }

.objective-row { display: flex; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px dashed #eef1f7; }
.objective-row:last-child { border-bottom: none; }
.objective-row .name { width: 150px; font-size: 13px; }
.objective-row .bar { flex: 1; }
.objective-row .val { width: 92px; text-align: right; font-size: 12.5px; color: var(--muted); }

/* ---------- Detail pages ---------- */
.detail-grid { display: grid; grid-template-columns: 1.65fr 1fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13.2px; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; color: var(--ink); }
.section-title {
    font-size: 13px; font-weight: 600; color: #3c4657;
    display: flex; align-items: center; gap: 8px; margin: 0 0 12px;
}
.section-title .bar { width: 3px; height: 14px; border-radius: 2px; background: var(--brand); }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 2px; background: #eef1f7; }
.timeline-item { position: relative; padding-bottom: 14px; font-size: 12.5px; }
.timeline-item::before {
    content: ""; position: absolute; left: -18px; top: 4px; width: 9px; height: 9px;
    border-radius: 50%; background: #fff; border: 2px solid #c9d6f5;
}
.timeline-item strong { font-size: 13px; display: block; }
.timeline-item span { color: var(--muted); }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: #fff;
}
.login-visual {
    position: relative;
    background: radial-gradient(1200px 600px at 10% 0%, #3f7bff 0%, #2f55d8 42%, #1f2f8a 100%);
    color: #fff;
    padding: 56px 60px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.login-visual::after {
    content: "";
    position: absolute; inset: auto -120px -160px auto;
    width: 460px; height: 460px; border-radius: 50%;
    background: rgba(255, 255, 255, .08);
}
.login-visual::before {
    content: "";
    position: absolute; right: 40px; top: -80px;
    width: 300px; height: 300px; border-radius: 50%;
    background: rgba(255, 255, 255, .06);
}
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 600; }
.login-visual h2 { font-size: 34px; line-height: 1.35; margin: 90px 0 18px; font-weight: 700; letter-spacing: -.5px; }
.login-visual p { color: rgba(255, 255, 255, .78); font-size: 14px; max-width: 460px; line-height: 1.8; }
.login-features { margin-top: 40px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 520px; position: relative; z-index: 2; }
.login-feature { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .16); border-radius: 12px; padding: 14px 16px; backdrop-filter: blur(6px); }
.login-feature i { font-size: 18px; opacity: .9; }
.login-feature strong { display: block; font-size: 13.5px; margin: 8px 0 2px; }
.login-feature span { font-size: 11.5px; color: rgba(255, 255, 255, .7); }
.login-foot { margin-top: auto; font-size: 12px; color: rgba(255, 255, 255, .55); position: relative; z-index: 2; }

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px; background: #fbfcfe; }
.login-card { width: 100%; max-width: 380px; }
.login-card h3 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 28px; }
.login-card .form-control { padding: 11px 14px; }
.login-card .btn { padding: 10px 16px; font-size: 14px; }
.login-tip {
    margin-top: 22px; background: #f2f6ff; border: 1px dashed #c9d8fb;
    border-radius: 10px; padding: 12px 14px; font-size: 12px; color: #4a5a7a; line-height: 1.8;
}

/* ---------- Misc ---------- */
.alert-soft-danger { background: #fdecec; border: 1px solid #f8d7d7; color: #b42323; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.alert-soft-success { background: #e7f7ef; border: 1px solid #cdeede; color: #0f7b4f; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.toast-stack { position: fixed; top: 74px; right: 22px; z-index: 1080; display: flex; flex-direction: column; gap: 8px; }
.toast-pill {
    background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: 10px; padding: 10px 16px; font-size: 13px; display: flex; align-items: center; gap: 8px;
    animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.tabs-line { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 16px; }
.tabs-line a {
    padding: 12px 12px 10px; font-size: 13.5px; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs-line a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.sidebar-toggle { display: none; }

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

@media (max-width: 900px) {
    .login-page { grid-template-columns: 1fr; }
    .login-visual { display: none; }
    .sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: 0 0 40px rgba(16, 24, 40, .18);
    }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open::after {
        content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .32); z-index: 1035;
    }
    .sidebar-toggle { display: grid; }
    .content { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .page-head-actions { width: 100%; margin-left: 0; }
}

@media (max-width: 576px) {
    .stat-grid { grid-template-columns: 1fr; }
    .user-meta { display: none; }
}