/* ===== 后台样式 ===== */
:root {
    --primary: #3b6ef5;
    --primary-dark: #2b55c9;
    --primary-light: #e8eefd;
    --bg: #f3f4f6;
    --card: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --danger: #ef4444;
    --success: #10b981;
    --sidebar-w: 220px;
    --radius: 10px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg); color: var(--text); font-size: 14px; min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }

/* 登录页 */
.login-body {
    background: linear-gradient(135deg, #3b6ef5 0%, #6d5ef5 50%, #8b5cf6 100%);
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.login-box {
    background: #fff; border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { font-size: 46px; }
.login-logo h1 { font-size: 20px; margin-top: 10px; }
.login-logo p { color: var(--text-light); font-size: 13px; margin-top: 4px; }
.login-form label { display: block; font-size: 13px; color: var(--text-light); margin: 14px 0 6px; }
.login-form input {
    width: 100%; height: 42px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; outline: none; transition: border .2s;
}
.login-form input:focus { border-color: var(--primary); }
.captcha-row { display: flex; gap: 8px; }
.captcha-row input { flex: 1; }
.captcha-row img { height: 42px; width: 130px; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; object-fit: cover; }
.login-btn {
    width: 100%; height: 44px; margin-top: 22px; border: none; border-radius: 8px;
    background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-btn:hover { background: var(--primary-dark); }
.login-err {
    background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; border-radius: 8px;
    padding: 10px 14px; font-size: 13px; margin-top: 14px; display: none;
}
.login-back { display: block; text-align: center; margin-top: 18px; color: var(--text-light); font-size: 13px; }

/* 后台布局 */
.admin-body { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: #1f2937; color: #d1d5db; flex-shrink: 0;
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
    padding: 20px 18px; border-bottom: 1px solid #374151; display: flex; align-items: center; gap: 10px;
    color: #fff; font-size: 16px; font-weight: 700;
}
.sidebar-logo .icon { font-size: 22px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px; padding: 11px 20px; color: #9ca3af;
    font-size: 14px; transition: all .15s; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: #2d3748; }
.sidebar-nav a.active { color: #fff; background: #374151; border-left-color: var(--primary); }
.sidebar-nav .nav-group { padding: 14px 20px 6px; font-size: 12px; color: #6b7280; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid #374151; font-size: 12px; color: #6b7280; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px;
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-right .user { color: var(--text-light); font-size: 13px; }
.topbar-right .user strong { color: var(--text); }

.content { padding: 24px; flex: 1; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
    background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
    padding: 18px; display: flex; align-items: center; gap: 14px;
}
.stat-card .s-icon {
    width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-card .s-num { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-card .s-label { color: var(--text-light); font-size: 12px; }
.bg-blue { background: #e8eefd; } .bg-green { background: #d1fae5; } .bg-orange { background: #fef3c7; } .bg-red { background: #fee2e2; } .bg-purple { background: #ede9fe; }

/* 面板 */
.panel {
    background: var(--card); border-radius: var(--radius); border: 1px solid var(--border);
    margin-bottom: 20px;
}
.panel-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 600; }
.panel-body { padding: 20px; overflow-x: auto; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
.table th { background: #f9fafb; color: var(--text-light); font-weight: 600; white-space: nowrap; }
.table tr:hover td { background: #fafbfd; }
.table .fname { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .ops { white-space: nowrap; }
.table .ops a, .table .ops button {
    display: inline-flex; align-items: center; gap: 3px; padding: 4px 10px; border-radius: 6px;
    font-size: 12px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; margin-right: 4px;
}
.table .ops a:hover, .table .ops button:hover { border-color: var(--primary); color: var(--primary); }
.table .ops .danger:hover { border-color: var(--danger); color: var(--danger); }

/* 标签 */
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; }
.tag-green { background: #d1fae5; color: #047857; }
.tag-gray { background: #f3f4f6; color: #6b7280; }
.tag-yellow { background: #fef3c7; color: #b45309; }
.tag-red { background: #fee2e2; color: #dc2626; }
.tag-blue { background: #e8eefd; color: #2b55c9; }

/* 按钮 */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 8px;
    font-size: 13px; font-weight: 500; border: none; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item label { font-size: 13px; color: var(--text-light); }
.form-item label .req { color: var(--danger); }
.form-item input[type="text"], .form-item input[type="password"], .form-item input[type="number"], .form-item input[type="url"], .form-item select, .form-item textarea {
    width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; outline: none; background: #fff; transition: border .2s;
}
.form-item textarea { height: auto; padding: 10px 12px; min-height: 90px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--primary); }
.form-item .hint { font-size: 12px; color: #9ca3af; }
.form-actions { margin-top: 22px; display: flex; gap: 10px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 24px; transition: .25s;
}
.switch .slider:before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: .25s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(20px); }

/* 上传区 */
.upload-zone {
    border: 2px dashed #cbd5e1; border-radius: 12px; padding: 48px 20px; text-align: center;
    color: var(--text-light); cursor: pointer; transition: all .2s; background: #fafbfd;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.upload-zone .u-icon { font-size: 44px; margin-bottom: 10px; }
.upload-list { margin-top: 16px; }
.upload-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--bg);
    border-radius: 8px; margin-bottom: 8px; font-size: 13px;
}
.upload-item .u-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item .u-status { font-size: 12px; }
.upload-item .u-status.ok { color: var(--success); }
.upload-item .u-status.err { color: var(--danger); }

/* 分页 */
.pagination { display: flex; justify-content: flex-end; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px; background: #fff; border: 1px solid var(--border); font-size: 13px; color: var(--text);
}
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .disabled { opacity: .5; pointer-events: none; }

/* 弹窗 */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: none;
    align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
    background: #fff; border-radius: 14px; width: 100%; max-width: 460px; padding: 26px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-body { font-size: 14px; color: var(--text-light); word-break: break-all; }
.modal-body .link-row { display: flex; gap: 8px; margin-top: 12px; }
.modal-body .link-row input {
    flex: 1; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; outline: none; min-width: 0;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* 提示 */
.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-80px);
    background: #111827; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14px;
    z-index: 999; opacity: 0; transition: all .3s; pointer-events: none; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* 图表占位 */
.chart-wrap { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-bar { width: 100%; max-width: 44px; background: var(--primary); border-radius: 6px 6px 0 0; min-height: 2px; transition: height .4s; position: relative; }
.chart-bar:hover { background: var(--primary-dark); }
.chart-num { font-size: 11px; color: var(--text-light); white-space: nowrap; }
.chart-day { font-size: 11px; color: var(--text-light); }

/* 空状态 */
.empty-tip { text-align: center; padding: 50px 20px; color: var(--text-light); }
.empty-tip .e-icon { font-size: 40px; margin-bottom: 8px; }

/* 响应式 */
@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 150; transform: translateX(-100%); transition: transform .25s; }
    .sidebar.open { transform: translateX(0); }
    .main-area { width: 100%; }
    .menu-toggle { display: inline-flex !important; }
    .content { padding: 14px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}
.menu-toggle {
    display: none; background: none; border: 1px solid var(--border); border-radius: 8px;
    width: 36px; height: 36px; align-items: center; justify-content: center; font-size: 18px; cursor: pointer;
}
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 140; display: none; }
.mask.show { display: block; }
