/* ============ 重置与基础 ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #FAF7F2;
    color: #2B2622;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ============ 配色变量 ============ */
:root {
    --bg-page: #FAF7F2;
    --bg-card: #FFFFFF;
    --color-main: #2B2622;
    --color-sub: #8C8278;
    --color-gold: #BFA06A;
    --color-dark: #3D3530;
    --color-line: #EDE7E0;
    --bg-tag: #F5F0E9;
    --shadow-card: 0 4px 24px rgba(61, 53, 48, 0.06);
    --radius: 16px;
    --radius-lg: 24px;
    --sidebar-w: 220px;
}

/* ============ 整体布局 ============ */
.app { display: flex; min-height: 100vh; }

/* ============ 侧边栏 ============ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-card);
    border-right: 1px solid var(--color-line);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}
.logo {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--color-line);
}
.logo-icon { color: var(--color-gold); font-size: 22px; }
.logo-text { font-size: 16px; font-weight: 600; color: var(--color-dark); white-space: nowrap; }

.nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: 12px;
    color: var(--color-sub);
    margin-bottom: 4px;
    transition: all 0.2s;
    font-size: 14px;
}
.nav-item:hover { background: var(--bg-tag); color: var(--color-dark); }
.nav-item.active { background: var(--color-dark); color: #fff; }
.nav-item.active .nav-ico { color: var(--color-gold); }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--color-line);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--color-gold);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600;
    text-transform: uppercase;
}
.user-name { color: var(--color-main); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
    display: block;
    width: 100%;
    text-align: center;
    padding: 9px;
    border: 1px solid var(--color-line);
    border-radius: 10px;
    color: var(--color-sub);
    font-size: 13px;
    transition: all 0.2s;
}
.btn-logout:hover { border-color: var(--color-gold); color: var(--color-gold); }

/* ============ 主内容区 ============ */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--color-line);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.menu-toggle {
    display: none;
    font-size: 20px;
    color: var(--color-dark);
    padding: 4px;
}
.page-title { font-size: 17px; font-weight: 600; color: var(--color-dark); }
.content {
    padding: 24px;
    flex: 1;
}

.sidebar-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(43, 38, 34, 0.4);
    z-index: 99;
}
.sidebar-mask.show { display: block; }

