:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #1a2332;
  --muted: #6b7a90;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #2f6fed;
  --accent-hover: #235dda;
  --accent-soft: #e8f0fe;
  --accent-glow: rgba(47, 111, 237, 0.16);
  --accent-mid: #5b8ff9;
  --ok: #0d9f6e;
  --ok-soft: #e6f7f0;
  --warn: #c47d14;
  --warn-soft: #fff6e8;
  --danger: #d14343;
  --danger-soft: #fdeeee;
  --sidebar: #0b1220;
  --sidebar-mid: #121a2b;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-text: #94a3b8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(26, 35, 50, 0.04), 0 8px 24px rgba(26, 35, 50, 0.06);
  --shadow-lg: 0 2px 4px rgba(26, 35, 50, 0.04), 0 16px 32px rgba(47, 111, 237, 0.08);
  --side-w: 240px;
  --font: "Noto Sans SC", "HarmonyOS Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-display: var(--font);
  --font-mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, 'Courier New', monospace;
  --el-font-family: var(--font);
  --control-h: 36px;
  --control-h-sm: 30px;
  --content-max: 1180px;
  --content-max-wide: 1560px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(47, 111, 237, 0.08), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(13, 159, 110, 0.05), transparent 50%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

.layout {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.side {
  background: var(--sidebar);
  padding: 16px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  padding: 8px 10px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-text {
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.brand-sub {
  margin: 3px 0 0;
  font-size: 11px;
  color: #64748b;
  letter-spacing: 0.02em;
}

.nav-group {
  display: grid;
  gap: 3px;
  padding: 4px 2px;
}

.nav-btn {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  cursor: pointer;
  width: 100%;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.nav-btn .nav-ico {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
  transition: background 0.18s, color 0.18s;
}

.nav-btn .nav-ico svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-btn:hover .nav-ico {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

.nav-btn.active {
  background: rgba(47, 111, 237, 0.18);
  color: #fff;
  font-weight: 600;
}

.nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-mid);
}

.nav-btn.active .nav-ico {
  background: rgba(47, 111, 237, 0.28);
  color: #93c5fd;
}

.status-row {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 8px;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-sm);
  padding: 8px 10px 8px 12px;
}

.status-card-label {
  font-size: 11.5px;
  font-weight: 500;
  color: #8595ab;
  flex-shrink: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

.pill.ok {
  background: rgba(5, 150, 105, 0.14);
  color: #6ee7b7;
  border-color: rgba(110, 231, 183, 0.22);
}

.pill.ok::before {
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.18);
  animation: pulseDot 2s ease infinite;
}

.pill.bad {
  background: rgba(220, 38, 38, 0.12);
  color: #fca5a5;
  border-color: rgba(252, 165, 165, 0.18);
}

@keyframes pulseDot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.45;
  }
}

/* ---------- Main ---------- */
.main {
  padding: 18px 22px 28px;
  width: 100%;
  max-width: calc(var(--content-max) + 44px);
  margin-inline: auto;
}

/* 订单列表是宽表格，单独放宽上限 */
.main:has(.page.active[data-page="orders"]) {
  max-width: calc(var(--content-max-wide) + 44px);
}

.page {
  display: none;
}

.page.active {
  display: block;
  animation: fadeIn 0.28s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-header {
  position: relative;
  margin-bottom: 16px;
  padding: 16px 18px 16px 20px;
  border-radius: var(--radius);
  background:
    linear-gradient(105deg, rgba(47, 111, 237, 0.07) 0%, rgba(255, 255, 255, 0.8) 42%, rgba(255, 255, 255, 0.55) 100%);
  border: 1px solid rgba(47, 111, 237, 0.12);
  box-shadow: 0 1px 2px rgba(26, 35, 50, 0.03);
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent-mid), var(--accent));
}

.page-header::after {
  content: '';
  position: absolute;
  right: -24px;
  top: -28px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 111, 237, 0.1), transparent 68%);
  pointer-events: none;
}

.page-header h2 {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.25;
}

