/* TK 工具 · 组件库(配合 tokens.css)· 2026-05-22
   标准化:按钮/卡片/表格/状态标/表单/toast/空态/tab/导航。各页统一用这些类。 */

/* ---------- 基础 ---------- */
*{ box-sizing:border-box; }
body{
  margin:0; font-family:var(--font); color:var(--text); background:var(--bg);
  font-size:14px; line-height:1.5; -webkit-font-smoothing:antialiased;
}
.mono, .num{ font-family:var(--mono); font-variant-numeric:tabular-nums; }
a{ color:var(--primary); text-decoration:none; }
a:hover{ text-decoration:underline; }
.muted{ color:var(--text-muted); }
.faint{ color:var(--text-faint); }
.wrap{ max-width:1480px; margin:0 auto; padding:var(--space-4); }

/* ---------- 顶栏 / 导航(nav.js 注入)---------- */
.app-header{
  position:sticky; top:0; z-index:40; background:rgba(255,255,255,.86);
  backdrop-filter:saturate(1.4) blur(8px); border-bottom:1px solid var(--border);
}
.app-header .inner{ max-width:1480px; margin:0 auto; padding:10px 16px; display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.brand{ display:flex; align-items:center; gap:8px; font-weight:800; letter-spacing:.2px; }
.brand .dot{ width:9px; height:9px; border-radius:3px; background:var(--primary); box-shadow:0 0 0 3px var(--primary-100); }
.app-nav{ display:flex; gap:2px; flex-wrap:wrap; }
.nav-link{
  padding:6px 11px; border-radius:8px; font-size:13px; color:var(--text-muted);
  font-weight:600; transition:background var(--t-fast), color var(--t-fast); white-space:nowrap;
}
.nav-link:hover{ background:var(--surface-2); color:var(--text); text-decoration:none; }
.nav-link.active{ background:var(--primary); color:#fff; box-shadow:var(--shadow-sm); }
.nav-sep{ width:1px; height:18px; background:var(--border-strong); margin:0 4px; align-self:center; }

/* ---------- 按钮 ---------- */
.btn{
  display:inline-flex; align-items:center; gap:6px; justify-content:center;
  font-family:inherit; font-size:13px; font-weight:600; line-height:1;
  padding:8px 14px; border-radius:var(--radius-sm); border:1px solid transparent;
  cursor:pointer; transition:transform var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  user-select:none;
}
.btn:active{ transform:translateY(1px); }
.btn:disabled{ opacity:.55; cursor:not-allowed; transform:none; }
.btn:focus-visible{ outline:none; box-shadow:var(--ring); }
.btn-primary{ background:var(--primary); color:#fff; box-shadow:var(--shadow-sm); }
.btn-primary:hover:not(:disabled){ background:var(--primary-hover); box-shadow:var(--shadow); }
.btn-ghost{ background:var(--surface); color:var(--text); border-color:var(--border-strong); }
.btn-ghost:hover:not(:disabled){ background:var(--surface-2); }
.btn-danger{ background:var(--surface); color:var(--danger-text); border-color:#f3c0c0; }
.btn-danger:hover:not(:disabled){ background:var(--danger-bg); }
.btn-sm{ padding:5px 10px; font-size:12px; }
.btn-lg{ padding:11px 20px; font-size:14px; }

/* ---------- 卡片 ---------- */
.card{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow-sm); }
.card-pad{ padding:var(--space-4); }
.card-head{ padding:10px 14px; border-bottom:1px solid var(--border); font-weight:700; display:flex; align-items:center; justify-content:space-between; gap:8px; }
.card-body{ padding:var(--space-4); }
.toolbar{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.spacer{ flex:1; }

/* ---------- 统计块 ---------- */
.stats{ display:grid; gap:10px; }
.stat{ background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px 16px; box-shadow:var(--shadow-sm); }
.stat .label{ font-size:11px; color:var(--text-muted); letter-spacing:.4px; }
.stat .value{ font-size:24px; font-weight:800; font-variant-numeric:tabular-nums; margin-top:2px; }
.stat .value.accent{ color:var(--primary); }
.stat .value.ok{ color:var(--ok); } .stat .value.warn{ color:var(--warn); } .stat .value.danger{ color:var(--danger); }

/* ---------- 表格 ---------- */
.tbl{ width:100%; border-collapse:collapse; font-size:13px; }
.tbl thead th{ text-align:left; font-size:11px; font-weight:600; letter-spacing:.3px; color:var(--text-muted); padding:9px 10px; background:var(--surface-2); border-bottom:1px solid var(--border); white-space:nowrap; }
.tbl tbody td{ padding:8px 10px; border-bottom:1px solid var(--border); vertical-align:middle; }
.tbl tbody tr:last-child td{ border-bottom:none; }
.tbl tbody tr{ transition:background var(--t-fast); }
.tbl tbody tr:hover{ background:var(--surface-2); }

/* ---------- 状态标(pill)---------- */
.pill{ display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:var(--radius-pill); font-size:12px; font-weight:600; line-height:1.4; }
.pill::before{ content:""; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.85; }
.pill-ok{ background:var(--ok-bg); color:var(--ok-text); }
.pill-warn{ background:var(--warn-bg); color:var(--warn-text); }
.pill-danger{ background:var(--danger-bg); color:var(--danger-text); }
.pill-info{ background:var(--info-bg); color:var(--info-text); }
.pill-neutral{ background:var(--neutral-bg); color:var(--neutral-text); }

/* ---------- 表单 ---------- */
.field{ display:flex; flex-direction:column; gap:4px; }
.field > label{ font-size:11px; color:var(--text-muted); font-weight:600; }
.field .req{ color:var(--danger); }
.input, .select, select.input{
  font-family:inherit; font-size:13px; color:var(--text); background:var(--surface);
  border:1px solid var(--border-strong); border-radius:var(--radius-sm); padding:7px 9px; transition:border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .select:focus, select:focus{ outline:none; border-color:var(--primary); box-shadow:var(--ring); }
.input::placeholder{ color:var(--text-faint); }
.input-xs{ padding:4px 7px; font-size:12px; }

/* select 染色(状态下拉)沿用 pill 配色 */
select.sel-ok{ background:var(--ok-bg); color:var(--ok-text); border-color:transparent; }
select.sel-warn{ background:var(--warn-bg); color:var(--warn-text); border-color:transparent; }
select.sel-danger{ background:var(--danger-bg); color:var(--danger-text); border-color:transparent; }
select.sel-neutral{ background:var(--neutral-bg); color:var(--neutral-text); border-color:transparent; }

/* ---------- tab ---------- */
.tabs{ display:flex; gap:8px; }
.tab{ padding:8px 16px; border-radius:var(--radius-sm); font-size:13px; font-weight:700; border:1px solid var(--border-strong); background:var(--surface); color:var(--text-muted); cursor:pointer; transition:all var(--t-fast); }
.tab:hover{ color:var(--text); }
.tab.active{ background:var(--primary); color:#fff; border-color:var(--primary); box-shadow:var(--shadow-sm); }

/* ---------- 空态 ---------- */
.empty{ text-align:center; color:var(--text-faint); padding:40px 16px; font-size:13px; }

/* ---------- toast(替代 alert)---------- */
#toastWrap{ position:fixed; right:18px; bottom:18px; z-index:100; display:flex; flex-direction:column; gap:8px; }
.toast{ min-width:220px; max-width:380px; background:var(--surface); border:1px solid var(--border); border-left:3px solid var(--text-muted); border-radius:var(--radius-sm); box-shadow:var(--shadow-lg); padding:10px 14px; font-size:13px; animation:toastIn .22s cubic-bezier(.4,0,.2,1); }
.toast.ok{ border-left-color:var(--ok); }
.toast.danger{ border-left-color:var(--danger); }
.toast.warn{ border-left-color:var(--warn); }
@keyframes toastIn{ from{ opacity:0; transform:translateY(8px); } to{ opacity:1; transform:none; } }

/* ---------- 进场动画 ---------- */
.fade-in{ animation:fadeUp .3s ease both; }
@keyframes fadeUp{ from{ opacity:0; transform:translateY(6px); } to{ opacity:1; transform:none; } }
