/* 两个后台共用的设计系统。
 *
 * 字体不走 Google Fonts：这机器在内网，CDN 拉不到时会先渲染回退字体再跳变，
 * 而且首屏要等超时。系统字体栈够用，中文在 Windows 上落到微软雅黑。
 *
 * 配色取 SaaS 后台标准盘：主色信任蓝 #2563EB、CTA 橙 #F97316、
 * 背景 #F8FAFC、正文 #0F172A（比 #1E293B 对比度更足）、边框 #E2E8F0。
 */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  /* CTA 从 orange-500 压到 orange-700：白字配 #f97316 只有 2.80，
   * 而这几个色值同时用作「软底上的文字」和「白字的底色」两种用法，
   * 两边都要过 AA 4.5。orange-700 白字 5.18。见 scripts/_contrast.py */
  --cta: #c2410c;
  --cta-dark: #9a3412;

  --bg: #f8fafc;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;

  /* 正文 #0F172A、次要 #475569 是浅色模式下的对比度下限，别再调浅 */
  --text: #0f172a;
  --muted: #475569;
  --faint: #64748b;

  /* 状态色全部落在 Tailwind 的 700 档：这三个既当软底上的文字（.pill.ok 等）
   * 又当白字的底色（.s-export、.pub.new 等），两种用法都要过 AA 4.5。
   * 原来的 600 档两边都不过（3.15 / 3.07 / 4.41），全站 452 处对比度失败里
   * 绝大多数就是它们。改后：绿 4.79/5.02、琥珀 4.84、红 5.91。 */
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --run: #2563eb;
  --run-soft: #eff6ff;

  --r: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
  --shadow-lg: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 10px 20px -5px rgba(15, 23, 42, .12);

  --sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI",
          "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  position: sticky; top: 0; z-index: var(--z-chrome, 40);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px; letter-spacing: -.01em;
  color: var(--text); white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); flex: none;
}
.brand .tag {
  padding: 1px 6px; border-radius: 4px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11px; font-weight: 600;
}

.nav { display: flex; gap: 2px; }
.nav a {
  padding: 6px 12px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 500;
  transition: background-color .2s, color .2s;
  cursor: pointer;
  /* 中间宽度（560~700）放不下时链接会在自身内部断行成竖条，
     比整体横滚难看得多。禁断行，溢出交给 topbar 的横滚兜。 */
  white-space: nowrap;
}
.nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* 放不下就横滚。这里管所有页面的中间宽度档（大屏手机横屏/小平板） */
@media (max-width: 760px) {
  .topbar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .topbar .nav, .topbar .right { flex: none; }
}

/* ---------------------------------------------------------------- 通用件 */

.wrap { max-width: 1440px; margin: 0 auto; padding: 20px; }
.wrap.narrow { max-width: 1120px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

.card-h {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.card-h .sub { font-weight: 400; color: var(--faint); font-size: 12.5px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--text); font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background-color .2s, border-color .2s, color .2s;
}
.btn:hover { background: var(--bg); border-color: var(--faint); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.cta { background: var(--cta); border-color: var(--cta); color: #fff; }
.btn.cta:hover { background: var(--cta-dark); border-color: var(--cta-dark); }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok   { background: var(--ok-soft);   color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err  { background: var(--err-soft);  color: var(--err); }
.pill.run  { background: var(--run-soft);  color: var(--run); }
.pill.idle { background: var(--bg);        color: var(--faint); }
/* 多片种矩阵：头任务=链进度，衍生任务=第几棒 */
.pill.mtx  { background: #ede9fe; color: #6d28d9; font-size: 11px; }

/* 运行中的状态点会呼吸，一眼能从静态列表里认出来 */
.pill.run .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.tiny { font-size: 12px; }

.empty {
  padding: 48px 20px; text-align: center; color: var(--faint);
}
.empty svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 10px; }

/* 骨架屏：异步加载时别把界面留白，否则看着像卡死 */
.skel {
  background: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 50%, #eef2f7 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .skel, .pill.run .dot { animation: none; }
  * { transition: none !important; }
}

/* 开关 */
.sw { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--line-strong); border-radius: 999px;
  transition: background-color .2s;
}
.sw span::before {
  content: ""; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
}
.sw input:checked + span { background: var(--ok); }
.sw input:checked + span::before { transform: translateX(18px); }
.sw input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

/* toast */
/* 必须显式压掉：hidden 属性自带的 display:none 是元素默认样式，
 * 优先级低于下面那条 .mask{display:flex}，不写这行抽屉会一进页面就展开。 */
[hidden] { display: none !important; }

/* 提示条必须压过一切：抽屉打开时也会弹（「现在播的是干净版」这类），
 * 排在浮层下面就等于没提示。 */
#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: var(--z-toast, 1300);
  display: flex; flex-direction: column; gap: 8px;
}
#toast div {
  padding: 10px 14px; border-radius: var(--r);
  background: #0f172a; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: rise .2s ease-out;
}
#toast div.err { background: var(--err); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
