/* 号仓 · 建行收号站 —— 共用样式
   原创设计：暖灰底 + 青绿主色，浅/深双主题，系统字体，手机宽度可用。 */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --border: #dde2e7;
  --border-strong: #c5ccd4;
  --text: #171b20;
  --text-2: #4d5760;
  --text-3: #7a848e;
  --accent: #0e7c6b;
  --accent-hover: #0b6558;
  --accent-soft: #d9f0eb;
  --accent-text: #0a5d50;
  --ok: #1f8a4c;
  --ok-soft: #dcf3e4;
  --warn: #a86300;
  --warn-soft: #fdf0d5;
  --bad: #c2352e;
  --bad-soft: #fbe1df;
  --info: #2b5fb8;
  --info-soft: #dfe8fa;
  --muted-soft: #e7eaee;
  --focus: rgba(14, 124, 107, .28);
  --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 6px 20px rgba(16, 24, 32, .05);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1316;
    --surface: #161b20;
    --surface-2: #1d242a;
    --border: #28313a;
    --border-strong: #3a4650;
    --text: #e4e8ec;
    --text-2: #a7b1ba;
    --text-3: #727e89;
    --accent: #3cbfa8;
    --accent-hover: #57cdb8;
    --accent-soft: #173630;
    --accent-text: #7fdccb;
    --ok: #43b77a;
    --ok-soft: #153224;
    --warn: #e0a63a;
    --warn-soft: #3a2c11;
    --bad: #e26860;
    --bad-soft: #3c1f1d;
    --info: #6b9be8;
    --info-soft: #1b2a45;
    --muted-soft: #242c33;
    --focus: rgba(60, 191, 168, .35);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1316;
  --surface: #161b20;
  --surface-2: #1d242a;
  --border: #28313a;
  --border-strong: #3a4650;
  --text: #e4e8ec;
  --text-2: #a7b1ba;
  --text-3: #727e89;
  --accent: #3cbfa8;
  --accent-hover: #57cdb8;
  --accent-soft: #173630;
  --accent-text: #7fdccb;
  --ok: #43b77a;
  --ok-soft: #153224;
  --warn: #e0a63a;
  --warn-soft: #3a2c11;
  --bad: #e26860;
  --bad-soft: #3c1f1d;
  --info: #6b9be8;
  --info-soft: #1b2a45;
  --muted-soft: #242c33;
  --focus: rgba(60, 191, 168, .35);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  min-height: 100vh;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.muted { color: var(--text-3); }
.hint { color: var(--text-2); font-size: 12.5px; margin: 6px 0 0; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto; padding: 0 16px;
  height: 56px; display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: .02em; }
