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

:root {
    --primary: #6366f1;
    --primary-dark: #5457e6;
    --primary-light: #eef0fe;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --text: #1e293b;
    --text-light: #64748b;
    --text-muted: #94a3b8;
    --bg: #f1f5f9;
    --card-bg: #fff;
    --border: #e2e8f0;
    --sidebar-w: 240px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 10px;
    --radius-lg: 14px;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

/* ============ Login ============ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    position: relative;
    overflow: hidden;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    top: -200px; right: -100px;
}
.login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    bottom: -150px; left: -100px;
}
.login-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    padding: 44px;
    width: 400px;
    max-width: 90vw;
    position: relative;
    z-index: 1;
}
.login-card h1 {
    text-align: center;
    font-size: 26px;
    margin-bottom: 6px;
    color: var(--text);
    font-weight: 800;
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 32px;
}
.login-card .form-group {
    margin-bottom: 20px;
}
.login-card label {
    display: block;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 600;
}
.login-card input {
    width: 100%;
    padding: 13px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
    transition: all 0.2s;
    background: #f8fafc;
}
.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px var(--primary-light);
}
.login-card button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}
.login-card button:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}
.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 18px;
    text-align: center;
    font-weight: 500;
}

/* ============ Layout ============ */
.layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 100%);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 12px rgba(0,0,0,0.1);
}
.sidebar-header {
    padding: 24px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header h2 {
    font-size: 18px;
    color: #fff;
    font-weight: 800;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-header p {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    margin-top: 4px;
}
.sidebar-nav {
    flex: 1;
    padding: 14px 0;
    overflow-y: auto;
}
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 22px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
    padding-left: 26px;
}
.sidebar-nav a.active {
    background: linear-gradient(90deg, rgba(99,102,241,0.3), transparent);
    color: #a5b4fc;
    border-left: 3px solid var(--primary);
    padding-left: 19px;
}
.sidebar-nav .nav-icon {
    width: 22px;
    text-align: center;
    font-size: 16px;
}
.sidebar-footer {
    padding: 16px 22px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer p {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 8px;
}
.sidebar-footer a {
    color: rgba(255,255,255,0.4);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}
.sidebar-footer a:hover { color: #fff; }

.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 28px 32px;
}
.page-header {
    margin-bottom: 28px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 24px;
    color: var(--text);
    font-weight: 800;
}
.page-header p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

/* ============ Stat Cards ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
    font-weight: 500;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}
.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 16px;
    font-size: 32px;
    opacity: 0.12;
}
.stat-card.green .stat-value { color: var(--success); }
.stat-card.green { border-top: 3px solid var(--success); }
.stat-card.blue .stat-value { color: var(--primary); }
.stat-card.blue { border-top: 3px solid var(--primary); }
.stat-card.orange .stat-value { color: var(--warning); }
.stat-card.orange { border-top: 3px solid var(--warning); }
.stat-card.red .stat-value { color: var(--danger); }
.stat-card.red { border-top: 3px solid var(--danger); }

/* ============ Filter Bar ============ */
.filter-bar {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}
.filter-bar .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.filter-bar label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 600;
    white-space: nowrap;
}
.filter-bar input[type="date"],
.filter-bar input[type="text"],
.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    transition: all 0.2s;
}
.filter-bar input[type="date"]:focus,
.filter-bar input[type="text"]:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: #fff;
}
/* 日期输入框：点击任意位置弹出日历 */
.filter-bar input[type="date"] {
    position: relative;
    cursor: pointer;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}
/* WebKit/Chrome: 让日历图标覆盖整个输入区域 */
.filter-bar input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}
/* 快捷日期按钮 */
.date-quick {
    display: inline-flex;
    gap: 4px;
    flex-wrap: wrap;
}
.date-quick button {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.date-quick button:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}
.date-quick button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
/* 年份按钮：用不同颜色区分 */
.date-quick button:nth-child(n+10) {
    background: linear-gradient(135deg, #f0f4ff, #e8ecfe);
    color: var(--primary);
    border-color: #c7d2fe;
    font-weight: 700;
}
.date-quick button:nth-child(n+10):hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.date-quick button:nth-child(n+10).active {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border-color: var(--primary);
}
.filter-bar .btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.filter-bar .btn-primary {
    background: var(--primary);
    color: #fff;
}
.filter-bar .btn-primary:hover {
    background: var(--primary-dark);
}
.filter-bar .btn-secondary {
    background: #f1f5f9;
    color: var(--text);
}
.filter-bar .btn-secondary:hover {
    background: #e2e8f0;
}
.filter-bar .search-box {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    position: relative;
}
.filter-bar .search-box input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
}
.filter-bar .search-box::before {
    content: "\1F50D";
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    opacity: 0.4;
}

/* ============ Table ============ */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.table-wrapper {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
thead th {
    background: #f8fafc;
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    color: #475569;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    white-space: nowrap;
}
tbody tr {
    transition: background 0.1s;
}
tbody tr:hover {
    background: var(--primary-light);
}
tbody tr:nth-child(even) {
    background: #fafbfc;
}
tbody tr:nth-child(even):hover {
    background: var(--primary-light);
}

/* ============ Badges ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}
.badge-green { background: var(--success-light); color: #065f46; }
.badge-blue { background: #dbeafe; color: #1e3a8a; }
.badge-orange { background: var(--warning-light); color: #92400e; }
.badge-red { background: var(--danger-light); color: #991b1b; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ============ Pagination ============ */
.pagination {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 8px;
}
.pagination .page-info {
    font-size: 13px;
    color: var(--text-light);
}
.pagination .page-links {
    display: flex;
    gap: 4px;
}
.pagination a, .pagination span {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
}
.pagination a:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}
.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}

/* ============ Charts ============ */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.chart-card h3 {
    font-size: 16px;
    margin-bottom: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chart-card h3::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--primary);
    border-radius: 2px;
}
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 220px;
    padding-top: 24px;
}
.bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.bar-fill {
    width: 100%;
    max-width: 42px;
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: height 0.3s;
    position: relative;
}
.bar-fill:hover {
    opacity: 0.85;
}
.bar-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
}
.bar-value {
    font-size: 11px;
    color: var(--text);
    font-weight: 700;
}

/* ============ Misc ============ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.muted { color: var(--text-light); }
.empty {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 15px;
}

/* Quick stats inline */
.inline-stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.inline-stat {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 12px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
}
.inline-stat .label {
    font-size: 12px;
    color: var(--text-light);
}
.inline-stat .value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
}

@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-header h2, .sidebar-header p,
    .sidebar-nav a span:not(.nav-icon),
    .sidebar-footer p, .sidebar-footer a { display: none; }
    .sidebar-nav a { justify-content: center; padding: 14px 0; }
    .main { margin-left: 60px; padding: 16px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar .search-box { max-width: 100%; }
}
