/* ===== SK-II Atlas 设计系统 ===== */
:root {
  --bg: #f7f4ee;
  --bg-soft: #fbf9f5;
  --card: #ffffff;
  --ink: #1c1c20;
  --ink-2: #55555e;
  --ink-3: #9a9aa3;
  --line: #eae5dc;
  --red: #c8102e;
  --red-dark: #a30d26;
  --red-soft: #fbeef0;
  --gold: #b08d57;
  --gold-soft: #f6efe4;
  --green: #1f7a4d;
  --green-soft: #e8f4ed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28,28,32,.04), 0 8px 24px -12px rgba(28,28,32,.10);
  --font: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--red); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: -.5px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--ink-3); letter-spacing: 2px; margin-top: 1px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a {
  padding: 7px 14px; border-radius: 8px; font-size: 14px; color: var(--ink-2);
  font-weight: 500;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.role-badge {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: var(--gold-soft); color: var(--gold); font-weight: 600;
}
.role-badge.admin { background: var(--red-soft); color: var(--red); }
.role-badge.data_manager { background: var(--green-soft); color: var(--green); }
.user-name { font-size: 14px; font-weight: 600; }
.btn-ghost {
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  padding: 6px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }

/* ===== 布局 ===== */
.container { max-width: 1280px; margin: 0 auto; padding: 28px 24px 80px; }
.section { margin-bottom: 22px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ===== 卡片 ===== */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-title {
  font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.card-title::before {
  content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--red);
}
.card-sub { font-size: 12.5px; color: var(--ink-3); }
.card-head .spacer { flex: 1; }

/* ===== 筛选栏 ===== */
.filterbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 22px;
  position: sticky; top: 68px; z-index: 40;
}
.seg { display: flex; background: var(--bg); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 8px;
  font-size: 13.5px; color: var(--ink-2); cursor: pointer; font-weight: 500;
  transition: all .15s;
}
.seg button.active { background: var(--ink); color: #fff; font-weight: 600; }
.seg.small button { padding: 5px 12px; font-size: 12.5px; }
select, input[type=date], input[type=text], input[type=password], input[type=file] {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px;
  font-size: 13.5px; font-family: inherit; background: #fff; color: var(--ink);
  outline: none;
}
select:focus, input:focus { border-color: var(--ink-3); }
.filter-label { font-size: 13px; color: var(--ink-3); }
.range-note { font-size: 12.5px; color: var(--ink-3); margin-left: auto; }

/* ===== KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px 16px;
  position: relative; overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--red), var(--gold));
  opacity: .65;
}
.kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 500; display:flex; align-items:center; gap:6px; }
.kpi-value {
  font-size: 26px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
}
.kpi-value.na { color: var(--ink-3); font-weight: 600; }
.kpi-foot { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; align-items: center; }
.delta { font-weight: 700; font-size: 12px; padding: 1px 7px; border-radius: 10px; }
.delta.up { color: var(--green); background: var(--green-soft); }
.delta.down { color: var(--red); background: var(--red-soft); }
.delta.flat { color: var(--ink-3); background: var(--bg); }

/* ===== 表格 ===== */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.tbl td { padding: 10px 12px; border-bottom: 1px solid #f2eee7; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--bg-soft); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl .strong { font-weight: 700; }
.tbl-wrap { overflow-x: auto; }
.rank-dot {
  display: inline-flex; width: 22px; height: 22px; border-radius: 50%;
  align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700;
  background: var(--bg); color: var(--ink-2);
}
.rank-dot.top { background: var(--red); color: #fff; }
.rank-dot.second { background: var(--gold); color: #fff; }
.rank-dot.third { background: #d8b98a; color: #fff; }
.bar-cell { display: flex; align-items: center; gap: 10px; }
.bar-track { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--red), #e0556c); }
.bar-fill.gold { background: linear-gradient(90deg, var(--gold), #d5b98c); }
.bar-with-pct {
  display: flex; align-items: center; gap: 10px; min-width: 140px;
}
.bar-with-pct .bar-track { flex: 1; }
.bar-with-pct .pct-num {
  width: 48px; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 12.5px; color: var(--ink-2); font-weight: 600; flex-shrink: 0;
}

/* 进度 */
.progress { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; min-width: 90px; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--green); }
.progress > i.warn { background: var(--gold); }
.progress > i.bad { background: var(--red); }

/* 标签 */
.tag { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.tag.flash { background: var(--red-soft); color: var(--red); }
.tag.promo { background: var(--gold-soft); color: var(--gold); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.warn { background: #fdf3e2; color: #b97d1f; }
.tag.bad { background: var(--red-soft); color: var(--red); }

/* 图表 */
.chart { width: 100%; height: 320px; }
.chart.tall { height: 360px; }

/* 空状态 */
.empty {
  padding: 42px 20px; text-align: center; color: var(--ink-3); font-size: 13.5px;
}
.empty b { color: var(--ink-2); }

/* 统计小卡 */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; background: var(--bg-soft);
}
.stat .s-label { font-size: 12px; color: var(--ink-3); }
.stat .s-value { font-size: 20px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s-value small { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* ===== 按钮 ===== */
.btn {
  border: 0; border-radius: 9px; padding: 9px 18px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-danger-ghost { background: transparent; border: 1px solid #f0c8ce; color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn.small { padding: 5px 12px; font-size: 12.5px; }
.link-btn { background: none; border: none; color: var(--red); cursor: pointer; font-size: 13px; font-weight: 600; }

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, #fdeef0 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 110%, #f6efe4 0%, transparent 50%),
    var(--bg);
}
.login-card {
  width: 400px; max-width: calc(100vw - 40px);
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 20px 60px -20px rgba(28,28,32,.18);
  padding: 40px 38px 36px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 800; letter-spacing: -.3px; }
.login-sub { color: var(--ink-3); font-size: 13px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.field input { width: 100%; padding: 11px 14px; font-size: 14px; }
.login-btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }
.form-error {
  background: var(--red-soft); color: var(--red); font-size: 13px;
  padding: 9px 13px; border-radius: 9px; margin-bottom: 14px; display: none;
}

/* ===== 管理后台 ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.tabs button {
  border: 0; background: none; padding: 11px 18px; font-size: 14.5px; cursor: pointer;
  color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--red); border-bottom-color: var(--red); font-weight: 700; }
.module-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
@media (max-width: 950px) { .module-grid { grid-template-columns: 1fr; } }
.module-card { padding: 20px; }
.module-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.module-icon {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--bg);
}
.module-name { font-weight: 700; font-size: 15.5px; }
.module-desc { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.5; }
.module-stats { font-size: 12.5px; color: var(--ink-2); margin: 10px 0; display: flex; gap: 16px; flex-wrap: wrap; }
.module-stats b { color: var(--ink); }
.upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.upload-row input[type=file] { flex: 1; min-width: 180px; font-size: 12.5px; padding: 7px; }
.upload-msg { font-size: 12.5px; margin-top: 8px; display: none; }
.upload-msg.ok { color: var(--green); display: block; }
.upload-msg.err { color: var(--red); display: block; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(20,20,24,.45); z-index: 100;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; padding: 26px; width: 460px; max-width: 100%;
  max-height: 86vh; overflow: auto; box-shadow: 0 24px 80px -24px rgba(0,0,0,.35);
}
.modal.wide { width: 900px; }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ===== 后台左右布局 ===== */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex-shrink: 0; background: #17181c; color: #b9bac2;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px;
  border-bottom: 1px solid #26272e;
}
.sidebar-brand .brand-name { color: #fff; font-size: 15px; }
.sidebar-brand .brand-sub { color: #6d6e78; }
.menu { padding: 14px 12px; flex: 1; }
.menu-group {
  font-size: 11px; color: #6d6e78; letter-spacing: 2px; font-weight: 700;
  padding: 14px 10px 8px;
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px; font-size: 13.5px; cursor: pointer;
  color: #b9bac2; margin-bottom: 2px; border: 0; background: none; width: 100%;
  text-align: left; font-family: inherit;
}
.menu-item:hover { background: #22232a; color: #fff; }
.menu-item.active { background: var(--red); color: #fff; font-weight: 600; }
.menu-item .mi-icon { width: 20px; text-align: center; font-size: 15px; }
.menu-item .mi-count {
  margin-left: auto; font-size: 11px; background: #2c2d35; color: #8b8c95;
  padding: 1px 8px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.menu-item.active .mi-count { background: rgba(255,255,255,.22); color: #fff; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid #26272e; font-size: 12.5px; }
.sidebar-foot .sf-user { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sidebar-foot .sf-name { color: #fff; font-weight: 600; font-size: 13px; }
.sidebar-foot .sf-actions { display: flex; gap: 8px; }
.sidebar-foot .sf-actions a, .sidebar-foot .sf-actions button {
  flex: 1; text-align: center; padding: 7px 0; border-radius: 8px; font-size: 12.5px;
  background: #22232a; color: #b9bac2; border: 1px solid #2c2d35; cursor: pointer;
}
.sidebar-foot .sf-actions a:hover, .sidebar-foot .sf-actions button:hover { color: #fff; border-color: #3a3b44; }
.admin-main { flex: 1; min-width: 0; background: var(--bg); }
.admin-topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 0 28px; height: 58px; display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.admin-page-title { font-size: 16.5px; font-weight: 700; }
.admin-page-desc { font-size: 12.5px; color: var(--ink-3); }
.admin-content { padding: 24px 28px 60px; max-width: 1080px; }
.quarter-badge {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px;
  border-radius: 6px; background: var(--gold-soft); color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.upload-panel {
  display: grid; grid-template-columns: minmax(200px, 240px) 180px 1fr auto; gap: 10px; align-items: center;
}
.upload-panel input[type="text"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13.5px; font-family: inherit;
}
.upload-panel input[type="text"]:focus { outline: none; border-color: var(--red); }
@media (max-width: 900px) { .upload-panel { grid-template-columns: 1fr 1fr; } }
.hint-list { font-size: 12.5px; color: var(--ink-2); line-height: 1.9; }
.hint-list b { color: var(--ink); }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 13.5px; padding: 11px 22px;
  border-radius: 10px; z-index: 200; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

.footer {
  text-align: center; color: var(--ink-3); font-size: 12px; padding: 30px 0 40px;
  letter-spacing: 1px;
}
.hide { display: none !important; }
