:root {
  --bg: #0a0c11;
  --bg-soft: #10141c;
  --panel: #141922;
  --panel-2: #1a2029;
  --line: #232b38;
  --line-soft: #1c232e;
  --text: #e8edf5;
  --muted: #8b98ad;
  --muted-2: #5f6b7e;
  --brand: #10a37f;
  --brand-soft: rgba(16, 163, 127, 0.12);
  --brand-line: rgba(16, 163, 127, 0.35);
  --danger: #f0575a;
  --danger-soft: rgba(240, 87, 90, 0.12);
  --warn: #e5a13a;
  --warn-soft: rgba(229, 161, 58, 0.12);
  --info: #5aa9f0;
  --radius: 14px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(720px 420px at 50% -10%, rgba(16, 163, 127, 0.13), transparent 70%),
    radial-gradient(560px 380px at 90% 8%, rgba(90, 169, 240, 0.07), transparent 70%);
  z-index: 0;
}

header.top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 12, 17, 0.72);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--brand), #0d7f63);
  display: grid;
  place-items: center;
  font-size: 15px;
  color: #fff;
}

/* flex-basis auto + 不收缩：内容矮时垂直居中，内容高时照常撑开不被压扁 */
main {
  position: relative;
  z-index: 1;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 660px;
  margin: 0 auto;
  padding: 36px 20px 44px;
}

.hero { text-align: center; margin-bottom: 26px; }
.hero h1 {
  margin: 0 0 10px;
  font-size: 30px;
  font-weight: 680;
  letter-spacing: -0.4px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}
.badge {
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 4px 11px;
  border-radius: 999px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.step { display: none; padding: 26px; }
.step.active { display: block; }

.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

label.lab {
  display: block;
  font-size: 13.5px;
  font-weight: 560;
  margin-bottom: 8px;
}
label.lab .req { color: var(--brand); margin-left: 3px; }

.hint { font-size: 12.5px; color: var(--muted-2); margin-top: 7px; line-height: 1.55; }

input[type='text'], input[type='password'], input[type='number'], textarea, select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand-line);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }

input.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 17px;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 13px;
}

