@tailwind base;
@tailwind components;
@tailwind utilities;

/* ============================================================
 * cc-router 视觉系统 (operator's console)
 * 暖中性灰 + 单一强调色(铁锈橙) + 紧凑密度
 * 参考: claude.ai/design 设计稿 cc-router.html
 * ============================================================ */

:root {
  /* Warm neutral grey scale */
  --bg:        #f6f5f2;
  --surface:   #ffffff;
  --surface-2: #fbfaf7;
  --surface-3: #f1efea;
  --line:      #e6e3dc;
  --line-2:    #d8d4cb;
  --ink:       #1a1916;
  --ink-2:     #3a3833;
  --ink-3:     #6b6962;
  --ink-4:     #9a978f;
  --ink-5:     #bdbab2;

  /* Single accent — Claude 铁锈橙 (rust) */
  --accent:      oklch(0.63 0.14 42);
  --accent-ink:  oklch(0.42 0.12 42);
  --accent-bg:   oklch(0.96 0.03 42);
  --accent-line: oklch(0.85 0.07 42);

  /* Status */
  --ok:    oklch(0.62 0.13 150);
  --ok-bg: oklch(0.95 0.04 150);
  --warn:  oklch(0.70 0.15 75);
  --err:   oklch(0.58 0.18 28);
  --err-bg: oklch(0.96 0.03 28);

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

  --shadow-sm: 0 1px 0 rgba(20,18,12,0.04), 0 1px 2px rgba(20,18,12,0.04);
  --shadow-md: 0 1px 0 rgba(20,18,12,0.04), 0 6px 18px -8px rgba(20,18,12,0.10);
  --shadow-lg: 0 1px 0 rgba(20,18,12,0.04), 0 24px 60px -28px rgba(20,18,12,0.22);

  /* Density: 1 = comfortable, 0.84 = compact (默认 compact) */
  --d: 0.84;
  --pad-card:    calc(18px * var(--d));
  --pad-row:     calc(11px * var(--d));
  --gap-xs:      calc(5px  * var(--d));
  --gap-sm:      calc(8px  * var(--d));
  --gap-md:      calc(12px * var(--d));
  --gap-lg:      calc(18px * var(--d));
  --gap-xl:      calc(24px * var(--d));
  --fs-body:     calc(14px * var(--d));
  --fs-sm:       calc(12px * var(--d));
  --fs-xs:       calc(11px * var(--d));
  --fs-h1:       calc(28px * var(--d));
  --fs-h2:       calc(18px * var(--d));
  --fs-mono:     calc(12.5px * var(--d));

  /* === Tailwind compatibility ===
   * 把 shadcn 风格的 HSL token 重新映射到设计调色板,
   * 让仍在用 Tailwind utility 的页面(Onboarding / SubscriptionEdit / 共享 ui/*)
   * 继续看到一致的暖灰色调,而非旧的冷蓝。
   */
  --background: 40 23% 96%;     /* ≈ #f6f5f2 */
  --foreground: 40 6% 9%;        /* ≈ #1a1916 */
  --card: 0 0% 100%;
  --card-foreground: 40 6% 9%;
  --popover: 0 0% 100%;
  --popover-foreground: 40 6% 9%;
  --primary: 40 6% 9%;           /* ≈ ink */
  --primary-foreground: 0 0% 100%;
  --secondary: 40 14% 93%;
  --secondary-foreground: 40 6% 9%;
  --muted: 40 14% 93%;
  --muted-foreground: 40 4% 42%;
  --accent-foreground: 40 6% 9%;
  --destructive: 18 70% 50%;
  --destructive-foreground: 0 0% 100%;
  --border: 40 14% 88%;
  --input: 40 14% 84%;
  --ring: 40 6% 9%;
  --radius: 0.5rem;

  /* status- 颜色保持 tailwind config 里的语义 */

  /* === Font stacks (system-only, no bundled webfonts) === */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Helvetica Neue", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, "Cascadia Mono", Consolas,
               "Liberation Mono", "Source Han Mono SC", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#root { min-height: 100vh; }

.mono { font-family: var(--font-mono); font-feature-settings: "ss01"; }
.tnum { font-variant-numeric: tabular-nums; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

/* === Layout === */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background: var(--bg);
}

/* === Sidebar === */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: transparent;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* 像素艺术风 logo: 用 nearest-neighbor 保持锐利,避免缩放发糊 */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.brand-text { line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-tag { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  position: relative;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: var(--surface);
}
.nav-item.active .nav-icon { color: var(--accent); }
.nav-item .nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item.active .badge {
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85);
}
.nav-item .badge {
  margin-left: auto;
  font-size: 10.5px;
  font-family: var(--font-mono);
  background: var(--surface-3);
  color: var(--ink-3);
  padding: 1px 6px;
  border-radius: 4px;
}
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.sidebar-footer .live-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px oklch(0.95 0.05 150);
  margin-right: 6px;
  vertical-align: middle;
}
.sidebar-footer .live-dot.off { background: var(--ink-4); box-shadow: 0 0 0 3px var(--surface-3); }

