
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

:root {
    --bg-main: #f7f8fc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #34495e;
    --text-secondary: #7f8c8d;
    --border-color: #ecf0f1;
    --accent-color: #3498db;
    --accent-color-dark: #2980b9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans SC', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Page */
.login-background {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0c3fc 0%, #8ec5fc 100%);
}

.login-panel {
    width: 380px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 500;
}

.field {
    margin-bottom: 20px;
}

.field label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.field input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #fff;
    font-size: 16px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.field input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.login-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background: var(--accent-color);
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.login-button:hover {
    background: var(--accent-color-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.3);
}

.error-message { color: #e74c3c; text-align: center; margin-top: 15px; height: 20px; font-size: 14px; }

/* Main Layout */
.layout { display: flex; height: 100vh; }

.sidebar {
    width: 260px;
    flex-shrink: 0; /* 核心修改：确保侧边栏宽度固定，不随内容变动或收缩 */
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 30px;
}

.logo-icon { font-size: 32px; color: var(--accent-color); }
.sidebar-title { margin: 0 0 0 15px; font-size: 24px; font-weight: 700; }

.menu { list-style: none; padding: 0; margin: 0; flex-grow: 1; }

.menu-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.menu-item .material-icons { margin-right: 15px; color: var(--text-secondary); }
.menu-item:hover { background: #ecf0f1; color: var(--accent-color); }
.menu-item:hover .material-icons { color: var(--accent-color); }

.menu-item.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.3);
}
.menu-item.active .material-icons { color: white; }

.sidebar-footer {
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#logout-btn {
    width: 100%;
    background: transparent;
    border: none;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
}
#logout-btn .material-icons { margin-right: 10px; }
#logout-btn:hover { background: #f3f4f6; color: #c0392b; }

.main-panel {
    flex-grow: 1;
    overflow: hidden; /* 核心修改：禁止主面板溢出滚动 */
    padding: 40px;
    height: 100vh;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.main-panel > main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* 允许内部元素自适应缩放 */
}

.metric-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}
.metric-card:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }

.card-icon { font-size: 36px; color: var(--accent-color); margin-right: 20px; }
.card-content { display: flex; flex-direction: column; }
.card-title { font-size: 14px; color: var(--text-secondary); }
.card-value { font-size: 28px; font-weight: 700; }

.content-section { display: none; }
.content-section.active { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    animation: fadeIn 0.5s ease;
    overflow-y: auto; /* 允许非仪表盘页面内部滚动 */
}

/* 仪表盘页面特殊处理，不滚动 */
#dashboard.content-section.active {
    overflow: hidden;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.content-header h2 { font-size: 28px; margin: 0 0 5px; }
.content-header p { font-size: 16px; color: var(--text-secondary); margin: 0; }

.content-header {
    margin-bottom: 20px;
    flex-shrink: 0;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    box-shadow: var(--shadow);
    flex-grow: 1; /* 自动填充剩余空间 */

    display: flex;
    flex-direction: column;
    position: relative; /* 核心修复 */
    min-height: 0; /* 核心修复：防止无限增长 */
}

.chart-container {
    flex-grow: 1;
    height: 100% !important;
    position: relative;
    min-height: 0;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Reports */
.controls-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.controls-bar input {
    flex-grow: 1;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

.controls-bar button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    transition: background 0.3s;
}
.controls-bar button:hover { background: var(--accent-color-dark); }

.data-table-card { background: var(--bg-card); border-radius: 12px; box-shadow: var(--shadow); overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 20px; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; font-size: 14px; }
thead th { background: #f9fafb; font-weight: 500; color: var(--text-secondary); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: #f5faff; }

.pagination { margin-top: 25px; text-align: center; }
.pagination button { background: white; border: 1px solid var(--border-color); padding: 8px 14px; margin: 0 4px; border-radius: 6px; cursor: pointer; }
.pagination button:disabled { background: var(--accent-color); color: white; border-color: var(--accent-color); }

/* Account */
.account-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }

.form-card { background: var(--bg-card); border-radius: 12px; padding: 30px; box-shadow: var(--shadow); }
.form-card h3 { margin: 0 0 25px; font-size: 20px; font-weight: 500; }

.info-field { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-size: 15px; }
.info-field span { color: var(--text-secondary); }
.info-field strong { font-weight: 500; }
.form-card hr { border: none; border-top: 1px solid var(--border-color); margin: 15px 0; }

.input-field { margin-bottom: 15px; }
.input-field label { display: block; font-size: 14px; color: var(--text-secondary); margin-bottom: 8px; }
.input-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border-color); border-radius: 6px; box-sizing: border-box; }

.form-card button {
    width: 100%;
    padding: 12px;
    margin-top: 10px;
    border: none;
    border-radius: 8px;
    background: var(--accent-color);
    color: white;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.3s;
}
.form-card button:hover { background: var(--accent-color-dark); }
