/* 统一认证中心共享样式：语义化双主题，无组件库 */
:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --panel: #ffffff;
  --panel2: #f1f3f5;
  --panel-hover: #F2F4F7;
  --line: #dfe3e8;
  --control-line: #929ba5;
  --primary: #6F531B;
  --primary-dark: #5b4316;
  --primary-action: #f5c842;
  --primary-action-hover: #edbb23;
  --primary-ink: #181a20;
  --primary-soft: #EBDDAD;
  --primary-border: #A98235;
  --selected-indicator: #A98235;
  --danger: #c83f50;
  --danger-ink: #ffffff;
  --danger-soft: #fbeaec;
  --danger-border: #d29aa1;
  --success: #18794e;
  --success-soft: #e5f4ec;
  --warning: #946200;
  --text: #475467;
  --muted: #566575;
  --disabled: #64717c;
  --border: var(--line);
  --focus-ring: 0 0 0 3px rgb(196 145 0 / 26%);
  --overlay: rgb(20 28 36 / 48%);
  --shadow-popover: 0 12px 32px rgb(29 43 56 / 16%);
  --shadow-modal: 0 24px 72px rgb(29 43 56 / 24%);
  --radius-sm: 4px;
  --radius-md: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e11;
  --panel: #181a20;
  --panel2: #1e2329;
  --panel-hover: #2b3139;
  --line: #2b3139;
  --control-line: #5e6673;
  --primary: #f0b90b;
  --primary-dark: #d9a506;
  --primary-action: #f0b90b;
  --primary-action-hover: #d9a506;
  --primary-ink: #181a20;
  --primary-soft: #30280f;
  --primary-border: #80640c;
  --selected-indicator: #f0b90b;
  --danger: #ff7881;
  --danger-ink: #2a1115;
  --danger-soft: #40262a;
  --danger-border: #8c565d;
  --success: #72d6a0;
  --success-soft: #1d3a2d;
  --warning: #f0c36a;
  --text: #edf2f4;
  --muted: #b4c0c8;
  --disabled: #a0adb5;
  --border: var(--line);
  --focus-ring: 0 0 0 3px rgb(240 185 11 / 32%);
  --overlay: rgb(0 0 0 / 66%);
  --shadow-popover: 0 12px 32px rgb(0 0 0 / 42%);
  --shadow-modal: 0 24px 72px rgb(0 0 0 / 56%);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  transition: background-color .18s ease, color .18s ease;
}

[v-cloak] { display: none !important; }