/* === Main === */
.main {
  padding: 22px 28px 36px;
  min-width: 0;
  overflow-x: hidden;
}
.page-header { margin-bottom: 18px; }
.page-header h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--ink);
}
.page-header .subtitle {
  color: var(--ink-3);
  font-size: 13px;
  max-width: 720px;
  line-height: 1.5;
}
.page-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

/* === Cards === */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: var(--pad-card) var(--pad-card) calc(var(--pad-card) - 6px);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 0 var(--pad-card) var(--pad-card); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.btn.primary:hover { background: var(--ink-2); }
.btn.accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.accent:hover { filter: brightness(0.95); }
.btn.danger {
  background: var(--err);
  color: #fff;
  border-color: var(--err);
}
.btn.danger:hover { filter: brightness(0.95); }
.btn.ghost { background: transparent; border: 1px dashed var(--line-2); color: var(--ink-3); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink-4); }
.btn.bare { background: transparent; border: none; color: var(--ink-3); padding: 4px 8px; }
.btn.bare:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
.btn-icon {
  width: 14px; height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* === Pills, badges === */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.pill .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ink-4);
}
.pill.ok { background: var(--ok-bg); color: oklch(0.40 0.12 150); }
.pill.ok .dot { background: var(--ok); }
.pill.warn { background: oklch(0.96 0.05 75); color: oklch(0.45 0.13 75); }
.pill.warn .dot { background: var(--warn); }
.pill.err { background: var(--err-bg); color: oklch(0.42 0.16 28); }
.pill.err .dot { background: var(--err); }
.pill.accent { background: var(--accent-bg); color: var(--accent-ink); }
.pill.accent .dot { background: var(--accent); }
.pill.tag { background: transparent; border: 1px solid var(--line-2); color: var(--ink-3); font-family: var(--font-mono); font-size: 10.5px; padding: 1px 6px; }

/* === Inputs === */
.input, .select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink);
  transition: border 0.12s, box-shadow 0.12s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: var(--ink-2);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.04);
}
.input.mono { font-family: var(--font-mono); }
.input:disabled, .select:disabled { background: var(--surface-2); color: var(--ink-4); cursor: not-allowed; }
.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
  display: block;
}
.field-hint { font-size: 11.5px; color: var(--ink-4); margin-top: 6px; line-height: 1.5; }

/* Toggle */
.toggle {
  width: 38px; height: 22px;
  background: var(--ink-5);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
  border: none;
  padding: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.on { background: var(--ink); }
.toggle.on::after { transform: translateX(16px); }
.toggle:disabled { opacity: 0.5; cursor: not-allowed; }

/* Radio inline */
.radio-group {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 3px;
  gap: 2px;
}
.radio-group button {
  border: none;
  background: transparent;
  padding: 4px 12px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}
.radio-group button.on {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* === Provider logo container === */
.logo {
  width: 22px; height: 22px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--surface-3);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-2);
  position: relative;
  overflow: hidden;
}

/* === Tables === */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.table td {
  padding: var(--pad-row) 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--ink-2);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-2); }
/* mono cell 修饰器:在 .table td.mono 基础上选不同色阶/粗细 */
.table td.mono { font-size: 12px; }
.table td.mono.muted { color: var(--ink-3); }
.table td.mono.strong { color: var(--ink-2); font-weight: 500; }

/* === Routing diagram === */
.diagram {
  background:
    linear-gradient(var(--surface), var(--surface)),
    radial-gradient(circle at 20% 0%, oklch(0.96 0.04 70) 0%, transparent 50%);
  background-blend-mode: normal, normal;
  background-color: var(--surface);
  position: relative;
  overflow: hidden;
}
.diagram::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 16px 16px;
  background-position: -1px -1px;
  opacity: 0.5;
  pointer-events: none;
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 70%, transparent 100%);
}
.diagram-inner { position: relative; z-index: 1; padding: 22px 20px 20px; }