.page-header p {
  position: relative;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 42em;
}

/* ---------- Cards ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}


.card-head {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-featured {
  border-color: rgba(47, 111, 237, 0.16);
  background:
    linear-gradient(135deg, rgba(47, 111, 237, 0.04) 0%, transparent 40%),
    linear-gradient(165deg, #ffffff 0%, #f7faff 100%);
  box-shadow: var(--shadow-lg);
}

.card-featured .card-head h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-featured .card-head h3::before {
  content: '';
  width: 3px;
  height: 16px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--accent), #0d9f6e);
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
  margin: 5px 0 0;
}

.summary-bar {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--accent-soft), #eefbf5);
  border: 1px solid rgba(47, 111, 237, 0.12);
  color: #1e40af;
  font-size: 13px;
  line-height: 1.55;
}

/* ---------- KPI 卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.stat-card {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff, #fbfcfe);
}

.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card-value {
  margin-top: 5px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.stat-card.is-ok {
  border-color: rgba(13, 159, 110, 0.24);
  background: linear-gradient(180deg, #ffffff, var(--ok-soft));
}

.stat-card.is-ok .stat-card-value {
  color: var(--ok);
}

.stat-card.is-bad {
  border-color: rgba(209, 67, 67, 0.22);
  background: linear-gradient(180deg, #ffffff, var(--danger-soft));
}

.stat-card.is-bad .stat-card-value {
  color: var(--danger);
}

.stat-card.is-accent {
  border-color: rgba(47, 111, 237, 0.22);
  background: linear-gradient(180deg, #ffffff, var(--accent-soft));
}

.stat-card.is-accent .stat-card-value {
  color: var(--accent);
}

.stat-card-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
}

.switch-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.switch-stack .auto-switch-row,
.switch-stack .switch-row {
  margin-bottom: 0;
}

.switch-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.switch-row .auto-switch-row {
  margin-bottom: 0;
  min-width: 0;
}

@media (max-width: 900px) {
  .switch-row {
    grid-template-columns: 1fr;
  }
}

.auto-switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, #f8fafc, #eef4ff);
  border: 1px solid var(--line);
}

.auto-switch-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.auto-switch-state {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-left: auto;
}

.auto-switch-state.on {
  color: var(--ok);
}

.auto-switch-state.paused {
  color: var(--warn);
}

.auto-switch-state.off {
  color: var(--muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: background 0.2s;
}

.switch-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.switch input:checked+.switch-slider {
  background: var(--accent);
}

.switch input:checked+.switch-slider::before {
  transform: translateX(20px);
}

.switch input:disabled+.switch-slider {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Forms ---------- */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}

.grid2 .span-2 {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 5px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.field-hint {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
}

/* 开关型字段：标签 / 开关 / 说明同一行，标签定宽以便多行开关对齐 */
.toggle-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.toggle-field > span:first-child {
  min-width: 104px;
  flex-shrink: 0;
}

.region-preview {
  margin-top: -2px;
  color: #475569;
  font-size: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px dashed var(--line);
}

.region-preview code {
  background: #eef2f7;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
}

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  min-height: var(--control-h);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink);
  width: 100%;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

select {
  appearance: none;
  padding-right: 32px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%2394a3b8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 11px;
}

/* 数字输入不需要占满整列 */
input[type="number"] {
  max-width: 180px;
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--line-strong);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #9db7f5;
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: #fff;
}

textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.55;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
}

.batch-actions {
  margin-top: 14px;
}

