/* ============================================================
   道士全盘 · 管理后台 v3「极简墨白」
   ============================================================ */
:root {
  --bg: #F7F6F2;
  --surface: #FFFFFF;
  --ink: #181613;
  --ink-2: #6E675C;
  --ink-3: #A39B8E;
  --line: #EAE7DE;
  --red: #A63821;
  --green: #2E5E4E;
  --blue: #3D6D99;
  --serif: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

.admin-layout { display: flex; min-height: 100vh; }

/* 侧边栏：墨色 */
.side {
  width: 216px; background: var(--ink); color: rgba(255,255,255,.55);
  position: fixed; top: 0; bottom: 0; z-index: 10; display: flex; flex-direction: column;
}
.s-brand {
  padding: 24px 22px; display: flex; align-items: center; gap: 10px;
  color: #fff; font-family: var(--serif); font-size: 16px; letter-spacing: 4px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.s-brand svg { width: 20px; height: 20px; }
.s-brand small { display: block; font-size: 9px; color: rgba(255,255,255,.35); letter-spacing: 2px; font-family: var(--sans); }
.s-menu { padding: 16px 12px; display: grid; gap: 2px; }
.s-menu a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  font-size: 13px; border-left: 2px solid transparent; transition: all .15s;
}
.s-menu a::before { content: ""; width: 4px; height: 4px; background: rgba(255,255,255,.3); transform: rotate(45deg); flex-shrink: 0; }
.s-menu a:hover { color: #fff; }
.s-menu a.on { color: #fff; border-left-color: var(--red); background: rgba(255,255,255,.05); }
.s-menu a.on::before { background: var(--red); }
.s-foot { margin-top: auto; padding: 18px 22px; font-size: 11px; color: rgba(255,255,255,.3); border-top: 1px solid rgba(255,255,255,.08); line-height: 1.9; }

/* 主区 */
.main { flex: 1; margin-left: 216px; padding: 32px 36px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.topbar h1 { font-family: var(--serif); font-size: 22px; letter-spacing: 3px; }
.topbar .t-user { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13px; }
.t-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-family: var(--serif);
}

/* 数据卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); padding: 20px 22px; }
.stat-card.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.stat-card .s-label { font-size: 12px; color: var(--ink-3); letter-spacing: 1px; }
.stat-card.ink .s-label { color: rgba(255,255,255,.5); }
.stat-card .s-value { font-family: var(--serif); font-size: 27px; font-weight: 600; margin: 8px 0 4px; }
.stat-card .s-trend { font-size: 12px; color: var(--ink-3); }
.s-trend.up { color: var(--green); }
.s-trend.down { color: var(--red); }

/* 面板 */
.panel { background: var(--surface); border: 1px solid var(--line); padding: 24px; margin-bottom: 24px; }
.panel h3 { font-size: 15px; font-weight: 600; letter-spacing: 1px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.panel h3 small { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }

/* 漏斗 */
.funnel { display: grid; gap: 14px; }
.funnel-row { display: flex; align-items: center; gap: 14px; }
.funnel-row .f-label { width: 96px; text-align: right; color: var(--ink-2); font-size: 13px; }
.funnel-row .f-bar { height: 24px; background: var(--ink); color: #fff; font-size: 12px; display: flex; align-items: center; padding-left: 10px; min-width: 52px; }
.funnel-row .f-rate { font-size: 12px; color: var(--ink-3); }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { padding: 10px 12px; text-align: left; font-size: 12px; color: var(--ink-3); font-weight: 400; letter-spacing: 1px; border-bottom: 1px solid var(--ink); }
.tbl td { padding: 13px 12px; font-size: 13px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: #FBFAF7; }

/* 标签 */
.tag { display: inline-block; padding: 2px 9px; font-size: 12px; border-radius: 2px; letter-spacing: 1px; }
.tag-green { background: #EBF2EE; color: var(--green); }
.tag-red { background: #F7E9E5; color: var(--red); }
.tag-blue { background: #EAF0F5; color: var(--blue); }
.tag-gray { background: #F1EFE9; color: var(--ink-2); }
.tag-ink { background: var(--ink); color: #fff; }

/* 筛选栏 */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-bar input, .filter-bar select {
  padding: 9px 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; outline: none; border-radius: 2px;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--ink); }
.btn-a { padding: 9px 18px; font-size: 13px; background: var(--ink); color: #fff; border-radius: 2px; border: 1px solid var(--ink); cursor: pointer; letter-spacing: 1px; }
.btn-a.line { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-a.line:hover { border-color: var(--ink); }
.link-a { color: var(--blue); cursor: pointer; }

/* 分页 */
.pager { display: flex; gap: 6px; justify-content: flex-end; margin-top: 18px; }
.pager span { padding: 6px 12px; border: 1px solid var(--line); font-size: 13px; cursor: pointer; background: var(--surface); border-radius: 2px; }
.pager span.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* 柱状图 */
.chart-bars { display: flex; align-items: flex-end; gap: 12px; height: 170px; padding-top: 10px; }
.chart-bars .cb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bars .cb i { width: 68%; background: var(--ink); display: block; }
.chart-bars .cb:last-child i { background: var(--red); }
.chart-bars .cb small { color: var(--ink-3); font-size: 11px; }

/* ---------- 设置页表单 ---------- */
.set-sec-t { font-size: 13px; font-weight: 600; letter-spacing: 2px; margin: 28px 0 16px; padding-top: 22px; border-top: 1px solid #E8E3D6; }
.set-sec-t:first-of-type { border-top: 0; padding-top: 0; margin-top: 6px; }
.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 28px; margin-bottom: 16px; }
.f-row.three { grid-template-columns: 1fr 1fr 1fr; }
.set-field label { display: block; font-size: 12px; color: #6E675C; letter-spacing: 1px; margin-bottom: 7px; }
.set-field input, .set-field select, .set-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #D9D2C2; background: #fff;
  font-size: 13px; color: #181613; font-family: inherit; outline: none;
  transition: border-color .15s ease; border-radius: 0;
}
.set-field input:focus, .set-field select:focus, .set-field textarea:focus { border-color: #181613; }
.set-field input[disabled], .set-field select[disabled] { background: #F5F2E9; color: #A39B8E; }
.set-field textarea { resize: vertical; line-height: 1.8; }
.set-field .hint { font-size: 11px; color: #A39B8E; margin-top: 6px; letter-spacing: .5px; }
.cell-input {
  width: 84px; padding: 6px 8px; border: 1px solid #D9D2C2; background: #fff;
  font-size: 13px; text-align: right; outline: none; font-family: inherit;
}
.cell-input:focus { border-color: #181613; }
@media (max-width: 960px) { .f-row, .f-row.three { grid-template-columns: 1fr; } }

/* 图表生长动画 */
.chart-bars .cb i { animation: cbGrow .9s cubic-bezier(.2,.7,.3,1) both; }
.chart-bars .cb:nth-child(2) i { animation-delay: .08s; }
.chart-bars .cb:nth-child(3) i { animation-delay: .16s; }
.chart-bars .cb:nth-child(4) i { animation-delay: .24s; }
.chart-bars .cb:nth-child(5) i { animation-delay: .32s; }
.chart-bars .cb:nth-child(6) i { animation-delay: .4s; }
.chart-bars .cb:nth-child(7) i { animation-delay: .48s; }
@keyframes cbGrow { from { height: 0 !important; } }
.funnel-row .f-bar { animation: fGrow .9s cubic-bezier(.2,.7,.3,1) both; }
.funnel-row:nth-child(2) .f-bar { animation-delay: .1s; }
.funnel-row:nth-child(3) .f-bar { animation-delay: .2s; }
.funnel-row:nth-child(4) .f-bar { animation-delay: .3s; }
.funnel-row:nth-child(5) .f-bar { animation-delay: .4s; }
@keyframes fGrow { from { width: 0 !important; } }
.stat-card { transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(24,22,19,.06); }
.tbl tr { transition: background .15s ease; }

/* 区域切换器：统一管理后台通过两区 API 读写业务数据，自身仅存 SQLite3 */
.region-switch { display: flex; margin-left: auto; margin-right: 16px; border: 1px solid #D9D2C2; background: #fff; }
.region-switch button {
  border: 0; background: none; padding: 7px 14px; font-size: 12px; letter-spacing: 1px;
  color: #6E675C; cursor: pointer; display: flex; align-items: center; gap: 7px; font-family: inherit;
}
.region-switch button + button { border-left: 1px solid #EDE6D6; }
.region-switch button.on { background: #181613; color: #F7F6F2; }
.region-switch .dot { width: 6px; height: 6px; border-radius: 50%; background: #4A9B7F; box-shadow: 0 0 0 3px rgba(74,155,127,.16); }
.region-switch .dot.down { background: #B03A2E; box-shadow: 0 0 0 3px rgba(176,58,46,.14); }

@media (max-width: 960px) {
  .side { width: 60px; }
  .s-brand span, .s-brand small, .s-menu a span, .s-foot { display: none; }
  .main { margin-left: 60px; padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