/* ============ 卡片 ============ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--color-line);
}
.card-title { font-size: 16px; font-weight: 600; color: var(--color-dark); }
.card-body { padding: 4px 0; }

/* ============ 统计卡片 ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card { margin-bottom: 0; }
.stat-label { font-size: 13px; color: var(--color-sub); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-dark); line-height: 1.2; }
.stat-trend { font-size: 12px; margin-top: 10px; }
.trend-up { color: var(--color-gold); }
.trend-down { color: #c97a6a; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    padding: 13px 14px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--color-line);
    vertical-align: middle;
}
.table th {
    background: var(--bg-tag);
    color: var(--color-sub);
    font-weight: 500;
    white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FCFAF7; }
.mono { font-family: "SF Mono", Consolas, "Roboto Mono", monospace; font-size: 13px; }
.empty-row { text-align: center; color: var(--color-sub); padding: 32px; }
.empty-row a { color: var(--color-gold); }
.mini-stat { display: inline-block; margin-right: 12px; font-size: 13px; color: var(--color-sub); }

/* ============ 标签 ============ */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    background: var(--bg-tag);
    color: var(--color-sub);
}
.tag-success { background: #E8F3EC; color: #4a8a5e; }
.tag-danger { background: #F7E9E6; color: #b06655; }
.tag-info { background: #EAF0F5; color: #5a7a99; }
.tag-gold { background: #F5EBD9; color: var(--color-gold); }
.tag-default { background: var(--bg-tag); color: var(--color-sub); }

/* ============ 按钮 ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn-primary { background: var(--color-dark); color: #fff; }
.btn-primary:hover { background: #4a413b; }
.btn-gold { background: var(--color-gold); color: #fff; }
.btn-gold:hover { background: #ccb077; }
.btn-default { background: var(--bg-card); border-color: var(--color-line); color: var(--color-main); }
.btn-default:hover { border-color: var(--color-gold); color: var(--color-gold); }
.btn-text { padding: 4px 8px; color: var(--color-gold); background: transparent; }
.btn-text:hover { color: #ccb077; }
.btn-danger-text { padding: 4px 8px; color: #b06655; background: transparent; }
.btn-danger-text:hover { color: #c97a6a; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled], .btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ 表单 ============ */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    color: var(--color-sub);
    margin-bottom: 7px;
}
.req { color: #b06655; }
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-line);
    border-radius: 10px;
    background: var(--bg-card);
    color: var(--color-main);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.form-input:focus { border-color: var(--color-gold); box-shadow: 0 0 0 3px rgba(191, 160, 106, 0.12); }
.form-input::placeholder { color: #c0b8ad; }
textarea.form-input { resize: vertical; min-height: 72px; line-height: 1.5; }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path fill='%238C8278' d='M2 4l4 4 4-4'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-hint { display: block; font-size: 12px; color: var(--color-sub); margin-top: 6px; }
.form-actions { margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-group-full { grid-column: 1 / -1; }

/* ============ 开关 ============ */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: relative;
    width: 42px;
    height: 24px;
    background: var(--color-line);
    border-radius: 12px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.switch-slider::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.switch input:checked + .switch-slider { background: var(--color-gold); }
.switch input:checked + .switch-slider::after { transform: translateX(18px); }
.switch-text { font-size: 13px; color: var(--color-main); }
.switch-sm .switch-slider { width: 36px; height: 20px; }
.switch-sm .switch-slider::after { width: 16px; height: 16px; }
.switch-sm input:checked + .switch-slider::after { transform: translateX(16px); }

/* ============ 模态框 ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow-y: auto;
}
.modal.show { display: flex; }
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(43, 38, 34, 0.5);
}
.modal-dialog {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(61, 53, 48, 0.2);
    width: 100%;
    max-width: 520px;
    z-index: 1;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-line);
}
.modal-title { font-size: 16px; font-weight: 600; color: var(--color-dark); }
.modal-close {
    font-size: 24px;
    color: var(--color-sub);
    width: 30px; height: 30px;
    line-height: 1;
    border-radius: 50%;
    transition: all 0.2s;
}
.modal-close:hover { background: var(--bg-tag); color: var(--color-dark); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--color-line);
}

/* ============ 分页 ============ */
.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}
.page-info { font-size: 13px; color: var(--color-sub); margin-right: auto; }
.page-btn {
    padding: 7px 14px;
    border: 1px solid var(--color-line);
    border-radius: 8px;
    color: var(--color-main);
    background: var(--bg-card);
    transition: all 0.2s;
}
.page-btn:hover { border-color: var(--color-gold); color: var(--color-gold); }
.page-btn.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ============ 筛选栏 ============ */
.filter-bar { margin-bottom: 20px; }
.filter-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.filter-item { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 13px; color: var(--color-sub); white-space: nowrap; }
.filter-item .form-input { min-width: 160px; }

/* ============ 页头/操作 ============ */
.page-actions { margin-bottom: 16px; }
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.back-link { color: var(--color-gold); font-size: 14px; margin-right: 14px; }
.page-head-title { font-size: 17px; font-weight: 600; color: var(--color-dark); }
.sub-title { font-size: 14px; font-weight: 600; color: var(--color-main); margin: 20px 0 12px; }

/* ============ 提示框 ============ */
.alert {
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: #F7E9E6; color: #b06655; }
.alert-success { background: #E8F3EC; color: #4a8a5e; }

/* ============ 图表(CSS柱状图) ============ */
.chart-wrap { padding: 10px 0; }
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 240px;
    padding-top: 20px;
    overflow-x: auto;
}
.bar-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 32px;
    flex: 1;
}
.bar-value { font-size: 11px; color: var(--color-sub); margin-bottom: 4px; }
.bar {
    width: 60%;
    min-height: 2px;
    background: linear-gradient(180deg, var(--color-gold), #ccb077);
    border-radius: 4px 4px 0 0;
    transition: height 0.3s;
}
.bar-label { font-size: 11px; color: var(--color-sub); margin-top: 6px; white-space: nowrap; }

/* ============ 登录页 ============ */
.login-body {
    background: var(--bg-page);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 40px rgba(61, 53, 48, 0.1);
    padding: 40px 32px;
    text-align: center;
}
.login-logo { margin-bottom: 28px; }
.login-logo-icon { font-size: 40px; color: var(--color-gold); display: block; margin-bottom: 12px; }
.login-title { font-size: 20px; font-weight: 600; color: var(--color-dark); margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--color-sub); }
.login-form { text-align: left; }
.login-copyright { margin-top: 28px; font-size: 12px; color: var(--color-sub); }

/* ============ 响应式 ============ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(61, 53, 48, 0.15);
    }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .table th, .table td { padding: 10px 10px; font-size: 13px; }
    .filter-row { flex-direction: column; align-items: stretch; }
    .filter-item { width: 100%; }
    .filter-item .form-input { min-width: 0; flex: 1; }
    .modal { padding: 16px; }
    .modal-dialog { max-width: 100%; }
    .modal-body { padding: 18px; }
    .pagination { flex-wrap: wrap; }
    .page-info { width: 100%; margin-bottom: 6px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 24px; }
    .card { padding: 16px; }
    .topbar { padding: 0 16px; }
    .page-title { font-size: 16px; }
}
