/* base.css — 设计令牌与公共组件。主对话维护，其他代理只读不改。
   各模块在自己的 css 里加样式，类名必须带模块前缀（ask-、arc-、tbl-、drw-、top-、run-），不得重定义这里的类。 */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2330;
  --muted: #667085;
  --border: #e3e6ec;
  --border-strong: #cfd4dd;
  --accent: #2f6fed;
  --accent-weak: #e8f0ff;
  --red: #d92d20;
  --red-weak: #fdecea;
  --amber: #b54708;
  --amber-weak: #fff3e0;
  --green: #067647;
  --green-weak: #e7f6ee;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1d222c;
    --text: #e7eaf0;
    --muted: #98a2b3;
    --border: #2a303b;
    --border-strong: #3a4250;
    --accent: #6b9bff;
    --accent-weak: #1a2745;
    --red: #ff6b5f;
    --red-weak: #3a1b19;
    --amber: #f5a524;
    --amber-weak: #3a2a10;
    --green: #4cc38a;
    --green-weak: #12301f;
    --shadow: 0 1px 2px 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: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- 页面骨架 ---------- */
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px 56px; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}
.topbar-inner { max-width: 1120px; margin: 0 auto; display: grid; gap: 8px; }
.sec { margin-top: 28px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sec-title { font-size: 18px; font-weight: 650; }
.help { color: var(--muted); font-size: 13px; }
.foot { max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); }

/* ---------- 通用组件 ---------- */
.cards { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: grid; gap: 8px; align-content: start;
  min-width: 0;
}
.card.is-red { border-left: 4px solid var(--red); }
.card.is-warn { border-left: 4px solid var(--amber); }
.card.is-ok { border-left: 4px solid var(--green); }
.card.is-muted { opacity: 0.78; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.row-between { justify-content: space-between; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.wrap-text { overflow-wrap: anywhere; white-space: pre-wrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600;
}
.count.is-red { background: var(--red-weak); color: var(--red); }
.count.is-warn { background: var(--amber-weak); color: var(--amber); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; line-height: 1; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid transparent;
}
.badge-red { background: var(--red-weak); color: var(--red); }
.badge-warn { background: var(--amber-weak); color: var(--amber); }
.badge-ok { background: var(--green-weak); color: var(--green); }
.badge-accent { background: var(--accent-weak); color: var(--accent); }
.badge-outline { background: transparent; border-color: var(--border-strong); }
.provider-badge { background: var(--surface); border-color: var(--border); }
.provider-claude { color: var(--accent); border-color: var(--accent-weak); }
.provider-codex { color: var(--green); border-color: var(--green-weak); }
.provider-dsh { color: var(--amber); border-color: var(--amber-weak); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border-strong);
  cursor: pointer; font-size: 13px; color: var(--text);
}
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip.is-red { border-color: var(--red); color: var(--red); background: var(--red-weak); }

.input, .select {
  height: 32px; padding: 0 10px; min-width: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; width: 100%; }

.empty {
  padding: 18px; border: 1px dashed var(--border-strong); border-radius: var(--radius);
  color: var(--muted); text-align: center;
}
.empty-error { border-color: var(--red); color: var(--red); }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot-ok { background: var(--green); }
.dot-warn { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-pulse { animation: sb-pulse 1.6s ease-in-out infinite; }
@keyframes sb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { position: sticky; top: 0; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

/* ---------- 详情抽屉 ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 18, 24, 0.45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(100vw, 520px);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
  overflow-y: auto; padding: 16px;
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px); z-index: 60;
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok { background: var(--green); color: #fff; }
.toast-warn { background: var(--amber); color: #fff; }
.toast-red { background: var(--red); color: #fff; }

/* ---------- 窄屏 ---------- */
@media (max-width: 640px) {
  .wrap { padding: 0 12px 48px; }
  .topbar { padding: 8px 12px; position: static; }  /* 窄屏顶栏有 4 行，吸顶会占掉大半个屏幕 */
  .cards { grid-template-columns: 1fr; }
  .drawer { width: 100vw; }
  .sec-title { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot-pulse { animation: none; }
  .toast { transition: none; }
}