.routemap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 0;
  align-items: stretch;
  position: relative;
}
@media (max-width: 1100px) {
  .routemap { grid-template-columns: 160px minmax(0, 1fr) 160px; }
}

.node {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
  position: relative;
  z-index: 2;
}
.node-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-4);
  font-weight: 600;
}
.node-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.node-meta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.node-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.node-list .row { display: flex; align-items: center; gap: 6px; }
.node-list .row .dot { width: 6px; height: 6px; border-radius: 50%; }

.routemap-mid {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin: 0 16px;
  position: relative;
  min-width: 0;
}
.routemap-mid-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line-2);
}
.routemap-mid-head .live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
.routemap-mid-head .live.off { background: var(--ink-4); animation: none; }
.routemap-mid-head img {
  width: 16px; height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.62 0.13 150 / 0.5); }
  50% { box-shadow: 0 0 0 5px oklch(0.62 0.13 150 / 0); }
}

/* === 路由实时高亮 (proxy/pipeline.rs emit 的事件 → useRouteFlash) === */
@keyframes routeFlashAttempt {
  0%   { background: var(--accent-bg); }
  100% { background: transparent; }
}
@keyframes routeFlashSuccess {
  0%   { background: var(--ok-bg); }
  100% { background: transparent; }
}
@keyframes routeFlashError {
  0%   { background: var(--err-bg); }
  100% { background: transparent; }
}
.chain-chip.route-flash-attempt,
.endpoint.route-flash-attempt { animation: routeFlashAttempt 600ms ease-out; }
.chain-chip.route-flash-success,
.endpoint.route-flash-success { animation: routeFlashSuccess 600ms ease-out; }
.chain-chip.route-flash-error,
.endpoint.route-flash-error { animation: routeFlashError 600ms ease-out; }

.route-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  grid-template-areas: "slot mode" "chain chain";
  align-items: center;
  gap: 4px 8px;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  border-bottom: 1px dotted var(--line);
}
.route-row .route-slot { grid-area: slot; }
.route-row .route-mode { grid-area: mode; }
.route-row .route-chain { grid-area: chain; }
.route-row:last-child { border-bottom: none; }
.route-slot { font-weight: 600; color: var(--ink); }
.route-mode { font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.route-chain { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; row-gap: 4px; }
.chain-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chain-chip .dot { width: 5px; height: 5px; border-radius: 50%; }
.chain-arrow { color: var(--ink-4); font-size: 11px; }
.chain-empty { color: var(--ink-4); font-size: 11px; font-style: italic; }

/* === Slot cards === */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-md);
}
@media (max-width: 900px) {
  .slot-grid { grid-template-columns: 1fr; }
}
.slot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--pad-card);
  box-shadow: var(--shadow-sm);
}
.slot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.slot-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}
.slot-purpose {
  font-size: 12px;
  color: var(--ink-3);
  margin-left: 10px;
}
.slot-purpose strong { color: var(--ink-2); font-weight: 500; }
.slot-mode-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--ink-3);
  margin: 14px 0 12px;
  flex-wrap: wrap;
}

