/* ============================================================
   XServer Mail Provisioner — "Terminal Noir"
   深色工程控制台：等宽凭据为视觉主角，操作区克制，历史区紧凑。
   ============================================================ */

:root {
  --bg:            oklch(16% 0.015 265);
  --bg-grain:      oklch(19% 0.018 265);
  --surface:       oklch(21% 0.020 265);
  --surface-high:  oklch(25% 0.022 265);
  --line:          oklch(32% 0.020 265);
  --line-soft:     oklch(27% 0.018 265);

  --text:          oklch(95% 0.008 265);
  --text-muted:    oklch(68% 0.018 265);
  --text-faint:    oklch(52% 0.018 265);

  --accent:        oklch(80% 0.165 162);
  --accent-dim:    oklch(62% 0.120 162);
  --accent-glow:   oklch(80% 0.165 162 / 0.14);
  --indigo:        oklch(74% 0.135 262);
  --warn:          oklch(82% 0.145 78);
  --danger:        oklch(70% 0.180 22);

  --mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;

  --dur: 180ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 82% -10%, oklch(26% 0.045 200 / 0.55), transparent 70%),
    radial-gradient(900px 500px at 5% 100%, oklch(24% 0.040 275 / 0.45), transparent 72%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ─── 顶栏 ─────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 clamp(16px, 3vw, 32px);
  height: 62px;
  border-bottom: 1px solid var(--line-soft);
  background: oklch(16% 0.015 265 / 0.82);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 620;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), var(--indigo));
  color: oklch(18% 0.03 265);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
}

.brand small {
  display: block;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-spacer { flex: 1; }

.domain-chip {
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
}

.domain-chip b { color: var(--accent); font-weight: 500; }

/* ─── 徽章 ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 560;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-live  { background: oklch(80% 0.165 162 / 0.13); color: var(--accent); }
.badge-mock  { background: oklch(82% 0.145 78 / 0.14);  color: var(--warn); }

/* ─── 通用按钮 ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 520;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn:hover { background: var(--surface-high); border-color: oklch(40% 0.03 265); }
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(140deg, var(--accent), var(--accent-dim));
  color: oklch(18% 0.04 165);
  font-weight: 640;
  box-shadow: 0 6px 22px -10px var(--accent);
}

.btn-primary:hover {
  background: linear-gradient(140deg, oklch(85% 0.17 162), var(--accent));
  border-color: transparent;
}

.btn-primary:disabled,
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost { background: transparent; border-color: var(--line-soft); color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }

.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }

.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

/* ─── 布局 ─────────────────────────────────────────────── */

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(20px, 3.5vw, 38px) clamp(16px, 3vw, 32px) 72px;
}

.columns {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: clamp(18px, 2.4vw, 30px);
  align-items: start;
}

@media (max-width: 1000px) {
  .columns { grid-template-columns: minmax(0, 1fr); }
}

.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface), oklch(19% 0.018 265));
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 620;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-body { padding: 18px; }

.stack > * + * { margin-top: 16px; }

/* ─── 表单 ─────────────────────────────────────────────── */

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--text-muted);
}

.field .hint {
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
}

.input,
.compound {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: oklch(18% 0.016 265);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.input:focus-within,
.compound:focus-within {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input input,
.compound input,
textarea.raw {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  outline: none;
}

.input input::placeholder,
.compound input::placeholder { color: var(--text-faint); }

.compound .suffix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-left: 1px dashed var(--line);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13.5px;
  white-space: nowrap;
}

.input-actions {
  display: flex;
  align-items: center;
  padding-right: 6px;
  gap: 4px;
}

/* 实时预览：本页视觉主角之一 */
.preview {
  padding: 14px 16px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  background:
    radial-gradient(400px 120px at 0% 50%, var(--accent-glow), transparent 70%),
    oklch(18% 0.016 265);
}

.preview-label {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.preview-value {
  margin-top: 5px;
  font-family: var(--mono);
  font-size: clamp(15px, 1.5vw, 18px);
  font-weight: 500;
  color: var(--accent);
  word-break: break-all;
}

.preview-value.idle { color: var(--text-faint); }

/* ─── 结果卡 ───────────────────────────────────────────── */

.result {
  position: relative;
  border: 1px solid var(--accent-dim);
  border-radius: var(--r-lg);
  background:
    radial-gradient(600px 200px at 12% -20%, var(--accent-glow), transparent 65%),
    linear-gradient(180deg, var(--surface-high), var(--surface));
  padding: 20px;
  box-shadow: 0 18px 50px -30px var(--accent);
}

.result-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 620;
  color: var(--accent);
}

.cred {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: oklch(17% 0.016 265);
}

.cred + .cred { margin-top: 10px; }

.cred-body { flex: 1; min-width: 0; }

.cred-key {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.cred-val {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: clamp(14px, 1.6vw, 17px);
  font-weight: 500;
  word-break: break-all;
  user-select: all;
}

.cred-val.pw { color: var(--warn); letter-spacing: 0.04em; }
.cred-val.addr { color: var(--text); }

.copy-btn {
  flex-shrink: 0;
  min-width: 74px;
}

.copy-btn.done {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: oklch(80% 0.165 162 / 0.10);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

/* ─── 步骤流水线 ───────────────────────────────────────── */

.steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--line-soft);
}

.step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.step-dot {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

.step-ok      .step-dot { background: oklch(80% 0.165 162 / 0.18); color: var(--accent); }
.step-skipped .step-dot { background: oklch(74% 0.135 262 / 0.18); color: var(--indigo); }
.step-failed  .step-dot { background: oklch(70% 0.180 22 / 0.18);  color: var(--danger); }

.step b { color: var(--text); font-weight: 560; }

/* ─── 历史 ─────────────────────────────────────────────── */

.history-list { display: flex; flex-direction: column; }

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line-soft);
  transition: background var(--dur) var(--ease);
}