.brand-sub { font-size: 11px; color: var(--text-3); letter-spacing: .12em; text-transform: uppercase; line-height: 1; margin-top: 2px; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* 探活指示 */
.health {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.health[data-state="ok"] .health-dot { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.health[data-state="bad"] .health-dot { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.health[data-state="wait"] .health-dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.health-ms { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* ---------- 布局 ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 22px 16px 56px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.stack { display: grid; gap: 16px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .cols-2 { grid-template-columns: 1fr; } }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-head .title { display: flex; align-items: center; gap: 8px; }
.card-head .title small { color: var(--text-3); font-weight: 400; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* 统计看板 */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px;
  background: var(--stat-color, var(--border-strong));
}
.stat[data-tone="accent"] { --stat-color: var(--accent); }
.stat[data-tone="ok"] { --stat-color: var(--ok); }
.stat[data-tone="muted"] { --stat-color: var(--text-3); }
.stat[data-tone="info"] { --stat-color: var(--info); }
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -.02em; }
.stat-note { font-size: 11.5px; color: var(--text-3); margin-top: 2px; min-height: 1.2em; }

/* ---------- 表单 ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 12.5px; color: var(--text-2); }
.input, .textarea, .select {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); outline: none; }
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 220px; white-space: pre; overflow: auto; }
.input.mono { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border-strong)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn svg { width: 16px; height: 16px; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--focus); }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--muted-soft); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-plain::before { display: none; }

/* 计数胶囊 */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12px; color: var(--text-2); }
.pill b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- 列表/表格 ---------- */
.lines { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; max-height: 360px; overflow-y: auto; font-family: var(--mono); font-size: 12.5px; }
.line { display: grid; grid-template-columns: 44px 120px 1fr; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: 0; }
.line-no { color: var(--text-3); text-align: right; }
.line-phone { font-variant-numeric: tabular-nums; }
.line-msg { color: var(--text-2); font-family: var(--sans); display: flex; align-items: center; gap: 8px; min-width: 0; }
.line-msg span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line[data-level="ok"] { background: color-mix(in srgb, var(--ok-soft) 45%, transparent); }
.line[data-level="warn"] { background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
.line[data-level="bad"] { background: color-mix(in srgb, var(--bad-soft) 45%, transparent); }
.line-mark { width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; color: #fff; flex: none; font-family: var(--sans); }
.line[data-level="ok"] .line-mark { background: var(--ok); }
.line[data-level="warn"] .line-mark { background: var(--warn); }
.line[data-level="bad"] .line-mark { background: var(--bad); }
.line[data-level="info"] .line-mark { background: var(--info); }
@media (max-width: 560px) {
  .line { grid-template-columns: 30px 1fr; }
  .line-msg { grid-column: 1 / -1; padding-left: 38px; }
}

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-weight: 500; color: var(--text-2); font-size: 12px; background: var(--surface-2); position: sticky; top: 0; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tbl .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl .actions { white-space: nowrap; text-align: right; }
.tbl td.empty { text-align: center; color: var(--text-3); padding: 28px 12px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 28px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 500; }
.chip b { font-variant-numeric: tabular-nums; }

/* 空态 */
.empty { text-align: center; color: var(--text-3); padding: 28px 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

/* 锁定遮罩(需登录的区块) */
.locked { position: relative; }
.locked-pane {
  display: grid; place-items: center; text-align: center; padding: 28px 16px;
  background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--surface-2) 70%, transparent) 10px 20px);
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.locked-pane .lock-icon { width: 36px; height: 36px; color: var(--text-3); margin-bottom: 8px; }
.locked-pane form { display: flex; gap: 8px; margin-top: 12px; width: 100%; max-width: 360px; }

/* ---------- 提示条(toast) ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 12px; font-size: 13px;
  animation: toast-in .18s ease-out;
}
.toast[data-type="ok"] { border-left-color: var(--ok); }
.toast[data-type="bad"] { border-left-color: var(--bad); }
.toast[data-type="warn"] { border-left-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 管理端布局 ---------- */
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 20px; align-items: start; }
.side-nav { position: sticky; top: 72px; display: grid; gap: 2px; }
.side-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2);
}
.side-nav button svg { width: 17px; height: 17px; opacity: .8; flex: none; }
.side-nav button:hover { background: var(--surface-2); color: var(--text); }
.side-nav button[aria-current="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 500; }
.side-nav .nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }
@media (max-width: 860px) {
  .admin-layout { grid-template-columns: 1fr; gap: 14px; }
  .side-nav { position: static; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav button { width: auto; flex: none; height: 34px; border: 1px solid var(--border); background: var(--surface); }
  .side-nav .nav-sep { display: none; }
}
.panel[hidden] { display: none; }

/* 登录卡 */
.login-shell { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 28px 26px; }
.login-card .brand-mark { width: 44px; height: 44px; }
.login-card h1 { font-size: 18px; margin-top: 14px; }
.login-card p { color: var(--text-2); margin: 4px 0 18px; }
.login-card form { display: grid; gap: 10px; }
.login-err { color: var(--bad); font-size: 12.5px; min-height: 1.2em; }

/* 券行编辑器 */
.coupon-rows { display: grid; gap: 8px; }
.coupon-row { display: grid; grid-template-columns: 1.6fr .8fr 1fr .7fr 1.4fr 34px; gap: 8px; align-items: center; }
.coupon-row .input { height: 34px; }
.coupon-head { display: grid; grid-template-columns: 1.6fr .8fr 1fr .7fr 1.4fr 34px; gap: 8px; font-size: 12px; color: var(--text-3); padding: 0 2px; }
@media (max-width: 720px) {
  .coupon-head { display: none; }
  .coupon-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
  .coupon-row .input[data-col="id"] { grid-column: 1 / -1; }
  .coupon-row .input[data-col="fire"] { grid-column: 1 / -1; }
}

/* 预览块 */
pre.preview { margin: 0; padding: 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* 页脚 */
.foot { margin-top: 28px; color: var(--text-3); font-size: 12px; text-align: center; }