.endpoint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  margin-bottom: 8px;
  position: relative;
}
.endpoint:hover { background: var(--surface); }
.endpoint .grip {
  color: var(--ink-5);
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
}
.endpoint .grip:active { cursor: grabbing; }
.endpoint .priority {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-4);
  background: var(--surface-3);
  width: 18px; height: 18px;
  border-radius: 4px;
  display: grid; place-items: center;
}
.endpoint-info { flex: 1; min-width: 0; }
.endpoint-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.endpoint-model {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.endpoint-model::before { content: '↳ '; color: var(--ink-4); }
.endpoint-status { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.endpoint-status.err { background: var(--err); }
.endpoint-status.warn { background: var(--warn); }
.endpoint-status.idle { background: var(--ink-4); }
.endpoint .remove {
  background: transparent;
  border: none;
  color: var(--ink-4);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}
.endpoint .remove:hover { color: var(--err); background: var(--err-bg); }

.add-endpoint {
  width: 100%;
  padding: 9px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}
.add-endpoint:hover { color: var(--ink); border-color: var(--ink-4); background: var(--surface-2); }
.add-endpoint:disabled { opacity: 0.5; cursor: not-allowed; }

.endpoint-empty {
  border: 1px dashed var(--line-2);
  border-radius: var(--r-sm);
  padding: 18px 12px;
  text-align: center;
  color: var(--ink-4);
  font-size: 12px;
  background: var(--surface-2);
  margin-bottom: 8px;
}

/* === Logs === */
.log-filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.log-filters .select { width: auto; min-width: 140px; }
.log-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-md);
  margin-bottom: var(--gap-lg);
}
@media (max-width: 800px) {
  .log-stats { grid-template-columns: repeat(2, 1fr); }
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
}
.stat-label { font-size: 11px; color: var(--ink-4); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-val {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.stat-delta { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.stat-delta.up { color: oklch(0.45 0.13 150); }
.stat-delta.down { color: var(--err); }

/* === Statistics page === */
.range-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
}
.range-tab {
  padding: 5px 12px;
  font-size: 12px;
  border: none;
  background: transparent;
  border-radius: 4px;
  color: var(--ink-3);
  cursor: pointer;
}
.range-tab:hover { color: var(--ink); }
.range-tab.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.stats-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.stats-section-header {
  margin-bottom: 14px;
}
.stats-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.stats-section-subtitle {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 2px;
}
.stat-unit { font-size: 14px; color: var(--ink-3); }
.cell-with-icon { display: flex; align-items: center; gap: 8px; }
.cell-with-icon-label { font-size: 12.5px; }
.bar-row-label { font-size: 12.5px; }
.bar-meta-sub { color: var(--ink-4); margin-left: 6px; }

/* Heatmap (GitHub-style) */
.heatmap-wrap {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heatmap-day-labels {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  font-size: 9px;
  color: var(--ink-4);
  padding-top: 16px;
}
.heatmap-day-labels span {
  height: 11px;
  line-height: 11px;
  white-space: nowrap;
}
.heatmap-grid-wrap { flex: 1; }
.heatmap-month-row {
  display: flex;
  font-size: 10px;
  color: var(--ink-3);
  margin-bottom: 4px;
  position: relative;
  height: 12px;
}
.heatmap-month-label {
  position: absolute;
  white-space: nowrap;
}
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
}
.heatmap-cell {
  border-radius: 2px;
  background: var(--surface-3);
}
.heatmap-cell.l1 { background: oklch(0.92 0.06 150); }
.heatmap-cell.l2 { background: oklch(0.82 0.10 150); }
.heatmap-cell.l3 { background: oklch(0.70 0.13 150); }
.heatmap-cell.l4 { background: oklch(0.56 0.16 150); }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 8px;
  justify-content: flex-end;
}
.heatmap-legend .heatmap-cell { width: 11px; height: 11px; }

.token-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 8px;
  justify-content: flex-end;
}
.token-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.token-legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
}

.recharts-tooltip-wrapper { outline: none; }
.stats-tooltip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stats-tooltip .tt-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.stats-tooltip .tt-label { color: var(--ink-3); }
.stats-tooltip .tt-val { font-family: var(--font-mono); color: var(--ink); }

.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  font-size: 12.5px;
}
.bar-row + .bar-row { border-top: 1px solid var(--line); }
.bar-track {
  position: relative;
  height: 18px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  opacity: 0.85;
}
.bar-row .bar-meta {
  text-align: right;
  font-family: var(--font-mono);
  color: var(--ink-3);
}

