/* ============================================================
   素白主题
   原则：纯白为底 · 1px 细边框代替阴影 · 单一系统字体 · 不用渐变
        动效只服务于反馈，不做装饰
   ============================================================ */

/* ---------- 令牌 ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;

  --maxw: 1080px;
  --ease: cubic-bezier(.2, 0, .2, 1);
}

/* 浅色（默认，纯白） */
:root,
:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f7f8;
  --surface-3: #f1f1f3;
  --border: #e6e6ea;
  --border-strong: #d3d3d9;

  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;

  --primary: #18181b;
  --primary-ink: #ffffff;
  --primary-hover: #2a2a2e;

  --accent: #a35a06;
  --accent-soft: #fdf6ec;

  --success: #15803d;
  --success-soft: #f0f9f2;
  --danger: #b3261e;
  --danger-soft: #fdf2f1;
  --warning: #9a5b06;
  --warning-soft: #fdf7ed;

  --shadow-modal: 0 12px 32px -12px rgba(24, 24, 27, .22);
  color-scheme: light;
}

/* 深色（中性灰，不做花哨） */
:root[data-theme="dark"] {
  --bg: #101012;
  --surface: #17171a;
  --surface-2: #1e1e22;
  --surface-3: #26262b;
  --border: #2b2b31;
  --border-strong: #3a3a42;

  --ink: #f4f4f5;
  --ink-2: #d4d4d8;
  --muted: #a1a1aa;
  --faint: #71717a;

  --primary: #f4f4f5;
  --primary-ink: #18181b;
  --primary-hover: #e4e4e7;

  --accent: #e3a951;
  --accent-soft: #241d10;

  --success: #4ade80;
  --success-soft: #14241a;
  --danger: #f87171;
  --danger-soft: #261618;
  --warning: #fbbf24;
  --warning-soft: #241d10;

  --shadow-modal: 0 12px 32px -12px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

/* 浏览器自带的 [hidden]{display:none} 优先级低于本文件里任何带 display 的规则
   （.btn 就是 inline-flex）。不补这一条的话，el.hidden = true 对按钮完全不生效。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; }
p { margin: 0; }

.app-root { min-height: 100dvh; display: flex; flex-direction: column; }
.container { width: min(100% - 40px, var(--maxw)); margin-inline: auto; }
main { flex: 1; padding-block: 32px 64px; }

.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }

/* 视图切换：只用极短的淡入，不做位移特效 */
.view { animation: fade .18s var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.page-head { margin-bottom: 24px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s var(--ease), border-color .15s var(--ease), opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn--primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--primary:active { background: var(--primary); }

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-2); }

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

.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--lg { padding: 10px 18px; font-size: 14px; }
.btn--icon { padding: 7px; }
.btn--block { width: 100%; }

.btn svg { flex: none; opacity: .75; }
.btn--primary svg { opacity: .9; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.card--pad { padding: 20px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
/* .field__title：一组按钮的小标题（没有输入框可关联，就不冒充 <label>），外观同 label */
.field > label, .field > .field__title { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }

.input, .textarea, .select {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 9px 11px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 10%, transparent);
}
.textarea {
  resize: vertical; min-height: 110px; line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px;
}

/* 两列 / 三列的表单栅格；.span-2 占满整行 */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid > .span-2 { grid-column: 1 / -1; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  /* 徽标一律整块走，宁可整个换到下一行，也绝不在内部断字 */
  white-space: nowrap;
}
.badge--dot::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--success); background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.badge--warn { color: var(--warning); background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.badge--bad { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.badge--brand { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- 顶栏 ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.topbar__inner { display: flex; align-items: center; gap: 14px; height: 56px; }
.topbar__spacer { flex: 1; }

.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand__mark {
  flex: none; width: 28px; height: 28px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink);
}
.brand__name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.navlink {
  color: var(--muted); text-decoration: none; font-size: 13.5px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius); transition: color .15s, background .15s;
}
.navlink:hover { color: var(--ink); background: var(--surface-2); }
.navlink.active { color: var(--ink); background: var(--surface-2); }

.avatar {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  font-weight: 600; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  transition: background .15s;
}
.avatar:hover { background: var(--surface-3); }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: min(100%, 380px); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 8px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-form { display: grid; gap: 14px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--faint); }

/* ---------- 网格 ---------- */
.grid { display: grid; gap: 14px; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------- 图标底座 ---------- */
.icon-box { flex: none; width: 34px; height: 34px; border-radius: var(--radius); display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 52px 24px; }
.empty__ic { width: 40px; height: 40px; margin: 0 auto 14px; display: grid; place-items: center; color: var(--faint); }
.empty h3 { font-size: 15px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 42ch; margin: 0 auto 18px; font-size: 13.5px; }

/* ---------- 统计 ---------- */
.stat { padding: 16px 18px; }
.stat__label { font-size: 12.5px; color: var(--muted); }
.stat__value { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------- 弹窗 ---------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60; padding: 20px;
  background: rgba(24, 24, 27, .35);
  display: grid; place-items: center;
  animation: fade .15s var(--ease) both;
}
.modal {
  width: min(100%, 440px); max-height: 88dvh; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  animation: modalIn .18s var(--ease) both;
}
.modal--wide { width: min(100%, 580px); }
/* 无输入框时会把焦点程序化地放到面板上（无障碍需要），但不该画出焦点框 */
.modal:focus, .modal:focus-visible { outline: none; }
@keyframes modalIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.modal__head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; }
.modal__title { font-size: 15px; font-weight: 600; flex: 1; }
.modal__body { padding: 16px 20px 20px; }
.modal__foot { padding: 0 20px 20px; display: flex; gap: 8px; justify-content: flex-end; }
.modal__close { margin-left: auto; color: var(--muted); }

/* ---------- 页签 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 8px 12px; font-size: 13.5px; font-weight: 500; color: var(--muted);
  background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer;
  font-family: inherit; margin-bottom: -1px; transition: color .15s, border-color .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .count { padding: 0 6px; border-radius: 999px; background: var(--surface-3); font-size: 11.5px; color: var(--ink-2); }

/* ---------- 分段切换 ---------- */
.seg { display: flex; padding: 3px; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); }
.seg button { flex: 1; padding: 7px 12px; font-size: 13px; font-family: inherit; border: none; background: none; color: var(--muted); border-radius: var(--radius-sm); cursor: pointer; transition: background .12s, color .12s; }
.seg button:hover { color: var(--ink-2); }
.seg button.active { background: var(--surface); color: var(--ink); font-weight: 500; border: 1px solid var(--border); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.seg button:disabled:hover { color: var(--muted); }

/* ---------- 列表行（放在 .card 里，一行一条） ---------- */
.urow { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.urow:last-child { border-bottom: none; }
/* flex-basis 给一个不大的下限、再允许它长大：这样「名字 + 一串徽标」超宽时，
   徽标在这一块内部换行，按钮组照旧待在右边。 */
.urow__main { display: flex; align-items: center; gap: 11px; min-width: 0; flex: 1 1 260px; }
.urow__av { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; font-size: 12.5px; color: var(--ink-2); }
.urow__name { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.urow__sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
/* margin-left:auto 保证按钮组始终靠右 —— 包括它放不下、独占一行的时候 */
.urow__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }

/* ---------- Toast ---------- */
.toast-host { position: fixed; top: 16px; right: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; min-width: 240px; max-width: 360px;
  display: flex; align-items: flex-start; gap: 9px; padding: 11px 13px;
  border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-modal);
  animation: toastIn .18s var(--ease) both; cursor: pointer;
}
.toast.leaving { animation: toastOut .15s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(12px); } }
.toast__ic { flex: none; margin-top: 1px; }
.toast__title { font-weight: 500; font-size: 13.5px; }
.toast__msg { font-size: 12.5px; color: var(--muted); margin-top: 1px; white-space: pre-line; }
.toast--success .toast__ic { color: var(--success); }
.toast--error .toast__ic { color: var(--danger); }
.toast--warn .toast__ic { color: var(--warning); }
.toast--info .toast__ic { color: var(--muted); }

