/* ============================================================
   诚芳加油站 · 经营工作台  v3 视觉
   深色导航 + 渐变主色 + 精致卡片；所有类名与 v2 兼容
   ============================================================ */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-deep: #1d4fd7;
  --primary-weak: #eef3fe;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea8a1f;
  --purple: #7c3aed;
  --text: #171a20;
  --text2: #7a828e;
  --text3: #a5adba;
  --line: #e8ebf0;
  --line-soft: #f0f2f5;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 26, 32, .05), 0 6px 20px rgba(23, 26, 32, .06);
  --shadow-lift: 0 4px 10px rgba(23, 26, 32, .07), 0 14px 34px rgba(23, 26, 32, .1);
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(37, 99, 235, .06), transparent 60%),
    radial-gradient(900px 420px at -10% 105%, rgba(22, 163, 74, .05), transparent 60%),
    var(--bg);
  color: var(--text); font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

#app { display: none; }
#app.on { display: flex; min-height: 100vh; }

/* ================= 侧边栏（深色渐变） ================= */
.sidebar {
  width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  padding: 22px 14px 16px;
  background: linear-gradient(180deg, #101a33 0%, #16223f 55%, #182b52 100%);
  position: sticky; top: 0; height: 100vh;
  box-shadow: 4px 0 24px rgba(16, 26, 51, .18);
}
.sidebar::after {
  content: ""; position: absolute; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 139, 255, .28), transparent 70%);
  top: -60px; left: -50px; pointer-events: none;
}
.logo { padding: 2px 10px 20px; display: flex; align-items: center; gap: 10px; position: relative; }
.logo .mark {
  width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, #2563eb, #4f8bff);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: 0 4px 14px rgba(59, 123, 255, .45);
}
.logo b { font-size: 15px; display: block; line-height: 1.2; color: #fff; letter-spacing: .3px; }
.logo small { display: block; font-size: 11.5px; color: rgba(255, 255, 255, .45); font-weight: 400; }
.nav-item {
  padding: 10px 13px; border-radius: 10px; cursor: pointer;
  color: rgba(255, 255, 255, .62);
  display: flex; align-items: center; gap: 10px; font-size: 14px; user-select: none;
  transition: background .15s, color .15s; position: relative;
}
.nav-item .ico { width: 22px; text-align: center; font-size: 15px; }
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active {
  background: linear-gradient(135deg, rgba(59, 123, 255, .95), rgba(37, 99, 235, .9));
  color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .4);
}
.nav-spacer { flex: 1; }
.whoami { padding: 12px 12px 6px; font-size: 12.5px; color: rgba(255, 255, 255, .55); border-top: 1px solid rgba(255, 255, 255, .1); }
.whoami b { color: #fff; font-size: 13px; }
.logout { color: #ff8f8f; cursor: pointer; padding-top: 2px; }
.logout:hover { opacity: .75; }

/* ================= 底部导航（手机） ================= */
.bottomnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255, 255, 255, .9);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(23, 26, 32, .06);
}
.bottomnav .nav-item { flex-direction: column; gap: 1px; font-size: 10.5px; padding: 5px 2px; flex: 1; border-radius: 9px; color: var(--text2); }
.bottomnav .nav-item .ico { font-size: 19px; width: auto; }
.bottomnav .nav-item.active { background: transparent; box-shadow: none; color: var(--primary); }
.bottomnav .nav-item.active .ico { transform: scale(1.08); }

/* ================= 主区 ================= */
.main { flex: 1; padding: 28px 32px 90px; max-width: 1180px; margin: 0 auto; width: 100%; }
.page { display: none; animation: fadein .2s ease; }
.page.on { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.page-title { font-size: 21px; font-weight: 800; letter-spacing: .2px; }
.page-sub { color: var(--text2); font-size: 12.5px; margin: 4px 0 20px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow);
  transition: box-shadow .18s ease, transform .18s ease;
}
.card:hover { box-shadow: var(--shadow-lift); }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 7px; }
.card h3 .hint { font-size: 12px; color: var(--text3); font-weight: 400; margin-left: auto; }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) {
  .g4, .g5 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .g2 { grid-template-columns: 1fr; }
}