textarea {
  min-height: 128px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.55;
  letter-spacing: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 14.5px;
  font-weight: 560;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:not(:disabled):hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:not(:disabled):hover { border-color: var(--muted-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); border-color: rgba(240,87,90,.3); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-top: 14px;
  border: 1px solid transparent;
  line-height: 1.55;
}
.alert .ico { flex-shrink: 0; font-size: 14px; line-height: 1.5; }
.alert-ok { background: var(--brand-soft); border-color: var(--brand-line); color: #4fd1ab; }
.alert-err { background: var(--danger-soft); border-color: rgba(240,87,90,.3); color: #ff8a8c; }
.alert-warn { background: var(--warn-soft); border-color: rgba(229,161,58,.3); color: #f0bd6d; }
.alert-info { background: rgba(90,169,240,.1); border-color: rgba(90,169,240,.25); color: #8cc4f5; }

details.guide {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  overflow: hidden;
}
details.guide summary {
  padding: 11px 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--brand);
  user-select: none;
  list-style: none;
}
details.guide summary::-webkit-details-marker { display: none; }
details.guide summary::before { content: '▸ '; }
details.guide[open] summary::before { content: '▾ '; }
details.guide .body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 13.5px;
  color: var(--muted);
}
details.guide ol { margin: 12px 0 0; padding-left: 20px; }
details.guide li { margin-bottom: 9px; }
details.guide code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 1.5px 6px;
  border-radius: 5px;
  font-size: 12.5px;
  color: #9ad9c4;
  word-break: break-all;
}

.summary-box {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px 16px;
  margin-bottom: 18px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .k { color: var(--muted); }
.summary-row .v { font-weight: 550; text-align: right; word-break: break-all; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.copyable {
  cursor: pointer;
  border-bottom: 1px dashed var(--line);
  transition: color .15s, border-color .15s;
}
.copyable:hover { color: var(--brand); border-bottom-color: var(--brand); }

.progress-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}
.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.ok { background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.dot.err { background: var(--danger); box-shadow: 0 0 0 4px var(--danger-soft); }

.console {
  background: #070a0e;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  height: 300px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.75;
  scrollbar-width: thin;
}
.console::-webkit-scrollbar { width: 8px; }
.console::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
.log-line { display: flex; gap: 10px; word-break: break-word; }
.log-line .t { color: var(--muted-2); flex-shrink: 0; }
.log-line.info .m { color: #c6d0de; }
.log-line.success .m { color: #4fd1ab; }
.log-line.error .m { color: #ff8a8c; }
.log-line.warn .m { color: #f0bd6d; }
.log-empty { color: var(--muted-2); }

footer.bottom {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 22px;
  font-size: 12.5px;
  color: var(--muted-2);
  border-top: 1px solid var(--line-soft);
}

.hidden { display: none !important; }

/* ---------- 管理后台 ---------- */

main.wide { max-width: 1180px; }

.login-wrap {
  max-width: 380px;
  margin: 9vh auto 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.stat .k { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -0.3px; }
.stat .s { font-size: 12px; color: var(--muted-2); margin-top: 3px; }
.stat.accent .v { color: var(--brand); }
.stat.warn .v { color: var(--warn); }
.stat.danger .v { color: var(--danger); }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  padding: 9px 16px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab.active { color: var(--text); border-bottom-color: var(--brand); }

.pane { display: none; }
.pane.active { display: block; }

.switch-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  cursor: pointer;
}
.switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 auto;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-ui {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line);
  transition: background .15s;
}
.switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .15s, background .15s;
}
.switch input:focus-visible + .switch-ui {
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.switch input:checked + .switch-ui { background: var(--brand); }
.switch input:checked + .switch-ui::after {
  transform: translateX(20px);
  background: #fff;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { width: auto; min-width: 140px; padding: 8px 11px; font-size: 13.5px; }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: auto;
  background: var(--panel);
  max-height: 62vh;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  text-align: left;
  padding: 10px 13px;
  font-weight: 560;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}
tbody td {
  padding: 9px 13px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
td.wrap { white-space: normal; word-break: break-all; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 550;
  border: 1px solid transparent;
}
.pill.available, .pill.completed, .pill.active { background: var(--brand-soft); color: #4fd1ab; border-color: var(--brand-line); }
.pill.used, .pill.exhausted, .pill.unloaded, .pill.stopped { background: rgba(139,152,173,.12); color: var(--muted); border-color: var(--line); }
.pill.locked, .pill.running, .pill.pending { background: var(--warn-soft); color: #f0bd6d; border-color: rgba(229,161,58,.3); }
.pill.disabled, .pill.failed, .pill.closed, .pill.missing { background: var(--danger-soft); color: #ff8a8c; border-color: rgba(240,87,90,.3); }

.codes-out {
  margin-top: 14px;
  background: #070a0e;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 240px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.85;
  white-space: pre;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.72);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.modal-body { padding: 18px; overflow: auto; }
.modal-body .console { height: 340px; }

.empty { padding: 34px; text-align: center; color: var(--muted-2); font-size: 13.5px; }

/* .alert 基础样式是 flex 行，公告要整段居中所以改回块级 */
.notice {
  display: block;
  text-align: center;
  margin: 0 0 22px;
  padding: 13px 18px;
  overflow-wrap: anywhere;
}

.tools {
  margin-top: 26px;
  padding-top: 24px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.tools-hint {
  flex-basis: 100%;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

/* 次要工具入口：主 CTA 已经是绿色实心按钮，这里刻意做轻，避免抢焦点 */
.btn-tool {
  min-width: 190px;
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}
.btn-tool:not(:disabled):hover { border-color: var(--brand-line); color: var(--brand); }

.kv-box { display: grid; gap: 1px; background: var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 15px;
  background: var(--panel-2);
  font-size: 13.5px;
}
.kv-row .k { color: var(--muted); flex-shrink: 0; }
.kv-row .v { text-align: right; word-break: break-all; }
.plan-hit { font-size: 17px; font-weight: 700; color: var(--brand); }
.plan-miss { font-size: 17px; font-weight: 700; color: var(--muted); }
/* 到期倒计时和停用状态：灰色会被当成次要信息，这里要的是提醒 */
.v-warn { font-weight: 650; color: var(--warn); }
.v-danger { font-weight: 650; color: var(--danger); }

/* 账户详情卡片网格：宽屏自动排 3 列，窄屏回落，空字段的格子不渲染 */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.detail-cell {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  min-width: 0;
}
.dc-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--muted-2);
}
.dc-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dc-value {
  font-size: 15.5px;
  font-weight: 600;
  margin-top: 7px;
  line-height: 1.4;
  word-break: break-all;
}
.dc-value .plan-hit, .dc-value .plan-miss { font-size: 15.5px; }
.dc-sub { font-size: 11.5px; font-weight: 400; color: var(--muted); }

@media (max-width: 620px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  main { padding: 28px 14px 40px; }
  .hero h1 { font-size: 24px; }
  .step { padding: 20px 16px; }
  input.code { font-size: 15px; letter-spacing: 1px; }
  /* 窄屏下两个工具按钮各占一行，避免挤成两个半宽小按钮 */
  .tools .btn-tool { flex: 1 1 100%; min-width: 0; }
}