/* ---------- 加载 ---------- */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--ink);
  animation: spin .6s linear infinite;
}
.btn--primary .spinner { border-color: color-mix(in srgb, var(--primary-ink) 35%, transparent); border-top-color: var(--primary-ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; gap: 9px; padding: 40px 0; color: var(--muted); font-size: 13.5px; }

/* ---------- 工具类 ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-sm { gap: 6px; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 22px; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

.link { color: var(--ink); cursor: pointer; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border-strong); }
.link:hover { text-decoration-color: var(--ink); }
button.link { background: none; border: none; padding: 0; font-family: inherit; font-size: 13px; }
button.link:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 3px; }

/* ---------- 提示条 ---------- */
.note {
  font-size: 12.5px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--ink-2); line-height: 1.6;
}
.note--warn { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 22%, transparent); color: var(--ink-2); }
.note--error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); color: var(--ink-2); }
.note--ok { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 22%, transparent); color: var(--ink-2); }

/* 报错弹窗正文：要能看全、能选中复制。
   报错里常带一长串不含空格的地址，必须 anywhere 才不会把弹窗撑破。 */
.err-box {
  font-size: 13px; line-height: 1.7; color: var(--ink-2);
  padding: 12px 14px; border-radius: var(--radius);
  background: var(--danger-soft);
  border: 1px solid color-mix(in srgb, var(--danger) 22%, transparent);
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  max-height: 46vh; overflow-y: auto;
  user-select: text; -webkit-user-select: text; cursor: text;
}

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .form-grid, .form-grid--3 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .container { width: calc(100% - 28px); }
  .topbar__inner { height: 52px; gap: 8px; }
  .navlink { padding: 6px 8px; font-size: 13px; white-space: nowrap; flex: none; }
  /* 导航链接多了手机上放不下：导航区占满剩余宽度、可横向滑动，主题按钮和头像始终留在右侧 */
  .topbar__inner > nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topbar__inner > nav::-webkit-scrollbar { display: none; }
  .topbar__spacer { display: none; }
  .grid--cards { grid-template-columns: 1fr; }
  .urow { align-items: flex-start; }
  .urow__main { align-items: flex-start; }
  /* 窄屏上按钮组独占一行、从左排起 */
  .urow__actions { width: 100%; justify-content: flex-start; margin-left: 0; }
  /* 页签多了放不下一行：横向滑动，底线改用内阴影（overflow 会裁掉页签 -1px 的下边框） */
  .tabs { overflow-x: auto; scrollbar-width: none; border-bottom: none; box-shadow: inset 0 -1px 0 var(--border); }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; white-space: nowrap; margin-bottom: 0; }
}
@media (max-width: 420px) {
  /* 很窄的手机上只留图标，把宽度让给导航 */
  .brand__name { display: none; }
}

/* ---------- 减少动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