/* === Add subscription wizard === */
.wizard {
  max-width: 560px;
  margin: 0 auto;
}
.steps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
  font-size: 12px;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-4);
}
.step .num {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
}
.step.done .num { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.step.active { color: var(--ink); }
.step.active .num { border-color: var(--ink); color: var(--ink); }
.step-bar { width: 36px; height: 1px; background: var(--line-2); }
.step.done + .step-bar { background: var(--ink); }

/* === Settings sections === */
.setting-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  align-items: start;
}
.setting-row:first-child { padding-top: 0; }
.setting-row:last-child { border-bottom: none; padding-bottom: 0; }
.setting-row .label-col {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.setting-row .label-col .desc { font-size: 11.5px; color: var(--ink-4); font-weight: 400; margin-top: 3px; line-height: 1.5; }
.codeblock {
  background: var(--ink);
  color: oklch(0.92 0.02 80);
  border-radius: var(--r-sm);
  padding: 16px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  position: relative;
  overflow: auto;
  white-space: pre;
}
.codeblock .k { color: oklch(0.78 0.12 60); }
.codeblock .v { color: oklch(0.85 0.05 200); }
.codeblock .copy {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.codeblock .copy:hover { background: rgba(255,255,255,0.14); color: #fff; }
.danger-card {
  border: 1px solid oklch(0.85 0.08 28);
  background: oklch(0.98 0.02 28);
  border-radius: var(--r-md);
  padding: var(--pad-card);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
}

/* About */
.about-card {
  max-width: 460px;
  margin: 0 auto;
  padding: 36px 32px;
  text-align: center;
}
.about-mark {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: transparent;
  box-shadow: var(--shadow-sm);
}
.about-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.about-name { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.about-version { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.about-desc { color: var(--ink-3); font-size: 13px; line-height: 1.7; margin: 18px 0 22px; }
.about-meta {
  display: flex; justify-content: center; gap: 12px;
  margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-4); font-family: var(--font-mono);
  flex-wrap: wrap;
}
.disclaimer-card {
  max-width: 460px;
  margin: 16px auto 0;
  padding: 18px 22px;
  text-align: left;
}
.disclaimer-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 10px;
}
.disclaimer-card p {
  font-size: 11.5px;
  line-height: 1.7;
  color: var(--ink-3);
  margin: 0 0 8px;
}
.disclaimer-card p:last-child { margin-bottom: 0; }

/* === Onboarding disclaimer (full-screen gate) === */
.onboarding-disclaimer-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--surface-2);
  overflow: auto;
  z-index: 10;
}
.onboarding-disclaimer {
  width: 100%;
  max-width: 560px;
  padding: 36px 40px 32px;
  text-align: left;
}
.onboarding-disclaimer-mark {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 14px;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
}
.onboarding-disclaimer-mark img {
  width: 100%; height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.onboarding-disclaimer-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ink);
}
.onboarding-disclaimer-subtitle {
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  margin: 8px 0 22px;
}
.onboarding-disclaimer-body {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.onboarding-disclaimer-body p {
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
  margin: 0 0 12px;
}
.onboarding-disclaimer-body p:last-child { margin-bottom: 0; }
.onboarding-disclaimer-accept {
  width: 100%;
  justify-content: center;
  padding: 12px 16px;
  margin-top: 24px;
  font-size: 14px;
}

/* small utility */
.flex { display: flex; }
.between { justify-content: space-between; }
.center-y { align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.section { margin-bottom: var(--gap-lg); }

/* === Alerts (block-level notice; replaces .pill abuse) === */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--ink-2);
}
.alert.warn { background: oklch(0.96 0.05 75); border-color: oklch(0.85 0.07 75); color: oklch(0.36 0.13 75); }
.alert.err  { background: var(--err-bg); border-color: oklch(0.82 0.10 28); color: oklch(0.42 0.16 28); }

/* === Empty state inside .card === */
.empty-state {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

/* === Spinner (replaces tailwind animate-spin in components dropping Tailwind) === */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* === Status dot (用于无 pill 的紧凑场景, 见 StatusDot) === */
.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0;
}
.status-dot-ok      { background: var(--ok); }
.status-dot-warn    { background: var(--warn); }
.status-dot-err     { background: var(--err); }
.status-dot-accent  { background: var(--accent); }
.status-dot-neutral { background: var(--ink-4); }

/* === Dialog (Radix overlay 重塑) ===
 * 仅作用于 VirtualModels 添加订阅弹窗等使用 Radix Dialog 的场景。
 * 通过统一类名让浮层视觉与 .card 体系一致。
 */
.cc-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--pad-card);
  font-family: inherit;
}
.cc-dialog-overlay {
  background: rgba(20, 18, 12, 0.32);
  backdrop-filter: blur(2px);
}

/* === Tabs === */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px;
  cursor: pointer;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover:not(.active) { color: var(--ink-2); }
.tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

.brand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
}

/* === Tailwind base override 兼容: 让原 ui/* shadcn 组件颜色仍可读 === */
@layer base {
  body {
    /* 已被上面的全局 body 规则覆盖,但 tailwind 的 bg-background 仍可用 */
  }
}
