:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #EFF6FF;
    --success: #22C55E;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #6B7280;

    --bg-body: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-soft: #F9FAFB;
    --bg-hover: #F3F4F6;

    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --text-placeholder: #D1D5DB;

    --border: #E5E7EB;
    --border-light: #F3F4F6;

    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --sidebar-width: 220px;
    --topbar-h: 52px;
}

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

.svg-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; line-height: 0; }
.svg-icon svg { width: 100%; height: 100%; display: block; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }
ul { list-style: none; }

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

.sidebar {
    width: var(--sidebar-width);
    background: #FFFFFF;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: transform 0.25s ease;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-logo {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

.sidebar-nav { flex: 1; padding: 6px 0 20px; }

.nav-section-label {
    padding: 14px 18px 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    white-space: nowrap;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}
.sidebar-nav .nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.sidebar-nav .nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.sidebar-nav .nav-item .nav-icon {
    width: 18px; height: 18px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

.nav-group {}
.nav-parent {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 18px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.12s, color 0.12s;
    user-select: none;
}
.nav-parent:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-parent.active { color: var(--primary); font-weight: 600; }
.nav-parent .nav-icon { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-parent .nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-parent .nav-arrow {
    width: 14px; height: 14px; flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}
.nav-parent .nav-arrow svg { width: 100%; height: 100%; }
.nav-group.expanded .nav-parent .nav-arrow { transform: rotate(90deg); }

.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.nav-group.expanded .nav-children { max-height: 600px; }

.nav-child {
    display: block;
    padding: 6px 18px 6px 46px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.12s, color 0.12s;
}
.nav-child:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-child.active { color: var(--primary); font-weight: 600; background: var(--primary-light); }

.sidebar-footer {
    padding: 8px 18px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    flex-shrink: 0;
}

.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

.topbar {
    height: var(--topbar-h);
    background: #FFFFFF;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 12px;
    flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; min-width: 0; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.topbar-user img { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); }
.topbar-user .name { font-size: 13px; color: var(--text-primary); }

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}
.menu-toggle:hover { color: var(--primary); }

.breadcrumb-bar { padding: 8px 20px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .separator { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-secondary); font-weight: 500; }

.content { padding: 16px 20px; flex: 1; }

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--border);
}
.card-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 14px; }
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--primary); }
.stat-card .icon {
    width: 40px; height: 40px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card .icon svg { width: 20px; height: 20px; }
.stat-card .icon.blue { background: #EFF6FF; color: var(--primary); }
.stat-card .icon.green { background: #ECFDF5; color: var(--success); }
.stat-card .icon.orange { background: #FFFBEB; color: var(--warning); }
.stat-card .icon.red { background: #FEF2F2; color: var(--danger); }
.stat-card .info .label { font-size: 11px; color: var(--text-muted); margin-bottom: 1px; }
.stat-card .info .value { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.stat-card .info .sub { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.table-wrapper { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
    background: var(--bg-soft);
    padding: 9px 12px; text-align: left;
    font-weight: 600; color: var(--text-secondary);
    white-space: nowrap; border-bottom: 1px solid var(--border);
}
table.data-table td {
    padding: 9px 12px; border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
table.data-table tr:hover td { background: var(--bg-soft); }
table.data-table .empty { text-align: center; color: var(--text-placeholder); padding: 32px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; line-height: 1.5; }
.badge-success { background: #ECFDF5; color: var(--success); }
.badge-warning { background: #FFFBEB; color: var(--warning); }
.badge-danger { background: #FEF2F2; color: var(--danger); }
.badge-info { background: #F3F4F6; color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group .required { color: var(--danger); }
.input, .select, .textarea {
    width: 100%; padding: 7px 11px;
    border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 13px; color: var(--text-primary);
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.textarea { resize: vertical; min-height: 72px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-help { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 7px 16px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 13px; cursor: pointer; transition: all 0.15s;
    background: #fff; color: var(--text-primary); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--text-muted); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 24px; font-size: 14px; max-width: 200px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filter-bar .input, .filter-bar .select { width: auto; min-width: 140px; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 3px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all 0.15s;
}
.pagination a:hover { background: var(--bg-hover); border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-placeholder); cursor: not-allowed; }

.alert { padding: 9px 13px; border-radius: var(--radius); margin-bottom: 14px; font-size: 13px; }
.alert-success { background: #ECFDF5; color: var(--success); }
.alert-error { background: #FEF2F2; color: var(--danger); }
.alert-warning { background: #FFFBEB; color: var(--warning); }
.alert-info { background: #F3F4F6; color: var(--info); }

.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 1000; display: none;
    align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #fff; border-radius: 8px; width: 500px; max-width: 90%;
    max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-header { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; }
.modal-body { padding: 18px; }
.modal-footer { padding: 11px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.chart-container { width: 100%; height: 260px; position: relative; }
.chart-container canvas { width: 100%; height: 100%; display: block; }

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: 20px;
}
.auth-card {
    width: 380px;
    max-width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
}
.auth-logo {
    text-align: center;
    margin-bottom: 20px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.auth-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.auth-header { margin-bottom: 20px; text-align: center; }
.auth-header h1 { font-size: 19px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.auth-header p { font-size: 13px; color: var(--text-muted); }
.auth-form .form-group { margin-bottom: 14px; }
.auth-form .form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.auth-form .input { width: 100%; height: 40px; padding: 0 12px; font-size: 14px; }
.auth-form .btn { width: 100%; max-width: 200px; height: 40px; font-size: 14px; font-weight: 600; margin: 4px auto 0; display: flex; }
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--primary); font-weight: 500; }
.auth-footer { text-align: center; margin-top: 20px; font-size: 11px; color: var(--text-muted); }
.auth-captcha-row { display: flex; gap: 8px; }
.auth-captcha-row .input { flex: 1; }
.auth-captcha-img { height: 40px; width: 100px; cursor: pointer; border-radius: var(--radius); border: 1px solid var(--border); flex-shrink: 0; }
.auth-code-row { display: flex; gap: 8px; align-items: center; }
.auth-code-row .input { flex: 1; }
.auth-code-btn {
    flex-shrink: 0;
    width: 38px; height: 38px;
    min-width: 38px;
    padding: 0 !important;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 38px;
    text-align: center;
    border: none;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    transition: all .2s;
    display: inline-block;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
}
.auth-code-btn:hover { background: var(--primary-dark); }
.auth-code-btn:disabled { background: #C0C4CC; cursor: not-allowed; pointer-events: none; }

.switch-wrap { display: inline-flex; align-items: center; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: #D1D5DB; transition: .25s; border-radius: 22px;
}
.switch .slider:before {
    position: absolute; content: ""; height: 18px; width: 18px; left: 2px; bottom: 2px;
    background: #fff; transition: .25s; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked ~ .slider { background: var(--primary); }
.switch input:checked ~ .slider:before { transform: translateX(18px); }

.progress { height: 8px; background: var(--bg-body); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); transition: width .3s; border-radius: 4px; }

.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%;
    min-width: 170px; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-md); z-index: 200;
    padding: 4px 0; margin-top: 4px;
}
.dropdown-menu.show { display: block; }
.dropdown-menu .dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 13px; color: var(--text-secondary); font-size: 13px;
    transition: all 0.15s; cursor: pointer;
}
.dropdown-menu .dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.dropdown-menu .dropdown-item .svg-icon { color: var(--primary); width: 16px; height: 16px; }
.dropdown-menu .dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.sidebar-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4); z-index: 99;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .topbar { padding: 0 12px; }
    .topbar-user .name { display: none; }
    .content { padding: 12px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 12px; gap: 10px; }
    .stat-card .icon { width: 34px; height: 34px; }
    .stat-card .icon svg { width: 17px; height: 17px; }
    .stat-card .info .value { font-size: 17px; }
    .form-row { flex-wrap: wrap; gap: 10px; }
    .form-row > div, .form-row > .card { flex: 1 1 100% !important; min-width: 0; }
    .card { padding: 14px; }
    table.data-table { font-size: 12px; }
    table.data-table th, table.data-table td { padding: 7px 9px; }
    .filter-bar { flex-wrap: wrap; align-items: center; gap: 6px; }
    .filter-bar .input, .filter-bar .select { width: auto; min-width: 100px; flex: 1 1 100px; }
    .filter-bar .btn { width: auto; flex: 0 0 auto; padding: 6px 12px; font-size: 12px; }
    .auth-card { padding: 24px 20px; }
    .breadcrumb-bar { padding: 6px 12px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 10px; gap: 8px; }
    .stat-card .icon { width: 30px; height: 30px; }
    .stat-card .icon svg { width: 15px; height: 15px; }
    .stat-card .info .value { font-size: 16px; }
    .topbar-title { font-size: 13px; }
}
@media (max-width: 360px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .stat-card { padding: 8px; gap: 6px; }
    .stat-card .icon { width: 26px; height: 26px; }
    .stat-card .icon svg { width: 13px; height: 13px; }
    .stat-card .info .label { font-size: 10px; }
    .stat-card .info .value { font-size: 14px; }
    .stat-card .info .sub { font-size: 10px; }
}