.batch-conc-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  grid-auto-flow: column;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.batch-conc-label input {
  width: 72px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.inline-field input {
  width: 80px;
}

.stats-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.stats-toolbar .stats-days-wrap {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: auto;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

.stats-toolbar #stats-days {
  flex: 0 0 76px;
  width: 76px;
}

.orders-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.orders-toolbar > .orders-q {
  flex: 0 1 280px;
  width: 280px;
  max-width: 100%;
  min-width: 160px;
}

.orders-toolbar > .orders-filter {
  flex: 0 0 auto;
  width: 132px;
}

.orders-toolbar > .btn {
  flex: 0 0 auto;
}

.orders-toolbar-actions {
  display: inline-flex;
  flex: 0 0 auto;
  margin-left: auto;
  align-items: center;
  gap: 8px;
}

@media (max-width: 720px) {
  .orders-toolbar {
    flex-wrap: wrap;
  }
  .orders-toolbar > .orders-q {
    flex: 1 1 100%;
    width: 100%;
  }
  .orders-toolbar > .orders-filter {
    flex: 1 1 calc(50% - 5px);
    width: auto;
  }
  .orders-toolbar-actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }
}

label+.row,
.grid2+.row {
  margin-top: 14px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  min-height: var(--control-h);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(90deg, #2f6fed, #5b8ff9);
  color: #fff;
  box-shadow: 0 1px 2px rgba(47, 111, 237, 0.2), 0 4px 10px rgba(47, 111, 237, 0.14);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(90deg, #235dda, #4a82f5);
  box-shadow: 0 2px 8px rgba(47, 111, 237, 0.26);
}

.btn-secondary {
  background: #fff;
  color: #374151;
  border-color: var(--line);
  box-shadow: 0 1px 1px rgba(17, 24, 39, 0.03);
}

.btn-secondary:hover:not(:disabled) {
  background: #f9fafb;
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  border-color: var(--line);
  backdrop-filter: blur(8px);
}

.btn-ghost:hover:not(:disabled) {
  background: #fff;
  color: var(--ink);
}

.btn-sm {
  padding: 0 10px;
  min-height: var(--control-h-sm);
  font-size: 12px;
  border-radius: 6px;
  font-weight: 500;
}

/* ---------- Log / Activity ---------- */
.log-wrap {
  margin-top: 14px;
}

.log-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.log {
  background: #0f172a;
  color: #cbd5e1;
  border: 1px solid #1e293b;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: 12.5px/1.65 var(--font-mono);
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  margin: 0;
}

.log:empty::before {
  content: '暂无日志';
  color: #64748b;
}

.log-success {
  color: #6ee7b7;
}

.log-error {
  color: #fca5a5;
}

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
}

.table-wrap.compact {
  max-height: 220px;
}

/* 空表格只剩表头时显示占位，避免看起来像加载失败 */
.table-wrap:has(tbody:empty)::after {
  content: '暂无数据';
  display: block;
  padding: 26px 14px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

td.cell-empty {
  padding: 24px 14px;
  text-align: center;
  color: #94a3b8;
}

/* 订单列表：内部横竖滚动，避免撑破页面 */
.orders-table-wrap {
  max-height: min(62vh, 640px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.orders-table-wrap .col-check {
  width: 36px;
  min-width: 36px;
  text-align: center;
  padding-left: 10px;
  padding-right: 8px;
}

.orders-table-wrap .col-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  vertical-align: middle;
}

.orders-table-wrap table {
  width: max-content;
  min-width: 100%;
}

.orders-table-wrap th,
.orders-table-wrap td {
  white-space: nowrap;
}

.orders-table-wrap .cell-clip {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.orders-table-wrap .col-error {
  max-width: 280px;
  white-space: normal;
}

.orders-table-wrap .err-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #b91c1c;
  font-size: 12px;
  line-height: 1.35;
  max-width: 280px;
  cursor: default;
}

.ops-cell {
  white-space: nowrap;
}

.ops-dd {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.ops-dd-menu {
  display: none;
  z-index: 80;
  padding: 4px;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.ops-dd-menu.is-open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ops-dd-item {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
}

.ops-dd-item:hover:not(:disabled) {
  background: #f3f4f6;
  color: #111827;
}

.ops-dd-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.12s ease;
}

tbody tr:hover td {
  background: #fafbfc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #f3f4f6;
  color: #4b5563;
}

.tag.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.tag.fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.muted {
  color: #9ca3af;
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  color: #4b5563;
}

/* ---------- Multi-select ---------- */
.ms {
  position: relative;
  width: 100%;
  max-width: 520px;
  font-weight: 400;
  min-height: var(--control-h);
}

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--control-h);
  padding: 6px 10px 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ms-trigger:hover {
  border-color: var(--line-strong);
}

.ms.open .ms-trigger {
  border-color: #9db7f5;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ms-trigger-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.ms-trigger-text.is-placeholder {
  color: #94a3b8;
}

.ms-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #94a3b8;
  flex-shrink: 0;
}

.ms-panel {
  display: none;
  position: absolute;
  z-index: 40;
  left: 0;
  top: calc(100% + 6px);
  width: min(100%, 420px);
  max-height: 320px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  padding: 0;
}

.ms.open .ms-panel {
  display: flex;
  flex-direction: column;
}

.ms-toolbar {
  flex-shrink: 0;
  padding: 8px 8px 6px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.ms-search {
  width: 100%;
  margin: 0;
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  background: #fff;
}

.ms-search:focus {
  outline: none;
  border-color: #9db7f5;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.ms-list {
  overflow: auto;
  padding: 4px;
  max-height: 248px;
}

.ms-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: #334155;
  line-height: 1.3;
}

.ms-option:hover {
  background: #f1f5f9;
}

.ms-option.is-checked {
  background: var(--accent-soft);
  color: #1e3a8a;
}

.ms-option.is-checked:hover {
  background: #dbe7fe;
}

.ms-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  border: 1.5px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  box-shadow: none;
}

.ms-option input[type="checkbox"]:checked {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M2.5 6.2 5 8.7 9.5 3.4'/%3E%3C/svg%3E") center / 10px 10px no-repeat;
  border-color: var(--accent);
}

.ms-option-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ms-option .ms-code {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.ms-option.is-checked .ms-code {
  color: #6477a8;
}

.ms-empty {
  padding: 16px 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.ms-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 6px;
  margin: 0;
  border: 0;
}

.ms-toolbar .ms-search {
  margin-top: 2px;
}

.ms-actions button {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
}

.ms-actions button:hover {
  background: #e8f0fe;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
}

.toast {
  pointer-events: none;
  max-width: min(480px, calc(100vw - 40px));
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast.ok {
  background: rgba(6, 95, 70, 0.94);
}

.toast.bad {
  background: rgba(127, 29, 29, 0.92);
}

.hidden {
  display: none !important;
}

/* ---------- Unicom login page ---------- */
.login-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.login-step {
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

.login-step strong {
  display: block;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 3px;
}

.login-step.active {
  background: var(--accent-soft);
  border-color: rgba(47, 111, 237, 0.22);
  color: #1e40af;
}

.login-step.active strong {
  color: #1e40af;
}

.uni-status-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--ok-soft), #eff6ff);
  border: 1px solid #b7e8d4;
  margin-bottom: 4px;
}

.uni-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.uni-status-pill.ok {
  background: var(--ok);
  color: #fff;
}

.uni-status-pill.ok::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.28);
}

