/* ============================================================
   cf_control frontend — 全局样式
   深色 / 浅色自适应（prefers-color-scheme），零外部依赖
   ============================================================ */

:root {
  --bg: #f5f7fb;
  --bg-soft: #eef1f7;
  --bg-card: #ffffff;
  --text: #1d2433;
  --muted: #67708a;
  --border: #dfe4ee;
  --primary: #3b5bdb;
  --primary-strong: #2f49c4;
  --primary-soft: rgba(59, 91, 219, 0.1);
  --danger: #e03131;
  --danger-soft: rgba(224, 49, 49, 0.1);
  --success: #2f9e44;
  --success-soft: rgba(47, 158, 68, 0.12);
  --warn: #e8890c;
  --warn-soft: rgba(232, 137, 12, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 6px 24px rgba(23, 32, 61, 0.08);
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Code", Menlo, Consolas,
    "Liberation Mono", monospace;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --bg-soft: #161d2e;
    --bg-card: #172032;
    --text: #e8edf6;
    --muted: #8e97ad;
    --border: #2a3450;
    --primary: #6c8cff;
    --primary-strong: #83a0ff;
    --primary-soft: rgba(108, 140, 255, 0.16);
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, 0.14);
    --success: #51cf66;
    --success-soft: rgba(81, 207, 102, 0.14);
    --warn: #ffa94d;
    --warn-soft: rgba(255, 169, 77, 0.14);
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.65;
  min-height: 100vh;
}

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

/* ---------- 布局 ---------- */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 44px 16px 88px;
}
.container.wide {
  max-width: 780px;
}

.page-head {
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 6px 0 0;
  font-size: 1.55rem;
}
.brand {
  font-weight: 700;
  color: var(--text);
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.card + .card {
  margin-top: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 20px;
  font-size: 0.95rem;
}

/* ---------- 首页 ---------- */
.hero {
  margin-bottom: 22px;
}
.hero h1 {
  font-size: 1.8rem;
  margin: 0 0 8px;
}
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
a.card.entry-card {
  display: block;
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
a.card.entry-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}
.entry-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 4px;
}
.login-state {
  font-size: 0.95rem;
}

/* ---------- 表单 ---------- */
label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 14px 0 6px;
}
.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.input::placeholder {
  color: var(--muted);
  opacity: 0.75;
}
.form-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  text-decoration: none;
}
.btn:hover {
  filter: brightness(1.08);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn-block {
  width: 100%;
}
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover {
  background: var(--bg-soft);
  filter: none;
}
.btn-danger {
  background: var(--danger);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--primary);
}
.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

/* ---------- 验证码 / 等宽 ---------- */
.mono {
  font-family: var(--mono);
}
.code-box {
  background: var(--bg-soft);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 20px 14px;
  text-align: center;
  margin: 16px 0;
  user-select: all;
}
.code {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--primary);
  word-break: break-all;
}
.code-input {
  font-family: var(--mono);
  font-size: 1.3rem;
  letter-spacing: 0.35em;
  text-align: center;
}
.otpauth-uri {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 8px;
}

/* ---------- 步骤引导 ---------- */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 14px 0;
}
.steps li {
  position: relative;
  padding: 2px 0 12px 36px;
  color: var(--muted);
  font-size: 0.93rem;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Tab ---------- */
.tabbar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  gap: 6px;
}
.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* ---------- 密码强度 checklist ---------- */
.checklist {
  list-style: none;
  padding: 0;
  margin: 10px 0 4px;
}
.checklist li {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 2px 0;
}
.checklist li.pass {
  color: var(--success);
}
.checklist li.fail {
  color: var(--danger);
}

/* ---------- 徽章 / 工具类 ---------- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}
.badge-off {
  background: var(--bg-soft);
  color: var(--muted);
}
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.muted {
  color: var(--muted);
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mb-8 {
  margin-bottom: 8px;
}
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}
.hidden {
  display: none !important;
}

/* ---------- 提示条 ---------- */
.notice {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin: 12px 0;
}
.notice-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.notice-success {
  background: var(--success-soft);
  color: var(--success);
}
.notice-error {
  background: var(--danger-soft);
  color: var(--danger);
}
.notice-info {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toast-in 0.2s ease;
}
.toast-success {
  border-left-color: var(--success);
}
.toast-error {
  border-left-color: var(--danger);
}
.toast-info {
  border-left-color: var(--primary);
}
.toast-hide {
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.3s, transform 0.3s;
}
@keyframes toast-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* ---------- 表格 ---------- */
table.simple {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.simple th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 0.82rem;
}
table.simple td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* ---------- TOTP 恢复码 ---------- */
.secret-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.secret-item {
  font-family: var(--mono);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 8px;
  font-size: 0.85rem;
  text-align: center;
  word-break: break-all;
}

/* ---------- 其他 ---------- */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.divider-text {
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  margin: 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.divider-text::before,
.divider-text::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 14px 0;
}