:is(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

/* ---------- 容器与卡片 ---------- */
.container-sm { max-width: 400px; margin: 48px auto; padding: 0 16px; }
.container { max-width: 800px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}
.separated-cards > .card + .card { margin-top: 16px; }
.brand { font-size: 22px; font-weight: 700; text-align: center; margin: 4px 0 20px; color: var(--primary); letter-spacing: .5px; }
.brand-mini { font-size: 16px; font-weight: 700; }
.footer-tip { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- Tab 切换（下划线高亮） ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
  flex: 1; min-height: 44px; padding: 10px 4px; background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 表单 ---------- */
label, .field-label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--control-line); border-radius: 4px; background: var(--panel2); color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[type="checkbox"] { width: 18px; min-width: 18px; min-height: 18px; height: 18px; accent-color: var(--primary); }

.btn {
  display: inline-flex; min-height: 40px; align-items: center; justify-content: center;
  padding: 8px 16px; font-size: 14px; font-family: inherit; font-weight: 600;
  border-radius: 4px; border: 1px solid transparent; cursor: pointer;
  background: var(--panel2); color: var(--text);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .08s ease;
}
.btn:hover:not(:disabled) { background: var(--panel-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { color: var(--disabled); cursor: not-allowed; opacity: .78; }
.btn-primary { width: 100%; margin-top: 18px; background: var(--primary-action); color: var(--primary-ink); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--primary-action-hover); }
.btn-primary:disabled { background: var(--panel-hover); border-color: var(--line); }
.btn-danger { background: var(--danger); color: var(--danger-ink); }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-outline { border-color: var(--control-line); background: var(--panel2); }
.btn-danger.btn-sm { min-height: 40px; }
.btn-outline:hover:not(:disabled) { background: var(--panel-hover); border-color: var(--primary); color: var(--primary); }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }

.form-row { margin-bottom: 8px; }
.error {
  background: var(--danger-soft); color: var(--danger); font-size: 14px;
  padding: 8px 12px; border-radius: 4px; margin: 10px 0;
}
.notice {
  background: var(--success-soft); color: var(--success); font-size: 14px;
  padding: 8px 12px; border-radius: 4px; margin: 10px 0;
}
.link { display: inline-flex; align-items: center; min-height: 36px; color: var(--primary); font-size: 14px; cursor: pointer; background: none; border: none; padding: 0 4px; font-family: inherit; }
.link:hover { text-decoration: underline; }
.link:disabled { color: var(--disabled); cursor: not-allowed; text-decoration: none; }

/* ---------- 导航栏 ---------- */
.navbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 20px; margin-bottom: 20px;
}
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* ---------- 表格（斑马纹 + hover） ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--panel); }
.table th, .table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.table th { background: var(--panel2); font-weight: 600; color: var(--muted); }
.table tbody tr:nth-child(even) { background: var(--panel2); }
.table tbody tr:hover { background: var(--panel-hover); }
.table th { position: sticky; top: 0; z-index: 1; }
.tag-ok { color: var(--success); font-weight: 600; }
.tag-fail { color: var(--danger); font-weight: 600; }
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

