/* ===================== 基础 ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-soft: #64748b;
  --line: #e6eaf2;
  --brand: #2f6df6;
  --brand-soft: #eaf1ff;
  --green: #16a34a;
  --red: #ef4444;
  --amber: #f59e0b;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --radius: 12px;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ===================== 布局 ===================== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: #0f1b3d;
  color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #2f6df6);
  color: #fff; font-weight: 700; font-size: 18px;
  display: grid; place-items: center;
}
.brand-text strong { display: block; color: #fff; font-size: 15px; }
.brand-text small { color: #7c8aa5; font-size: 11px; letter-spacing: .5px; }
.nav { padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 9px; margin-bottom: 4px;
  color: #cbd5e1; font-weight: 500; transition: .15s;
}
.nav-item .ico { width: 18px; text-align: center; opacity: .8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(47,109,246,.4); }
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #5b6b8c; border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; }
.crumb { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.period-badge {
  background: var(--brand-soft); color: var(--brand);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.content { padding: 24px 26px; flex: 1; }

/* ===================== 组件 ===================== */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card-title { font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.stats-grid { grid-template-columns: repeat(4, 1fr); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 980px) { .stats-grid { grid-template-columns: repeat(2,1fr);} .cols-2,.cols-3{grid-template-columns:1fr;} }

.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { color: var(--ink-soft); font-size: 13px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat .delta { font-size: 12px; margin-top: 4px; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--red); }
.stat .accent { position: absolute; right: -10px; top: -10px; width: 60px; height: 60px; border-radius: 50%; opacity: .12; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  transition: .15s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #cbd5e1; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2560e0; }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--red); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { color: var(--ink-soft); font-weight: 600; background: #fafbfe; position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.tag-green { background: #dcfce7; color: #15803d; }
.tag-gray { background: #e2e8f0; color: #475569; }
.tag-amber { background: #fef3c7; color: #b45309; }
.tag-blue { background: var(--brand-soft); color: var(--brand); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.input, .inp, select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 13px; font-family: inherit; background: #fff; color: var(--ink); width: 100%;
}
.input:focus, .inp:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* 栅格 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* 统计卡片 */
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-k { color: var(--ink-soft); font-size: 13px; }
.stat-v { font-size: 24px; font-weight: 700; margin-top: 6px; }

/* 面板 */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.panel-h { font-weight: 600; margin-bottom: 12px; }

/* 表格容器 */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.table-wrap .table { box-shadow: none; border: none; }

/* 登录错误 */
.auth-err { display: none; color: var(--red); font-size: 12px; margin: 12px 0 0; }
.auth-err:not(:empty) { display: block; }
.auth-card .auth-form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.auth-card .btn-primary { margin-top: 16px; justify-content: center; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.field .req { color: var(--red); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: grid; place-items: center; z-index: 50; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 680px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; }
.modal-close { border: none; background: none; font-size: 18px; color: var(--ink-soft); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* toast */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: pop .2s ease;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px);} to {opacity:1; transform: translate(-50%,0);} }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 0; }
.chart-wrap { width: 100%; }
canvas { width: 100%; display: block; }
.muted { color: var(--ink-soft); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend span { font-size: 12px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.kbd { font-size: 11px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--ink-soft); }
.pill-filter { display: inline-flex; gap: 6px; }
.pill-filter .btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===================== 登录页 ===================== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f1b3d, #1e3a8a); padding: 20px; }
.auth-card { width: 380px; max-width: 100%; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, #3b82f6, #2f6df6); color: #fff; font-weight: 700; font-size: 22px; display: grid; place-items: center; margin-bottom: 14px; }
.auth-card h2 { font-size: 20px; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-soft); font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.auth-tabs button { flex: 1; padding: 10px; border: 1px solid var(--line); background: #fff; border-radius: 9px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.auth-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.auth-hint { font-size: 12px; color: var(--ink-soft); background: var(--brand-soft); padding: 8px 12px; border-radius: 8px; margin-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-chip .av { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; }
.user-chip .un { font-size: 13px; font-weight: 600; }
.user-chip .role { font-size: 11px; color: var(--ink-soft); }
.role-tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
