/* 金匠寿司预占取号系统 — 共享样式 */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9aa3b2;
  --brand: #c8963e;
  --brand-soft: rgba(200, 150, 62, .14);
  --brand-ink: #1a1206;
  --ok: #3fb98a;
  --warn: #e0a844;
  --danger: #e0574c;
  --info: #5b93d8;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .32);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --ok-soft: rgba(63,185,138,.12);
  --warn-soft: rgba(224,168,68,.13);
  --danger-soft: rgba(224,87,76,.12);
  --info-soft: rgba(91,147,216,.12);
}

/* 每台设备独立保存的主题预设，不改变状态色语义。 */
body[data-theme="jade"] {
  --brand:#45b88a; --brand-soft:rgba(69,184,138,.14); --bg:#0c1211;
  --surface:#141d1b; --surface-2:#1b2926; --border:#293a36;
}
body[data-theme="ocean"] {
  --brand:#62a7e8; --brand-soft:rgba(98,167,232,.14); --bg:#0b1018;
  --surface:#131a24; --surface-2:#1a2533; --border:#293748;
}
body[data-theme="violet"] {
  --brand:#a98bed; --brand-soft:rgba(169,139,237,.14); --bg:#100e17;
  --surface:#191622; --surface-2:#231e30; --border:#352e45;
}

/* 客户端四套主题统一采用浅色底。作用域限定在 client-page，后台仍保留
   原有深色运营界面；每套背景只带很淡的主题色，状态色语义保持一致。 */
body.client-page {
  color-scheme: light;
  --bg:#fbf7ef;
  --surface:#fffdf9;
  --surface-2:#f6efe3;
  --border:#ded3c2;
  --text:#29231b;
  --text-dim:#71695f;
  --brand:#96651e;
  --brand-soft:rgba(150,101,30,.11);
  --brand-ink:#fff;
  --ok:#27775e;
  --warn:#9a6513;
  --danger:#bd4037;
  --info:#326c9f;
  --ok-soft:rgba(39,119,94,.10);
  --warn-soft:rgba(154,101,19,.11);
  --danger-soft:rgba(189,64,55,.10);
  --info-soft:rgba(50,108,159,.10);
  --shadow:0 8px 28px rgba(83,62,31,.10);
}
body.client-page[data-theme="jade"] {
  --bg:#f1faf6;
  --surface:#fbfffd;
  --surface-2:#e7f4ee;
  --border:#c9ded4;
  --text:#1f2b26;
  --text-dim:#62736b;
  --brand:#28795f;
  --brand-soft:rgba(40,121,95,.11);
  --shadow:0 8px 28px rgba(35,92,73,.10);
}
body.client-page[data-theme="ocean"] {
  --bg:#f1f7fc;
  --surface:#fbfdff;
  --surface-2:#e7f1f9;
  --border:#c8d9e7;
  --text:#202b35;
  --text-dim:#607080;
  --brand:#326da3;
  --brand-soft:rgba(50,109,163,.11);
  --shadow:0 8px 28px rgba(43,91,132,.10);
}
body.client-page[data-theme="violet"] {
  --bg:#f7f3fc;
  --surface:#fefcff;
  --surface-2:#eee7f7;
  --border:#d8cce7;
  --text:#292431;
  --text-dim:#70677c;
  --brand:#7252ad;
  --brand-soft:rgba(114,82,173,.11);
  --shadow:0 8px 28px rgba(83,57,126,.10);
}
body.client-page .modal-host { background:rgba(39,32,52,.34); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }

/* ── 布局 ── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px; height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .spacer { flex: 1; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid.cols-5 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── 卡片 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2, .card h3 {
  margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text);
}
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title h2 { margin: 0; }
.card-title .spacer { flex: 1; }

/* ── 统计磁贴 ── */
.tile { background: var(--surface-2); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--text-dim); }
.tile .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 4px; }
.tile .value.ok { color: var(--ok); }
.tile .value.warn { color: var(--warn); }
.tile .value.danger { color: var(--danger); }

