/* 统计台 —— 样式 */

:root {
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #e6e8f0;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-2: #0ea5a4;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
               "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(140deg, #6366f1, #4338ca);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; letter-spacing: .5px; }
.brand-text small { color: var(--muted); font-size: 11px; }

.tabs { display: flex; gap: 4px; margin-left: 8px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.tab:hover { background: #f1f2f8; color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.pill {
  color: var(--muted);
  font-size: 12px;
  background: #f1f2f8;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- 布局 ---------- */

main { max-width: 1120px; margin: 0 auto; padding: 24px 24px 64px; }

.panel { display: none; }
.panel.active { display: block; animation: fade .18s ease; }

@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }

.hint { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #4338ca; }

.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.secondary:hover { background: #e2e5ff; }

.btn.ghost { background: #fff; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: #d3d7e3; }

.btn.danger { color: var(--danger); border-color: #f3d4d4; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }

.btn.mini { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.file-label { cursor: pointer; }

.link {
  border: 0;
  background: none;
  color: var(--accent);
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- 提示条 ---------- */

.empty-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}

.empty-banner .link { color: #b45309; }

/* ---------- 表单 ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px 16px;
}

.form-grid-inline {
  grid-template-columns: 1.2fr .8fr 1.6fr auto;
  align-items: end;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field > span em { font-style: normal; color: var(--accent); font-size: 11px; margin-left: 4px; }
.field-submit { justify-content: flex-end; }
.field-submit span { visibility: hidden; }

.input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfbfd;
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
  min-height: 38px;
}

.input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

.input.search { width: 220px; min-height: 34px; padding: 6px 12px; }
.input.date { width: 140px; min-height: 34px; padding: 6px 8px; }

.form-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  flex-wrap: wrap;
}

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; border-radius: 10px; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--muted);
  background: #fafbfd;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f1f6;
  vertical-align: top;
}

.data-table tbody tr:hover { background: #fafbff; }
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.num { text-align: right; }

.data-table .active-col { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.data-table th.active-col { background: #e6e9ff; }

.data-table .total-row td {
  border-top: 2px solid var(--line);
  border-bottom: 0;
  background: #fbfcff;
  font-weight: 600;
}

.table-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.row-actions { display: flex; align-items: center; gap: 10px; }
.cell-empty { color: #c2c6d2; }

/* ---------- 最近录入 ---------- */

.recent-list { display: flex; flex-direction: column; }

.recent-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 2px;
  border-bottom: 1px solid #f2f3f8;
  font-size: 13px;
}

.recent-item:last-child { border-bottom: 0; }
.recent-item .recent-main { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-item .recent-time { color: #9ca3af; font-size: 12px; white-space: nowrap; }

/* ---------- 统计控件 ---------- */

.controls {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.control { display: flex; flex-direction: column; gap: 6px; }
.control > label { font-size: 12.5px; color: var(--muted); }
.control select {
  border: 1px solid var(--line);
  background: #fbfbfd;
  border-radius: 9px;
  padding: 8px 12px;
  min-height: 38px;
  min-width: 130px;
  outline: none;
}
.control select:focus { border-color: var(--accent); background: #fff; }

.date-range { display: flex; align-items: center; gap: 6px; }
.date-range select { min-width: 110px; }
.dash { color: var(--muted); }
.control-actions { margin-left: auto; }

/* ---------- 统计卡片 ---------- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
}

.stat-card .label { color: var(--muted); font-size: 12.5px; }
.stat-card .value {
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -.5px;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.stat-card .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }

/* ---------- 图表 ---------- */

.chart { display: flex; flex-direction: column; gap: 9px; }

.bar-row { display: grid; grid-template-columns: minmax(90px, 22%) 1fr auto; gap: 12px; align-items: center; }

.bar-label {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #374151;
}

.bar-track { background: #f1f2f8; border-radius: 6px; height: 22px; overflow: hidden; }

.bar-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  min-width: 3px;
  transition: width .35s ease;
}

.bar-value {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 16px);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 80vw;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b91c1c; }

/* ---------- 空状态 ---------- */

.empty {
  padding: 28px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------- 价格页 ---------- */

.price-meta {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.price-meta .field { min-width: 180px; }

  .refund-row { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
  .refund-row .field { flex: 1; min-width: 180px; max-width: 320px; }
  .refund-reason { font-size: 11px; color: #9ca3af; margin-top: 2px; }

.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 16px; }
.perm-list label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.perm-list input { width: 16px; height: 16px; accent-color: var(--accent); }

.limited [data-perm] { display: none !important; }
.limited [data-perm].perm-on { display: revert !important; }

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.price-item {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcff;
  padding: 10px 12px 8px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.price-item:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .1);
  background: #fff;
}

.price-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.price-unit { color: #9ca3af; font-size: 11px; flex: none; }

.price-item input {
  width: 100%;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 20px;
  font-weight: 600;
  padding: 4px 0 2px;
  font-variant-numeric: tabular-nums;
}

.price-item input::placeholder { color: #c7cbd8; font-weight: 400; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.sub-head { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: #374151; }

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  min-height: 28px;
  align-items: flex-start;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f2f3fa;
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 12.5px;
}

.chip .chip-unit { color: var(--muted); font-size: 11px; }

.chip button {
  border: 0;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
}

.chip button:hover { color: var(--danger); }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form .input { flex: 1; min-width: 100px; }
.inline-form .btn { flex: none; }

code {
  background: #f2f3fa;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  word-break: break-all;
}

.limited .full-only { display: none !important; }

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; gap: 12px; padding: 10px 14px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; margin: 0; }
  .top-actions { margin-left: auto; }
  main { padding: 16px 14px 48px; }
  .form-grid-inline { grid-template-columns: 1fr; }
  .control-actions { margin-left: 0; }
  .input.search { width: 140px; }
  .settings-grid { grid-template-columns: 1fr; gap: 20px; }
  .price-meta .field { min-width: 140px; flex: 1; }
}

/* ---------- 登录 ---------- */
.login-cover {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: #eef0f8; padding: 20px;
}
.login-cover[hidden] { display: none; }
.login-card {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; width: 100%; max-width: 340px;
  padding: 28px 24px 22px; text-align: center;
  box-shadow: 0 20px 50px rgba(20, 24, 40, .12);
}
.login-logo {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 12px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 18px;
  background: linear-gradient(140deg, #6366f1, #4338ca);
}
.login-card h2 { margin: 0 0 4px; font-size: 17px; }
.login-sub { margin: 0 0 18px; font-size: 12.5px; color: var(--muted); }
.login-card .input { margin-bottom: 10px; }
.login-card .btn { width: 100%; margin-top: 4px; background: var(--accent); color: #fff; border: 0; }
.login-card .error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin: 8px 0 0; }

/* 品牌区可点击回看板 */
a.brand { text-decoration: none; color: inherit; }
a.brand:hover strong { color: var(--accent); }