.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: oklch(24% 0.022 265 / 0.6); }

.history-main { flex: 1; min-width: 0; }

.history-addr {
  font-family: var(--mono);
  font-size: 13.5px;
  color: var(--text);
  word-break: break-all;
}

.history-meta {
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.history-pw {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--warn);
  letter-spacing: 0.03em;
}

.history-pw.masked { color: var(--text-faint); letter-spacing: 0.16em; }

.history-actions { display: flex; gap: 6px; flex-shrink: 0; }

@media (max-width: 620px) {
  .history-row { flex-wrap: wrap; }
  .history-actions { width: 100%; }
}

/* ─── 空状态 / 提示 ────────────────────────────────────── */

.empty {
  padding: 42px 18px;
  text-align: center;
  color: var(--text-faint);
}

.empty-mark {
  font-family: var(--mono);
  font-size: 26px;
  color: var(--line);
}

.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.55;
}

.notice-warn  { background: oklch(82% 0.145 78 / 0.10);  color: oklch(88% 0.10 78);  border: 1px solid oklch(82% 0.145 78 / 0.28); }
.notice-error { background: oklch(70% 0.180 22 / 0.10);  color: oklch(85% 0.12 22);  border: 1px solid oklch(70% 0.180 22 / 0.32); }
.notice-info  { background: oklch(74% 0.135 262 / 0.10); color: oklch(86% 0.08 262); border: 1px solid oklch(74% 0.135 262 / 0.28); }

/* ─── 登录闸门 ─────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(400px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--surface), oklch(18% 0.018 265));
  padding: 34px 30px;
  box-shadow: 0 40px 90px -50px oklch(0% 0 0 / 0.9);
}

.gate-card h1 {
  margin: 18px 0 6px;
  font-size: 20px;
  letter-spacing: -0.015em;
}

.gate-card p {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.gate-card .btn { width: 100%; margin-top: 16px; padding: 11px; }

/* ─── 弹层 ─────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: oklch(10% 0.01 265 / 0.72);
  backdrop-filter: blur(6px);
}

.modal {
  width: min(480px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 24px;
  box-shadow: 0 40px 90px -40px oklch(0% 0 0 / 0.9);
}

.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal p  { margin: 0 0 18px; color: var(--text-muted); font-size: 12.5px; line-height: 1.6; }

.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }

/* ─── 杂项 ─────────────────────────────────────────────── */

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid oklch(18% 0.04 165 / 0.35);
  border-top-color: oklch(18% 0.04 165);
  border-radius: 50%;
  animation: spin 620ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 80;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 100px;
  background: var(--surface-high);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── 窄屏适配 ─────────────────────────────────────────── */

.btn { white-space: nowrap; }

@media (max-width: 820px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    padding: 10px clamp(14px, 4vw, 20px);
    row-gap: 8px;
  }
  .brand small { display: none; }
  .brand { font-size: 15px; }
  .domain-chip { display: none; }
  .topbar-spacer { flex: 1 1 auto; }
}

@media (max-width: 540px) {
  .cred { flex-direction: column; align-items: stretch; gap: 10px; }
  .copy-btn { width: 100%; }
  .result-actions .btn { flex: 1 1 auto; }
  .gate-card { padding: 28px 22px; }
}

/* ─── 设置面板 ─────────────────────────────────────────── */

.modal-lg {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
}

.modal-section + .modal-section {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}

.modal-section > h4 {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 620;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.modal-section > .section-hint {
  margin: 0 0 14px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.55;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-row .field { min-width: 0; }

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

.field + .field { margin-top: 13px; }

/* 当前值 / 来源标记 */
.origin-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 100px;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.origin-runtime { background: oklch(80% 0.165 162 / 0.13); color: var(--accent); }
.origin-env,
.origin-config { background: oklch(74% 0.135 262 / 0.14); color: var(--indigo); }
.origin-default { background: oklch(82% 0.145 78 / 0.13); color: var(--warn); }

.current-value {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  word-break: break-all;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: oklch(18% 0.016 265);
  cursor: pointer;
  font-size: 13px;
}

.checkbox input { accent-color: var(--accent-dim); width: 15px; height: 15px; }

/* field-row 是横向两列，不该继承 .field + .field 的垂直间距 */
.field-row .field + .field { margin-top: 0; }