/* ── 按钮 ── */
button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  padding: 7px 14px; border-radius: 8px;
  transition: background .15s, border-color .15s, opacity .15s;
}
button:hover, .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: translateY(1px); }
button.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: rgba(224, 87, 76, .12); }
button.ghost { background: transparent; }
button.ghost.active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 600; }
button.sm { padding: 4px 10px; font-size: 12px; }
.yyb-sync-progress {
  color: var(--text-dim); font-size: 12px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 8px;
}
.yyb-sync-progress[hidden] { display: none; }
.yyb-sync-progress.running { color: var(--brand); }
.yyb-sync-progress.failed { color: var(--danger); }
.yyb-sync-track {
  display:inline-block; width:92px; height:6px; overflow:hidden;
  border-radius:999px; background:var(--surface-2); border:1px solid var(--border);
}
.yyb-sync-track > span {
  display:block; width:0; height:100%; border-radius:inherit;
  background:var(--brand); transition:width .35s ease;
}
.yyb-sync-progress.failed .yyb-sync-track > span { background:var(--danger); }
.account-pool-stat {
  display:inline-flex; align-items:center; min-height:28px; padding:3px 10px;
  border:1px solid var(--border); border-radius:999px; background:var(--surface-2);
  font-size:12px; font-weight:700; font-variant-numeric:tabular-nums; white-space:nowrap;
}
.account-pool-stat[type="button"] { width:auto; margin:0; cursor:pointer; line-height:1.2; }
.account-pool-stat[type="button"]:hover,
.account-pool-stat[type="button"]:focus-visible { filter:brightness(1.16); outline:none; }
.account-pool-stat[type="button"][aria-pressed="true"] {
  background:var(--danger-soft); box-shadow:0 0 0 2px rgba(224,87,76,.14);
}
.account-pool-stat.total { color:var(--text); }
.account-pool-stat.available { color:var(--ok); border-color:color-mix(in srgb, var(--ok) 42%, var(--border)); }
.account-pool-stat.abnormal { color:var(--danger); border-color:color-mix(in srgb, var(--danger) 42%, var(--border)); }

/* ── 表单 ── */
label { font-size: 12px; color: var(--text-dim); display: block; margin-bottom: 5px; }
input, select, textarea {
  font: inherit; width: 100%;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
.field { margin-bottom: 12px; }
.field-inline { display: flex; gap: 12px; }
.field-inline > * { flex: 1; }
.time-wheel { display:grid; grid-template-columns:minmax(72px, 1fr) auto minmax(72px, 1fr) auto; align-items:center; gap:8px; }
.time-wheel-picker { position:relative; min-width:0; }
.time-wheel-trigger { width:100%; min-height:38px; display:flex; align-items:center; justify-content:center; gap:10px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text); font-variant-numeric:tabular-nums; font-weight:700; cursor:pointer; }
.time-wheel-trigger[aria-expanded="true"] { border-color:var(--brand); box-shadow:0 0 0 2px color-mix(in srgb, var(--brand) 16%, transparent); }
.time-wheel-caret { color:var(--muted); font-size:14px; }
.time-wheel-menu { position:absolute; z-index:90; top:calc(100% + 6px); left:0; right:0; max-height:220px; overflow-y:auto; overscroll-behavior:contain; padding:4px; border:1px solid var(--brand); border-radius:9px; background:var(--surface); box-shadow:var(--shadow); scrollbar-gutter:stable; }
.time-wheel-menu[hidden] { display:none; }
.time-wheel-option { display:block; width:100%; padding:7px 4px; border:0; border-radius:6px; background:transparent; color:var(--text); text-align:center; font-variant-numeric:tabular-nums; cursor:pointer; }
.time-wheel-option:hover, .time-wheel-option.selected { background:var(--brand-soft); color:var(--brand); font-weight:800; }
.time-wheel-unit { color:var(--muted); font-size:13px; white-space:nowrap; }
.plan-more-config { margin:4px 0 12px; border:1px solid var(--border); border-radius:12px; background:var(--surface-2); overflow:hidden; }
.plan-more-config summary { display:flex; align-items:center; gap:10px; padding:12px 14px; cursor:pointer; user-select:none; list-style:none; color:var(--text); font-weight:700; }
.plan-more-config summary::-webkit-details-marker { display:none; }
.plan-more-config summary small { margin-left:auto; color:var(--muted); font-size:12px; font-weight:500; }
.plan-more-config summary::after { content:'›'; color:var(--muted); font-size:20px; line-height:1; transform:rotate(90deg); transition:transform .18s ease; }
.plan-more-config[open] summary::after { transform:rotate(-90deg); }
.plan-more-config[open] summary { border-bottom:1px solid var(--border); }
.plan-more-config-body { padding:14px 14px 2px; }

