:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #182420;
  --muted: #6d7b74;
  --line: #e4e9e5;
  --accent: #0f766e;
  --accent-dark: #0b5f58;
  --accent-soft: #e4f3f0;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --shadow: 0 12px 30px rgba(21, 45, 36, .08);
  --radius: 14px;
  --side: #10241f;
  --side-soft: #1a352d;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
    "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: "Cascadia Mono", Consolas, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- 登录 ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth-hero {
  position: relative;
  padding: 64px 72px;
  background:
    radial-gradient(900px 480px at -10% 10%, #1c4a3e 0%, transparent 60%),
    radial-gradient(700px 500px at 90% 90%, #143b33 0%, transparent 55%),
    var(--side);
  color: #ecf5f0;
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
}
.auth-hero.admin { background: radial-gradient(800px 480px at 0 0, #23406b 0%, transparent 60%), #101c30; }
.auth-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -140px;
  width: 420px; height: 420px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 0 0 60px rgba(255,255,255,.03), 0 0 0 120px rgba(255,255,255,.02);
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .5px; }
.auth-hero h1 { font-size: 34px; line-height: 1.35; margin: 30px 0 14px; letter-spacing: 1px; }
.auth-hero > p { color: #b9cec5; max-width: 480px; line-height: 1.8; margin: 0 0 34px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; max-width: 460px; }
.auth-points li { display: flex; align-items: baseline; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.auth-points b { min-width: 78px; color: #fff; }
.auth-points span { color: #9fb8ae; }
.auth-foot { margin-top: 36px; color: #8aa69b; font-size: 12px; letter-spacing: 1px; }
.logo-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: #14b8a6; color: #06231e; font-weight: 800; font-size: 16px;
  box-shadow: 0 6px 18px rgba(20,184,166,.35);
}
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 48px; background: #fbfcfb; }
.auth-card { width: 100%; max-width: 390px; }
.auth-title { font-size: 22px; margin: 0 0 22px; }
.auth-tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.auth-tab {
  background: none; border: none; padding: 0 0 12px; cursor: pointer;
  color: var(--muted); font-weight: 600; position: relative;
}
.auth-tab.active { color: var(--ink); }
.auth-tab.active::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent); border-radius: 2px;
}
.auth-form { display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.auth-form input {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  padding: 12px 13px; outline: none; transition: .15s; font-weight: normal;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }
.code-row { display: flex; gap: 8px; align-items: stretch; }
.code-row input { flex: 1; min-width: 0; }
.code-row .btn { padding: 0 14px; }
.password-row { display: flex; gap: 8px; align-items: stretch; }
.password-row input { flex: 1; min-width: 0; }
.password-row .btn { padding: 0 14px; }
.auth-hint { color: var(--muted); font-size: 12px; line-height: 1.7; margin: 2px 0 0; }
.auth-inline { display: flex; justify-content: flex-end; margin: -8px 0 -6px; }
.text-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; }
.text-link:hover { color: var(--accent-dark); text-decoration: underline; }
.link-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; margin-top: 26px; font-size: 12px; }
.link-btn:hover { color: var(--accent); }

/* ---------- 框架 ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--side); color: #cfe0d8; display: flex; flex-direction: column;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; font-weight: 700; color: #fff; }
.side-brand-text { letter-spacing: .5px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-group { color: #6f8b80; font-size: 11px; letter-spacing: 1px; padding: 14px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; border: none; background: none;
  color: #b7ccc3; padding: 10px 12px; border-radius: 9px; cursor: pointer;
  text-align: left; font-size: 13.5px; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: #14b8a6; color: #05231f; font-weight: 700; }
.nav-item .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; }
.side-user { padding: 4px 10px 10px; font-size: 12px; line-height: 1.6; }
.side-user b { display: block; color: #fff; font-size: 13px; }
.side-user span { color: #86a196; }
.side-logout {
  width: 100%; background: rgba(255,255,255,.06); border: none; color: #cfe0d8;
  border-radius: 9px; padding: 9px; cursor: pointer; font-size: 12.5px;
}
.side-logout:hover { background: rgba(255,255,255,.12); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 18px;
  padding: 26px 34px 18px; background: rgba(244,246,244,.92);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: .3px; }
.page-sub { margin: 6px 0 0; color: var(--muted); font-size: 12.5px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 34px 60px; }
.support-banner {
  margin: 16px 34px 0; padding: 12px 16px; border-radius: 10px;
  background: var(--warn-soft); color: #8a4b07; border: 1px solid #f3d9b5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px;
}

/* ---------- 通用组件 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 15px; border-radius: 9px; cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #c8d2cc; background: #fafbfa; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f1c9c5; background: var(--danger-soft); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(16,36,31,.02);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -30px; width: 90px; height: 90px;
  border-radius: 50%; background: var(--accent-soft); opacity: .7;
}
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 27px; font-weight: 700; margin: 10px 0 2px; letter-spacing: .5px; }
.stat .extra { color: var(--muted); font-size: 12px; }
.stat.warn::after { background: var(--warn-soft); }
.stat.warn .value { color: var(--warn); }
.stat.today::after { background: var(--ok-soft); }
.stat.today .value { color: var(--ok); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: #eaeeeb; border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: none; padding: 7px 14px; border-radius: 7px;
  cursor: pointer; color: var(--muted); font-size: 12.5px;
}
.seg button.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.field { display: flex; align-items: center; gap: 7px; }
.field label { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.input, select.input {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 11px;
  background: #fff; outline: none; min-width: 0;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.search { width: 220px; }

.table-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fbfcfb;
  white-space: nowrap;
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { cursor: pointer; transition: background .12s; }
.tbl tbody tr:hover { background: #f8faf9; }
.tbl tbody tr.static { cursor: default; }
.tbl .thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; background: #eef2ef; border: 1px solid var(--line); display: block; }
.tbl .title { font-weight: 600; }
.tbl .sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.confirmed { background: var(--ok-soft); color: var(--ok); }
.badge.ignored { background: #eef1ef; color: var(--muted); }
.badge.trial { background: #e8f1fd; color: #1d4ed8; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.suspended { background: var(--danger-soft); color: var(--danger); }
.badge.expired { background: #eef1ef; color: var(--muted); }
.badge.support { background: #ede9fe; color: #6d28d9; }
.empty { padding: 54px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 15px; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; color: var(--muted); font-size: 12.5px; }
.pager .pages { display: flex; gap: 6px; }

/* ---------- 汇总 ---------- */
.summary-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.bars { display: grid; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 92px; align-items: center; gap: 12px; font-size: 12.5px; }
.bar-track { background: #edf1ee; height: 10px; border-radius: 20px; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, #14b8a6, #0f766e); height: 100%; border-radius: 20px; }
.bar-row .amount { text-align: right; font-weight: 600; }

/* ---------- 汇总看板 ---------- */
.summary-chart-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; margin-top: 18px; }
.summary-rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.trend-body { padding: 10px 10px 6px; }
.trend-svg { width: 100%; height: 238px; display: block; }
.trend-grid { stroke: #edf1ee; stroke-width: 1; }
.trend-axis { fill: #8a9891; font-size: 10px; }
.trend-line { fill: none; stroke: #0f766e; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.trend-dot { fill: #fff; stroke: #0f766e; stroke-width: 2; }
.donut-layout { display: flex; align-items: center; gap: 16px; }
.donut-figure { width: 160px; flex: 0 0 160px; }
.donut-svg { width: 160px; height: 160px; }
.donut-total { font-size: 17px; font-weight: 700; fill: var(--ink); }
.donut-caption { font-size: 10px; fill: var(--muted); }
.legend { flex: 1; min-width: 0; display: grid; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-amount { font-weight: 600; }
.legend-pct { color: var(--muted); width: 44px; text-align: right; }
.rank-list { display: grid; gap: 11px; }
.rank-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.rank-no { width: 22px; height: 22px; border-radius: 7px; display: flex; align-items: center; justify-content: center; background: #f1f4f2; color: var(--muted); font-size: 11px; font-weight: 700; }
.rank-no.top { background: var(--accent-soft); color: var(--accent-dark); }
.rank-title { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; }
.rank-sub { color: var(--muted); font-size: 11px; white-space: nowrap; }
.rank-track { height: 7px; border-radius: 10px; background: #edf1ee; margin-top: 6px; overflow: hidden; }
.rank-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #2dd4bf, #0f766e); }
.rank-value { font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.kv { display: grid; grid-template-columns: 112px 1fr; gap: 9px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- 抽屉 ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(10,25,20,.42); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(1280px, 96vw);
  background: #fff; z-index: 60; display: flex; flex-direction: column;
  box-shadow: -18px 0 50px rgba(10,30,24,.18);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { flex: 1; overflow: auto; padding: 20px 22px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 14px 22px; display: flex; gap: 10px; justify-content: flex-end; background: #fbfcfb; }
.detail-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 22px; }
.image-pane { position: sticky; top: 0; }
.image-pane img { width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #f2f5f3; }
.image-pane .img-meta { margin-top: 10px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.form-grid .span2 { grid-column: span 2; }
.items-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 8px; }
.items-head h4 { margin: 0; font-size: 14px; }
.item-table { table-layout: fixed; min-width: 860px; }
.item-table input { width: 100%; border: 1px solid transparent; background: transparent; padding: 6px; border-radius: 6px; }
.item-table input:focus { border-color: var(--line); background: #fff; }
.item-table td { padding: 4px 6px; }
.item-table th { padding: 7px 6px; }
.item-table th:nth-child(1), .item-table td:nth-child(1) { width: 220px; }
.item-table th:nth-child(2), .item-table td:nth-child(2) { width: 170px; }
.item-table th:nth-child(3), .item-table td:nth-child(3) { width: 62px; }
.item-table th:nth-child(4), .item-table td:nth-child(4) { width: 76px; }
.item-table th:nth-child(5), .item-table td:nth-child(5) { width: 92px; }
.item-table th:nth-child(6), .item-table td:nth-child(6) { width: 96px; }
.item-table th:nth-child(7), .item-table td:nth-child(7) { width: 54px; }
.item-table th:nth-child(8), .item-table td:nth-child(8) { width: 44px; }
.review-note { margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: var(--warn-soft); color: #8a4b07; font-size: 12.5px; line-height: 1.7; }
.review-note.ok { background: var(--ok-soft); color: var(--ok); }
.drawer-narrow { max-width: 640px; }

/* ---------- 模态 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(10,25,20,.45); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; border-radius: 16px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 管理端 ---------- */
.tenant-name { font-weight: 600; }
.mini { color: var(--muted); font-size: 11.5px; margin-top: 3px; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cfd8d3; border-radius: 22px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin-top: 8px; }
.feature-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-stack { display: grid; gap: 13px; }
.form-stack label { display: grid; gap: 6px; font-size: 12.5px; color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translate(-50%, -16px);
  background: #16241f; color: #fff; padding: 11px 18px; border-radius: 10px;
  z-index: 200; opacity: 0; pointer-events: none; transition: .22s; font-size: 13px;
  box-shadow: var(--shadow); max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #7f1d1d; }

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-chart-grid, .summary-rank-grid { grid-template-columns: 1fr; }
  .donut-layout { justify-content: center; }
  .detail-grid { grid-template-columns: 1fr; }
  .image-pane { position: static; }
  .image-pane img { max-height: 52vh; object-fit: contain; }
}
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; overflow-x: auto; }
  .side-brand { padding: 0 6px 0 0; }
  .side-brand-text { display: none; }
  .nav { flex-direction: row; flex: 1; }
  .nav-group { display: none; }
  .nav-item { width: auto; white-space: nowrap; padding: 8px 10px; }
  .side-foot { display: none; }
  .topbar, .content { padding-left: 18px; padding-right: 18px; }
  .support-banner { margin-left: 18px; margin-right: 18px; }
  .settings-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
}