/* ---------- 模态框（阶段 C 使用） ---------- */
.modal-mask {
  position: fixed; inset: 0; background: var(--overlay);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px;
  width: min(520px, calc(100vw - 32px)); max-height: min(86vh, 760px); overflow: auto;
  box-shadow: var(--shadow-modal);
}
.modal-title { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- toast（右下角弹出） ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px;
  background: var(--panel2); color: var(--text); padding: 10px 18px; border: 1px solid var(--line); border-radius: 4px;
  font-size: 14px; z-index: 300; box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
  animation: toast-in .2s ease-out;
}
.toast.success { background: var(--success-soft); color: var(--success); font-weight: 600; border-color: var(--success); }
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- 全局 loading ---------- */
.loading-mask {
  position: fixed; inset: 0; background: var(--overlay);
  z-index: 200; display: flex; align-items: center; justify-content: center;
}
.loading-mask.hidden { display: none; }
.spinner {
  width: 34px; height: 34px; border: 3px solid var(--line);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 2FA 辅助 ---------- */
.otp-row { display: flex; gap: 8px; justify-content: center; margin: 16px 0; }
.otp-box {
  width: 42px; height: 50px; text-align: center; font-size: 22px;
  border: 1px solid var(--line); border-radius: 4px;
}
.qr-box { display: flex; justify-content: center; margin: 14px 0; }
.qr-box svg { width: 180px; height: 180px; }
.secret-line {
  background: var(--panel2); border: 1px dashed var(--line); border-radius: 4px;
  padding: 8px 12px; font-family: Consolas, "Roboto Mono", monospace; font-size: 14px;
  word-break: break-all; text-align: center;
}
.recovery-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px;
  list-style: none; padding: 0; margin: 12px 0;
}
.recovery-grid li {
  font-family: Consolas, "Roboto Mono", monospace; font-size: 14px; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 4px; padding: 6px 8px;
}
.warn-line { color: var(--danger); font-size: 14px; font-weight: 600; }
.ok-line { color: var(--success); font-weight: 600; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.inline-form input { width: 220px; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel2); color: var(--text); font: inherit; font-size: 20px;
  cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.theme-toggle:hover { background: var(--panel-hover); color: var(--primary); border-color: var(--primary); }
.theme-toggle-floating { position: fixed; top: 18px; right: 18px; z-index: 120; box-shadow: var(--shadow-popover); }
.mail-page .theme-toggle-floating { top: 18px; right: 18px; }
.form-card { width: min(100%, 560px); }
.flow-compact { margin-top: 8px; }
.flow-section { margin-bottom: 18px; }
.toolbar-control { min-width: 140px; }
.toolbar button.btn-sm { min-height: 42px; }
.toolbar-search { min-width: 220px; }
.table-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.table-actions .link { min-height: 40px; padding: 0 6px; }
.page-count { align-self: center; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.overview-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.detail-list { padding-left: 20px; line-height: 1.8; }
.text-center { text-align: center; }
.modal-panel label, .modal-panel .field-label { margin-top: 14px; }
.modal-mask { padding: 16px; overflow-y: auto; }
.modal-panel { margin: auto; }
.text-right { text-align: right; }

/* ---------- 表单分组 / 标题（新增，兼容 login.html 旧类名） ---------- */
.form-group { margin-bottom: 14px; }
.title { font-size: 20px; font-weight: 700; margin: 0 0 14px; }
.card-title { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.section-title {
  font-size: 14px; font-weight: 600; margin: 22px 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}

/* ---------- 工具栏 / 空状态 / 标签 ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }
.empty {
  text-align: center; color: var(--muted); padding: 32px 0; font-size: 14px;
}
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 4px;
  font-size: 12px; background: var(--panel2); border: 1px solid var(--line);
}
.tag-blue { color: var(--primary); background: var(--primary-soft); border-color: var(--primary-border); }
.tag-green { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 62%, var(--line)); }
.tag-red { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.tag-gray { color: var(--muted); }

/* ---------- 按钮行 / 描述列表 ---------- */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.btn-row .btn-primary { width: auto; margin-top: 0; }
.btn-inline { width: auto; margin-top: 0; }
.desc-list { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 14px; }
.desc-list dt { color: var(--muted); margin: 0; }
.desc-list dd { margin: 0; word-break: break-all; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap .table { border: none; }
.table-wrap .table th:first-child, .table-wrap .table td:first-child { border-left: none; }
.table-wrap .table th:last-child, .table-wrap .table td:last-child { border-right: none; }
.row-current { background: var(--primary-soft); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; max-height: 220px; overflow: auto; }
.check-grid label { display: flex; align-items: center; gap: 6px; min-height: 40px; margin: 0; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); font-size: 14px; color: var(--text); cursor: pointer; }
.check-grid label:hover { border-color: var(--primary); background: var(--panel-hover); }
.check-grid input { width: 18px; min-width: 18px; flex: 0 0 18px; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.checkbox-inline input { width: 18px; min-width: 18px; flex: 0 0 18px; }
.mono { font-family: Consolas, "Roboto Mono", monospace; font-size: 12px; word-break: break-all; }

/* ---------- 响应式（小屏全宽） ---------- */
@media (max-width: 600px) {
  .container-sm, .container { max-width: 100%; margin: 12px auto; }
  .card { padding: 20px 16px; }
  .otp-box { width: 36px; height: 44px; }
  .toolbar input, .toolbar select { min-width: 100px; }
  .toolbar { align-items: stretch; }
  .toolbar > :not(.spacer) { min-width: 0; max-width: 100%; }
  .toolbar .spacer { display: none; }
  .pager { justify-content: center; flex-wrap: wrap; }
  .modal-actions { position: sticky; bottom: -24px; background: var(--panel); padding: 12px 0 0; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form input { width: 100%; }
  .overview-columns { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (max-width: 360px) {
  .otp-row { gap: 4px; }
  .otp-box { width: 40px; }
  .desc-list { grid-template-columns: 1fr; gap: 4px; }
  .desc-list dd + dt { margin-top: 8px; }
}