/* ── 表格 ── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); }
tr.row-error td { background: rgba(224, 87, 76, .09); }
tr.row-warn td { background: rgba(224, 168, 68, .09); }
.table-scroll { overflow: auto; max-height: 460px; }

/* ── 徽标 ── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; line-height: 1.7; white-space: nowrap;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border);
}
.theme-select { width:auto; min-width:92px; padding:5px 26px 5px 9px; font-size:12px; border-radius:20px; background-color:var(--surface-2); }
.badge.ok { color: var(--ok); border-color: rgba(63, 185, 138, .4); background: rgba(63, 185, 138, .1); }
.badge.warn { color: var(--warn); border-color: rgba(224, 168, 68, .4); background: rgba(224, 168, 68, .1); }
.badge.danger { color: var(--danger); border-color: rgba(224, 87, 76, .4); background: rgba(224, 87, 76, .1); }
.badge.info { color: var(--info); border-color: rgba(91, 147, 216, .4); background: rgba(91, 147, 216, .1); }
.badge.brand { color: var(--brand); border-color: rgba(200, 150, 62, .45); background: var(--brand-soft); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 10px 14px; color: var(--text-dim); white-space: nowrap;
  font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; gap: 7px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 700; }

/* 图标自带颜色，不跟着选中态变灰，未选中时压暗但不脱色 */
.tabs button svg { width: 17px; height: 17px; flex: none; pointer-events: none; opacity: .62; }
.tabs button.active svg { opacity: 1; }
.tabs button:hover svg { opacity: 1; }

/* ── 提示 ── */
.empty { text-align: center; padding: 36px 12px; color: var(--text-dim); font-size: 13px; }
.hint { font-size: 12px; color: var(--text-dim); }
.toast-host { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow);
  min-width: 220px; animation: slide-in .2s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.danger { border-left-color: var(--danger); }
@keyframes slide-in { from { opacity: 0; transform: translateX(12px); } }

/* 管理员手动取号失败时保留一份可复制的脱敏上游响应，便于核对
   93000001、HTTP500 等真实服务端原因；正文只由 JS textContent 写入。 */
.manual-take-failure {
  margin-top: 12px; padding: 10px 11px; border: 1px solid var(--danger);
  border-radius: 9px; color: var(--danger); background: var(--danger-soft);
  font-size: 12px; line-height: 1.45; overflow: hidden;
}
.manual-take-failure strong { display: block; margin-bottom: 3px; }
.manual-take-failure pre {
  margin: 7px 0 0; padding: 7px 8px; max-height: 180px; overflow: auto;
  color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 11px/1.45 var(--mono);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
.dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 138, .18); }
.dot.dead { background: var(--danger); }

/* ── 模态 ── */
.modal-host {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .62);
  display: grid; place-items: center; z-index: 60; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; width: min(520px, 100%); box-shadow: var(--shadow);
  max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 640px) {
  .wrap { padding: 14px; }
  .field-inline { flex-direction: column; }

  /* 顶栏 6 个元素在 360px 上会挤爆固定的 56px 高度 */
  .topbar { padding: 0 12px; gap: 10px; height: 52px; }
  .topbar h1 { font-size: 15px; }

  /* minmax(180px) 在窄屏会塌成单列，四格统计拉成一屏高；2×2 更合适 */
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  /* 手机端可认领号码 5 列，让一屏能看到尽可能多的号 */
  .grid.cols-5 { grid-template-columns: repeat(1, 1fr); gap: 10px; }
  .tile { padding: 12px; }
  .tile .value { font-size: 22px; }

  /* 分页贴在顶栏下方，等宽铺满，触控目标不低于 44px */
  .tabs {
    position: sticky; top: 52px; z-index: 15;
    background: var(--bg); gap: 0; margin-bottom: 14px;
  }
  .tabs button {
    flex: 1; padding: 12px 4px; min-height: 44px; font-size: 13px;
    gap: 5px; justify-content: center;
  }
  /* 360px 上三页加图标会顶到边，图标收一号 */
  .tabs button svg { width: 16px; height: 16px; }

  .table-scroll { max-height: none; }
  .modal-actions button { flex: 1; }
}