/* ================= KPI ================= */
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 17px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), #4f8bff);
  opacity: .85;
}
.kpi .label { font-size: 12.5px; color: var(--text2); }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.3px; }
.kpi .unit { font-size: 12.5px; font-weight: 400; color: var(--text3); margin-left: 2px; }
.kpi .delta { font-size: 12px; margin-top: 3px; color: var(--text2); }
.kpi.primary {
  background: linear-gradient(135deg, #2563eb 0%, #3b7bff 60%, #5a94ff 100%);
  border: none; color: #fff; box-shadow: 0 8px 22px rgba(37, 99, 235, .35);
}
.kpi.primary::before { background: rgba(255, 255, 255, .35); }
.kpi.primary .label, .kpi.primary .unit { color: rgba(255, 255, 255, .8); }
.kpi.primary .delta { color: rgba(255, 255, 255, .88); }
.kpi.green::before { background: linear-gradient(90deg, var(--green), #3ddc84); }
.kpi.red::before { background: linear-gradient(90deg, var(--red), #ff7b7b); }
.kpi.orange::before { background: linear-gradient(90deg, var(--orange), #ffc14d); }
.up { color: var(--green); } .down { color: var(--red); }

/* ================= 表单 ================= */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.field label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 5px; }
.field input, .field select {
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--text3); }
.field input:focus, .field select:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3.5px rgba(37, 99, 235, .12);
}
.btn {
  border: none; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 14.5px; cursor: pointer; font-family: inherit; font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #3b7bff);
  box-shadow: 0 3px 10px rgba(37, 99, 235, .3);
  transition: filter .15s, transform .1s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 5px 16px rgba(37, 99, 235, .38); }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--primary-weak); color: var(--primary); box-shadow: none; }
.btn.ghost:hover { background: #dfe9fd; filter: none; }
.btn.danger { background: #fdeaea; color: var(--red); box-shadow: none; }
.btn.danger:hover { background: #fbdcdc; filter: none; }
.btn.small { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.form-foot { margin-top: 14px; display: flex; gap: 10px; align-items: center; }
.form-msg { font-size: 13px; }

/* ================= 表格 ================= */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; color: var(--text3); font-weight: 600; font-size: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fafbfd;
  position: sticky; top: 0;
}
td { padding: 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-variant-numeric: tabular-nums; color: #333a45; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f4f7fe; }
td.num, th.num { text-align: right; }
.badge { display: inline-block; padding: 2.5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.red { background: #fdeaea; color: var(--red); }
.badge.green { background: #e5f6ec; color: var(--green); }
.badge.gray { background: #f0f2f5; color: var(--text2); }
tr.warn td { background: #fff9ef; }
tr.bad td { background: #fdf1f1; }

/* ================= 图表 ================= */
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 340px; }
@media (max-width: 900px) { .chart-box { height: 230px; } }

/* ================= 月选择 ================= */
.month-pick { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.month-pick label { font-size: 13px; color: var(--text2); }
.month-pick input {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14.5px; font-family: inherit; background: #fff; color: var(--text);
  box-shadow: var(--shadow);
}
.month-pick input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3.5px rgba(37, 99, 235, .12); }

/* ================= 登录页 ================= */
#login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(165deg, #eaf1fe 0%, #f4f6fa 48%, #e8f3ed 100%);
  padding: 20px; position: relative; overflow: hidden;
}
#login::before, #login::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55; pointer-events: none;
}
#login::before { width: 380px; height: 380px; background: #bcd3ff; top: -120px; left: -100px; }
#login::after { width: 320px; height: 320px; background: #bfe9d4; bottom: -110px; right: -80px; }
.login-card {
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 20px; box-shadow: 0 10px 44px rgba(23, 26, 32, .1);
  padding: 40px 32px 32px; width: 344px; max-width: 100%; text-align: center;
  position: relative; z-index: 1;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(135deg, #2563eb, #4f8bff);
  display: flex; align-items: center; justify-content: center; font-size: 27px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
}
.login-card h1 { font-size: 20px; letter-spacing: .5px; font-weight: 800; }
.login-card .sub { color: var(--text2); font-size: 12.5px; margin: 6px 0 26px; }
.login-card input {
  width: 100%; padding: 11px 14px; margin-bottom: 12px; border: 1px solid var(--line);
  border-radius: 11px; font-size: 15px; font-family: inherit; outline: none;
  background: #fafbfc; transition: border-color .15s, box-shadow .15s, background .15s; text-align: center;
}
.login-card input:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3.5px rgba(37, 99, 235, .12); }
.login-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 2px 0 6px; }
.login-card .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-foot { margin-top: 18px; font-size: 11.5px; color: var(--text3); }

/* ================= 杂项 ================= */
.empty { text-align: center; color: var(--text3); padding: 34px 0; font-size: 13.5px; }
.noperm { text-align: center; padding: 60px 20px; color: var(--text2); }
.noperm .ico { font-size: 42px; margin-bottom: 12px; }
.tag {
  display: inline-block; background: var(--primary-weak); color: var(--primary);
  border-radius: 6px; padding: 1.5px 8px; font-size: 11.5px; margin-left: 6px; font-weight: 600;
}

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  .main { padding: 16px 14px 100px; }
  .kpi .value { font-size: 20px; }
  .card { padding: 15px 16px; }
  .page-title { font-size: 18px; }
}