.uni-status-meta {
  min-width: 0;
}

.uni-status-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
}

.uni-status-phone {
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.manual-num-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.manual-num-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.manual-num-head #manual-num-count,
.manual-num-head .field-hint {
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.manual-num-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
  min-height: 48px;
  max-height: 220px;
  overflow: auto;
  margin-bottom: 14px;
  padding: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.manual-num-list:empty {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  min-height: 64px;
  color: #94a3b8;
  font-size: 12.5px;
}

.manual-num-list:empty::before {
  content: '点击「选择号码 / 刷新号池」加载可用号码';
}

.manual-num-list::-webkit-scrollbar {
  width: 6px;
}

.manual-num-list::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
}

.num-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
  box-shadow: 0 1px 1px rgba(26, 35, 50, 0.03);
}

.num-chip:hover {
  border-color: var(--accent-mid);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.num-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 12px rgba(47, 111, 237, 0.22);
}

.manual-picked {
  display: block;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.manual-picked input {
  margin-top: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding: 11px 12px;
  box-shadow: inset 0 0 0 1px transparent;
}

.manual-picked input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.manual-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.manual-photo-grid input[type="file"] {
  margin-top: 6px;
  width: 100%;
}

@media (max-width: 900px) {
  .manual-photo-grid {
    grid-template-columns: 1fr;
  }

  .manual-num-list {
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side {
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .main {
    padding: 14px 14px 24px;
    max-width: none;
  }

  .grid2,
  .login-steps {
    grid-template-columns: 1fr;
  }

  .auto-switch-state {
    margin-left: 0;
  }

  .page-header h2 {
    font-size: 20px;
  }

  .uni-status-box {
    flex-direction: column;
    align-items: flex-start;
  }
}

.login-locked .layout {
  display: none;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(720px 360px at 12% 8%, rgba(47, 111, 237, 0.16), transparent 62%),
    radial-gradient(640px 320px at 92% 92%, rgba(13, 159, 110, 0.1), transparent 60%),
    #eef3f8;
}

.login-gate[hidden] {
  display: none;
}

.login-shell {
  width: min(960px, 100%);
  min-height: 540px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  border-radius: 24px;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e6edf5;
  box-shadow: 0 18px 50px rgba(26, 35, 50, 0.08);
}

.login-hero {
  position: relative;
  padding: 44px 40px;
  color: #1a2332;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), transparent 40%),
    linear-gradient(165deg, #e7f0ff 0%, #f4f8fd 55%, #eef6f3 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.login-hero::after {
  content: "";
  position: absolute;
  width: 220px;
  height: 220px;
  right: -40px;
  top: -50px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 111, 237, 0.18), transparent 68%);
}

.login-kicker,
.login-hero h2,
.login-hero > p,
.login-points {
  position: relative;
  z-index: 1;
}

.login-kicker {
  align-self: flex-start;
  margin-bottom: auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d5e3f7;
  background: rgba(255, 255, 255, 0.72);
  color: #3d5a80;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.login-hero h2 {
  margin: 0 0 12px;
  font-size: 40px;
  line-height: 1.15;
  letter-spacing: -0.04em;
  font-weight: 700;
  color: #152033;
}

.login-hero > p {
  margin: 0 0 28px;
  max-width: 360px;
  color: #5c6b82;
  font-size: 15px;
  line-height: 1.7;
}

.login-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.login-points li {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid #e3ebf5;
}

.login-points span {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e8f0fe;
  color: #2f6fed;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.login-points strong,
.login-points em {
  display: block;
  font-style: normal;
}

.login-points strong {
  font-size: 14px;
  color: #1a2332;
}

.login-points em {
  margin-top: 2px;
  font-size: 12px;
  color: #6b7a90;
}

.login-card {
  padding: 52px 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
}

.login-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #3b82f6, #1d4ed8);
  box-shadow: 0 10px 24px rgba(47, 111, 237, 0.28);
  margin-bottom: 22px;
}

.login-mark svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.login-card h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.04em;
  color: #0f172a;
}

.login-card > p {
  margin: 8px 0 28px;
  color: #64748b;
  font-size: 14px;
  line-height: 1.6;
}

.login-field {
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.login-field input {
  height: 48px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 0 14px;
  font-size: 15px;
  background: #fff;
}

.login-field input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.15);
}

.login-submit {
  width: 100%;
  margin-top: 18px;
  height: 48px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(180deg, #3b82f6, #1d4ed8);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.28);
}

.login-submit:hover:not(:disabled) {
  background: linear-gradient(180deg, #2563eb, #1e40af);
}

.login-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: #d14343;
  font-size: 13px;
  font-weight: 500;
}

@media (max-width: 860px) {
  .login-gate {
    padding: 16px;
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-hero {
    padding: 28px 24px 22px;
  }

  .login-kicker {
    margin-bottom: 22px;
  }

  .login-hero h2 {
    font-size: 32px;
  }

  .login-card {
    padding: 28px 22px 22px;
  }
}

.side-logout {
  margin-top: 8px;
  width: 100%;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.side-logout:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}