/* Kiro 供应层管理面板
   设计令牌全部在 :root；浅色 / 深色跟随系统。中性灰阶 + 一个主色，语义色只用于状态。
   hover 效果只在有鼠标的设备上生效（@media (hover: hover)），触屏上不会"粘住"。 */

:root {
  color-scheme: light dark;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  /* 层级：页面底 < 卡片 < 浮层 */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #eceef2;
  --overlay: #ffffff;
  --border: #e4e6eb;
  --border-strong: #cfd3da;
  --text: #171a1f;
  --text-2: #5b6370;
  --text-3: #868d99;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-press: #3730a3;
  --accent-soft: #eef0fe;
  --accent-text: #ffffff;
  --focus-ring: color-mix(in srgb, var(--accent) 24%, transparent);

  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e1;
  --bad: #c0362c;
  --bad-soft: #fdecea;
  --info: #2563eb;
  --info-soft: #e8f0fe;
  --flash: color-mix(in srgb, var(--accent) 12%, transparent);

  --toast-bg: #1c2028;
  --toast-text: #f1f3f6;
  --toast-border: transparent;

  --shadow-1: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-2: 0 6px 20px rgb(16 24 40 / 0.10), 0 1px 3px rgb(16 24 40 / 0.06);
  --shadow-3: 0 18px 48px rgb(16 24 40 / 0.18), 0 4px 12px rgb(16 24 40 / 0.08);
  --scrim: rgb(15 18 25 / 0.45);

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;

  --sidebar: 228px;
  --rail: 64px;
  --topbar: 56px;

  --dur-fast: 0.12s;
  --dur: 0.2s;
  --dur-slow: 0.28s;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #16191f;
    --surface-2: #1c2027;
    --surface-3: #242932;
    --overlay: #20242c;
    --border: #2a2f39;
    --border-strong: #3b424e;
    --text: #e6e8ec;
    --text-2: #a3abb8;
    --text-3: #757d8a;

    --accent: #8b93f8;
    --accent-hover: #a1a8fa;
    --accent-press: #b6bbfb;
    --accent-soft: #24274a;
    --accent-text: #10122a;

    --ok: #4ade80;
    --ok-soft: #12301f;
    --warn: #fbbf24;
    --warn-soft: #33270d;
    --bad: #f87171;
    --bad-soft: #3a1a18;
    --info: #60a5fa;
    --info-soft: #14274a;

    --toast-bg: #2a2f39;
    --toast-text: #eef0f4;
    --toast-border: #3b424e;

    /* 深色下阴影几乎看不见，浮层靠边框勾勒 */
    --shadow-1: none;
    --shadow-2: 0 8px 24px rgb(0 0 0 / 0.45);
    --shadow-3: 0 18px 48px rgb(0 0 0 / 0.6);
    --scrim: rgb(0 0 0 / 0.6);
  }
}

/* ------------------------------------------------------------------ reset 与原生控件 */

*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: var(--border-strong) transparent; scrollbar-width: thin; }

body {
  margin: 0;
  font: 14px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}

h1, h2, h3, p, dl, dd { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
[hidden] { display: none !important; }
svg { display: block; flex: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; }
input::-webkit-outer-spin-button, input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 覆盖 Chrome 自动填充的黄 / 蓝底色 */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 100px var(--surface) inset;
  transition: background-color 9999s;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.clip { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.two-lines { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack:empty { display: none; }

/* 后台刷新时变化处轻轻高亮 */
.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { from { background-color: var(--flash); } }

/* ------------------------------------------------------------------ 骨架：侧栏 + 顶栏 + 内容区（内容区占满宽度） */

.shell { min-height: 100dvh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 30;
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-right: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + env(safe-area-inset-bottom));
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 6px 16px; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 650; font-size: 15px; line-height: 1.2; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px;
  border-radius: var(--r); color: var(--text-2); font-weight: 500; white-space: nowrap;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.nav a:active { background: var(--surface-3); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; }
.nav .ext { margin-left: auto; width: 14px; height: 14px; opacity: 0.6; }
.nav-sep { height: 1px; background: var(--border); margin: var(--sp-2) 6px; }
.sidebar-foot { margin-top: auto; padding: 10px 6px 2px; font-size: 12px; color: var(--text-3); }

.main { margin-left: var(--sidebar); min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-6);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent; transition: border-color var(--dur);
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.title-hint { display: none; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-meta { text-align: right; line-height: 1.25; min-width: 0; }
.user-name { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.user-ttl { font-size: 12px; color: var(--text-3); white-space: nowrap; }

.content { padding: var(--sp-2) var(--sp-6) 48px; }
.page { display: flex; flex-direction: column; gap: var(--sp-4); animation: page-in var(--dur) var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
.page-intro { color: var(--text-2); max-width: 760px; }

.scrim {
  position: fixed; inset: 0; z-index: 25; background: var(--scrim);
  opacity: 0; pointer-events: none; transition: opacity var(--dur);
}

/* ------------------------------------------------------------------ 卡片 */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--sp-2); padding: 14px var(--sp-4) 0; min-height: 44px; }
.card-head h2 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-head .grow { flex: 1; }
.card-body { padding: 14px var(--sp-4) var(--sp-4); }

/* ------------------------------------------------------------------ 按钮 */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative;
  height: 34px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 500; white-space: nowrap; user-select: none;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform 0.08s, opacity var(--dur-fast);
}
.btn:active { transform: scale(0.97); background: var(--surface-3); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:active { background: var(--accent-press); border-color: var(--accent-press); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:active { background: var(--surface-3); }
.btn.icon { width: 34px; padding: 0; }
.btn.sm { height: 30px; padding: 0 9px; font-size: 13px; }
.btn.sm.icon { width: 30px; padding: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { pointer-events: none; }
/* 加载中：文字隐去、宽度不变 */
.btn.loading { color: transparent !important; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--text-3); border-top-color: transparent; animation: spin 0.7s linear infinite;
}
.btn.primary.loading::after, .btn.danger.solid.loading::after { border-color: currentColor; border-color: var(--accent-text); border-top-color: transparent; }
.btn.danger.solid.loading::after { border-color: #fff; border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn .count { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 11.5px; font-weight: 650; }

/* ------------------------------------------------------------------ 表单 */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-weight: 550; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.field .help { font-size: 12.5px; color: var(--text-2); }
.field .err { font-size: 12.5px; color: var(--bad); }
.field .warn-text { font-size: 12.5px; color: var(--warn); }

.input, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.textarea { height: auto; min-height: 72px; padding: 8px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }
.input:disabled { background: var(--surface-2); color: var(--text-3); }
.input-group { position: relative; display: flex; align-items: center; min-width: 0; }
.input-group .affix { position: absolute; right: 11px; color: var(--text-3); font-size: 13px; pointer-events: none; }
.input-group .prefix { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-group .prefix svg { width: 16px; height: 16px; }
.input-group .prefix ~ .input { padding-left: 32px; }
.input-group .input.has-affix { padding-right: 76px; }
.input-group .input.has-clear { padding-right: 36px; }
.input-clear { position: absolute; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-3); }
.input-clear svg { width: 14px; height: 14px; }

/* 自定义下拉 */
.select { position: relative; min-width: 0; }
.select-btn {
  width: 100%; height: 36px; padding: 0 32px 0 11px; text-align: left; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.select-btn::after {
  content: ""; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
  border-right: 1.5px solid var(--text-2); border-bottom: 1.5px solid var(--text-2); transform: rotate(45deg);
  transition: transform var(--dur-fast);
}
.select.open .select-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.select.open .select-btn::after { transform: rotate(225deg); margin-top: -2px; }
.select-menu, .menu-pop {
  z-index: 60; min-width: 100%; max-height: 300px; overflow: auto; padding: 4px; overscroll-behavior: contain;
  background: var(--overlay); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-2);
  animation: pop-in var(--dur-fast) var(--ease);
}
.select-menu { position: absolute; top: calc(100% + 4px); left: 0; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.select-opt, .menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 34px;
  padding: 0 10px; border: 0; border-radius: var(--r-sm); background: none; color: var(--text); text-align: left; white-space: nowrap;
}
.select-opt { justify-content: space-between; }
.select-opt.active, .menu-item:focus-visible { background: var(--surface-3); outline: none; }
.select-opt[aria-selected="true"] { color: var(--accent); font-weight: 550; }
.select-opt[aria-selected="true"]::after { content: "✓"; font-size: 12px; }

/* "⋯" 菜单：挂在 body 上、按触发按钮定位，表格的圆角裁剪不会挡住它 */
.menu-pop { position: fixed; min-width: 168px; }
.menu-item svg { width: 16px; height: 16px; color: var(--text-3); }
.menu-item.danger, .menu-item.danger svg { color: var(--bad); }
.menu-item:active { background: var(--surface-3); }
.menu-scrim { position: fixed; inset: 0; z-index: 59; }

/* 开关 */
.switch { position: relative; width: 38px; height: 22px; flex: none; border: 0; padding: 0; border-radius: 999px;
  background: var(--border-strong); transition: background var(--dur); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform var(--dur) var(--ease); }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:active::after { width: 21px; }
.switch[aria-checked="true"]:active::after { transform: translateX(13px); }
/* 点击区域不小于 44px：视觉尺寸不变，热区外扩 */
.switch::before { content: ""; position: absolute; inset: -11px -4px; }

/* 徽标：浅底 + 彩色文字，颜色之外还有圆点和文字 */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.live::before { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.tag { display: inline-block; padding: 1px 7px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-family: var(--mono); white-space: nowrap; }

.notice { display: flex; gap: 10px; align-items: center; padding: 10px 12px 10px 14px; border-radius: var(--r);
  background: var(--warn-soft); color: var(--warn); font-size: 13.5px; }
.notice > svg { width: 18px; height: 18px; align-self: flex-start; margin-top: 2px; }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice a { color: inherit; text-decoration: underline; font-weight: 550; }
.notice .notice-text { flex: 1; min-width: 0; }
.notice .btn { flex: none; }

/* 说明气泡：悬停、聚焦、轻触都能打开 */
.hint { position: relative; display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0;
  background: none; color: var(--text-3); border-radius: 50%; vertical-align: middle; }
.hint::before { content: ""; position: absolute; inset: -12px; }
.hint svg { width: 15px; height: 15px; }
.hint-pop {
  position: fixed; z-index: 90; max-width: min(300px, calc(100vw - 24px)); padding: 9px 11px; border-radius: var(--r);
  background: var(--toast-bg); color: var(--toast-text); border: 1px solid var(--toast-border); font-size: 12.5px; font-weight: 400;
  line-height: 1.55; box-shadow: var(--shadow-2); animation: pop-in var(--dur-fast) var(--ease); pointer-events: none; white-space: normal;
}

.empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 44px var(--sp-4); text-align: center; color: var(--text-2); }
.empty > svg { width: 34px; height: 34px; color: var(--text-3); margin-bottom: 4px; }
.empty b { color: var(--text); font-weight: 600; font-size: 14.5px; }
.empty .btn { margin-top: 10px; }

.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.toolbar .grow { flex: 1 1 240px; min-width: 0; }
.toolbar .select { flex: 0 1 150px; }
.mobile-only { display: none !important; }

/* 筛选面板里的选项组 */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font-weight: 500; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip:active { transform: scale(0.97); }

/* ------------------------------------------------------------------ 概览 */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-3); }
.stat { padding: 14px var(--sp-4); }
.stat-label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 4px; }
.stat-value { margin-top: 6px; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums;
  border-radius: var(--r-sm); }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.stat-sub { margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.meter { margin-top: 10px; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 2px; background: var(--accent); transition: width 0.4s var(--ease); }
.meter.hot i { background: var(--bad); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(320px, 2fr); gap: var(--sp-3); align-items: start; }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 168px; padding-top: 4px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.bar-track { flex: 1; width: 100%; max-width: 48px; display: flex; flex-direction: column; justify-content: flex-end; border-radius: var(--r-sm);
  background: var(--surface-2); overflow: hidden; }
.bar-fill { background: var(--accent); transition: height 0.4s var(--ease); }
.bar-fill.fail { background: var(--bad); opacity: 0.85; }
.bar-val { font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; }
.bar-day { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--accent); }
.legend i.fail { background: var(--bad); }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px var(--sp-4); font-size: 13.5px; align-items: center; }
.kv dt { color: var(--text-2); white-space: nowrap; }
.kv dd { min-width: 0; text-align: right; display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.kv.left dd { text-align: left; justify-content: flex-start; }
.kv dd.wrap { display: block; }
.kv .sub { grid-column: 1 / -1; margin-top: -6px; font-size: 12.5px; color: var(--text-3); text-align: right; }

.fail-list { display: flex; flex-direction: column; }
.fail-item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 0; border: 0; border-top: 1px solid var(--border);
  background: none; text-align: left; min-width: 0; }
.fail-item:first-child { border-top: 0; padding-top: 2px; }
.fail-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fail-time { font-size: 12px; color: var(--text-3); white-space: nowrap; }

/* ------------------------------------------------------------------ 表格：按容器宽度先藏次要列，再变卡片 */

.table-wrap { container-type: inline-size; overflow: hidden; transition: opacity var(--dur); }
.table-wrap.dim { opacity: 0.55; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 550; color: var(--text-2); padding: 10px 12px; white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl .actions { display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:active { background: var(--surface-3); }
.tbl .card-cell { display: none; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 12.5px; color: var(--text-3); }
.table-foot { display: flex; justify-content: center; padding: var(--sp-3); border-top: 1px solid var(--border); }

@container (max-width: 1080px) { .tbl .p3 { display: none; } }
@container (max-width: 880px) { .tbl .p2 { display: none; } }
@container (max-width: 640px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr { display: block; }
  .tbl td { display: none; }
  .tbl td.card-cell { display: block; padding: 0; }
  .tbl tr { border-bottom: 1px solid var(--border); }
  .tbl tr:last-child { border-bottom: 0; }
}

/* 卡片形态的一行：三四个关键信息，操作统一进"⋯" */
.crow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px var(--sp-3); padding: var(--sp-3) 14px; align-items: center; }
.crow-title { font-weight: 600; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-side { justify-self: end; display: flex; align-items: center; gap: 6px; }
.crow-sub { font-size: 12.5px; color: var(--text-3); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crow-amount { justify-self: end; font-variant-numeric: tabular-nums; font-weight: 550; white-space: nowrap; }

/* ------------------------------------------------------------------ 上游密钥（可排序） */

.tiers { display: flex; flex-direction: column; }
.tier {
  display: grid; grid-template-columns: auto auto minmax(0, 1.3fr) minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: var(--sp-3) 14px; border-top: 1px solid var(--border); background: var(--surface);
  transition: opacity var(--dur), box-shadow var(--dur-fast);
}
.tier:first-child { border-top: 0; }
.tier.off .tier-name, .tier.off .tier-rank { opacity: 0.5; }
.tier.dragging { opacity: 0.4; }
.tier.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.tier.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.grip { display: grid; place-items: center; width: 26px; height: 36px; color: var(--text-3); cursor: grab; border: 0; background: none;
  border-radius: var(--r-sm); touch-action: none; }
.grip:active { cursor: grabbing; background: var(--surface-3); }
.grip svg { width: 16px; height: 16px; }
.tier-rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 650;
  background: var(--accent-soft); color: var(--accent); font-variant-numeric: tabular-nums; }
.tier-main { min-width: 0; }
.tier-name { font-weight: 600; }
.tier-meta { font-size: 12.5px; color: var(--text-3); display: flex; gap: 8px; align-items: center; min-width: 0; white-space: nowrap; overflow: hidden; }
.tier-meta .note { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tier-health { font-size: 12.5px; color: var(--text-2); min-width: 0; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.tier-health .line { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tier-actions { display: flex; gap: 2px; align-items: center; }
.move-btns { display: none; }

::view-transition-group(*) { animation-duration: var(--dur-slow); animation-timing-function: var(--ease); }

/* ------------------------------------------------------------------ 弹窗 / 抽屉 / 轻提示 */

dialog.modal {
  width: min(480px, calc(100vw - 32px)); max-width: none; max-height: min(86dvh, 720px); padding: 0; border: 1px solid var(--border);
  border-radius: var(--r-xl); background: var(--overlay); color: var(--text); box-shadow: var(--shadow-3); overflow: hidden;
}
dialog.modal[open] { display: flex; flex-direction: column; animation: modal-in var(--dur) var(--ease); }
dialog::backdrop { background: var(--scrim); animation: fade-in var(--dur); }
dialog.closing { animation: fade-out var(--dur-fast) var(--ease-in) forwards !important; }
dialog.closing::backdrop { animation: fade-out var(--dur-fast) var(--ease-in) forwards; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
.modal-form { display: contents; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: var(--sp-4) 18px 4px; }
.modal-head h2 { font-size: 16px; font-weight: 650; flex: 1; min-width: 0; }
.modal-body { padding: 10px 18px 6px; overflow: auto; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.modal-body > p { color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 14px 18px calc(var(--sp-4) + env(safe-area-inset-bottom)); }

.secret { display: flex; gap: var(--sp-2); align-items: stretch; }
.secret code { flex: 1; min-width: 0; padding: 9px 11px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 13px; word-break: break-all; user-select: all; }

dialog.drawer {
  margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(540px, 100vw); max-width: 100vw; padding: 0; border: 0;
  border-left: 1px solid var(--border); background: var(--overlay); color: var(--text); box-shadow: var(--shadow-3);
}
dialog.drawer[open] { display: flex; flex-direction: column; animation: drawer-in var(--dur-slow) var(--ease); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
  padding-top: calc(var(--sp-3) + env(safe-area-inset-top)); }
.drawer-head h2 { font-size: 15px; font-weight: 650; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.drawer-body { flex: 1; overflow: auto; padding: var(--sp-4) var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 20px; overscroll-behavior: contain; }
.section-title { font-size: 12px; font-weight: 600; color: var(--text-3); letter-spacing: 0.04em; margin-bottom: var(--sp-2); }
.codeblock { padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; }
.idval { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; }
.idval .mono { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.steps { display: flex; flex-direction: column; }
.step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 14px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; left: 10px; top: 24px; bottom: 2px; width: 2px; background: var(--border); }
.step:last-child::before { display: none; }
.step-dot { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; font-weight: 650;
  background: var(--surface-2); color: var(--text-2); z-index: 1; }
.step.ok .step-dot { background: var(--ok-soft); color: var(--ok); }
.step.bad .step-dot { background: var(--bad-soft); color: var(--bad); }
.step-title { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; font-weight: 550; min-height: 22px; }
.step-err { margin-top: 6px; }

.toasts { position: fixed; z-index: 100; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--sp-2); align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px); }
.toast { display: flex; align-items: center; gap: var(--sp-2); padding: 10px 14px; border-radius: 10px; background: var(--toast-bg); color: var(--toast-text);
  border: 1px solid var(--toast-border); box-shadow: var(--shadow-2); font-size: 13.5px; animation: toast-in var(--dur) var(--ease);
  pointer-events: auto; max-width: 100%; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity var(--dur-fast) var(--ease-in), transform var(--dur-fast) var(--ease-in); }
.toast svg { width: 16px; height: 16px; }
.toast.ok svg { color: #4ade80; }
.toast.bad svg { color: #f87171; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------------------ 设置（标签在输入框上方） */

.form-card { max-width: 680px; }
.form-fields { display: flex; flex-direction: column; gap: 22px; padding: 18px var(--sp-4) 20px; }
.form-fields .input-group, .form-fields > .field > .input { max-width: 320px; }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.dirty-note { font-size: 12.5px; color: var(--text-2); margin-right: auto; }

/* ------------------------------------------------------------------ 登录页 */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--sp-6) var(--sp-4);
  padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom)); }
.auth-card { width: min(380px, 100%); padding: 28px 26px 24px; display: flex; flex-direction: column; gap: 18px; }
.auth-head { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.auth-head .brand-mark { width: 38px; height: 38px; border-radius: 10px; font-size: 19px; margin-bottom: 8px; }
.auth-head h1 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
.auth-head p { color: var(--text-2); }
.code-input { height: 52px; font-family: var(--mono); font-size: 26px; letter-spacing: 0.32em; text-align: center; padding: 0 0 0 0.32em;
  font-variant-numeric: tabular-nums; }
.auth .btn.primary { height: 44px; font-size: 15px; }
.auth-err { min-height: 20px; font-size: 13px; color: var(--bad); }
.auth-foot { font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ------------------------------------------------------------------ 只给有鼠标的设备的 hover */

@media (hover: hover) {
  .nav a:hover { background: var(--surface-3); color: var(--text); }
  .nav a[aria-current="page"]:hover { background: var(--accent-soft); color: var(--accent); }
  .btn:hover { background: var(--surface-3); }
  .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn.danger:hover { background: var(--bad-soft); }
  .btn.danger.solid:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
  .btn.ghost:hover { background: var(--surface-3); color: var(--text); }
  .btn:disabled:hover { background: var(--surface); }
  .btn.primary:disabled:hover { background: var(--accent); }
  .input:hover, .textarea:hover, .select-btn:hover { border-color: var(--text-3); }
  .input:focus:hover { border-color: var(--accent); }
  .select-opt:hover, .menu-item:hover { background: var(--surface-3); }
  .chip:hover { border-color: var(--text-3); }
  .hint:hover { color: var(--text-2); }
  .input-clear:hover { color: var(--text); background: var(--surface-3); }
  .tbl tbody tr.clickable:hover { background: var(--surface-2); }
  .fail-item:hover .fail-text { color: var(--accent); }
  .grip:hover { color: var(--text-2); background: var(--surface-3); }
}

/* ------------------------------------------------------------------ 平板 / 窄窗口：侧栏收成图标栏 */

@media (min-width: 861px) and (max-width: 1180px) {
  :root { --sidebar: var(--rail); }
  .sidebar { padding-left: 10px; padding-right: 10px; }
  .brand { justify-content: center; padding: 6px 0 16px; }
  .brand-text, .nav .label, .nav .ext, .sidebar-foot { display: none; }
  .nav a { justify-content: center; padding: 0; min-height: 42px; }
  .nav-sep { margin: var(--sp-2) 4px; }
  .content { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .topbar { padding: 0 var(--sp-5); }
}

/* ------------------------------------------------------------------ 手机：单列，导航进抽屉，把空间留给操作 */

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--dur-slow) var(--ease); width: min(280px, 84vw);
    padding-top: calc(var(--sp-3) + env(safe-area-inset-top)); }
  .nav a { min-height: 46px; }
  .shell.nav-open .sidebar { transform: none; box-shadow: var(--shadow-3); }
  .shell.nav-open .scrim { opacity: 1; pointer-events: auto; }
  .main { margin-left: 0; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar { padding: env(safe-area-inset-top) var(--sp-2) 0; height: calc(var(--topbar) + env(safe-area-inset-top)); gap: 4px; }
  .topbar h1 { font-size: 16px; }
  .title-hint { display: inline-grid; }
  .user-meta { display: none; }
  .content { padding: 4px var(--sp-3) 40px; }
  .page { gap: var(--sp-3); }
  .page-intro { display: none; }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex !important; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: var(--sp-3) 14px; }
  .stat-value { font-size: 20px; }
  .card-head { padding: var(--sp-3) 14px 0; }
  .card-body { padding: var(--sp-3) 14px 14px; }
  .bars { height: 140px; gap: 6px; }

  /* 输入框字号不小于 16px，避免 iOS 聚焦时放大页面；点击区域加大 */
  .input, .textarea, .select-btn { font-size: 16px; height: 44px; }
  .textarea { height: auto; }
  .btn { height: 42px; }
  .btn.sm { height: 38px; }
  .btn.icon { width: 42px; }
  .btn.sm.icon { width: 38px; }
  .toolbar .grow { flex: 1 1 0; }
  .form-fields .input-group, .form-fields > .field > .input { max-width: none; }

  .tier { grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px var(--sp-3); padding: var(--sp-3) 14px; }
  .grip, .tier-health .line.counts { display: none; }
  .tier-health { grid-column: 2 / -1; grid-row: 2; }
  .tier-switch { grid-row: 1; grid-column: 3; }
  .tier-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .move-btns { display: flex; gap: 2px; margin-right: auto; }

  /* 弹窗、下拉、"⋯"菜单在手机上都从底部升起 */
  dialog.modal { margin: auto 0 0; width: 100vw; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; border-width: 1px 0 0; }
  dialog.modal[open] { animation: sheet-in var(--dur-slow) var(--ease); }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; height: 46px; }
  dialog.drawer { width: 100vw; border-left: 0; }
  .select-menu, .menu-pop { position: fixed; inset: auto 0 0 0 !important; top: auto !important; max-height: 70dvh; min-width: 0;
    border-radius: var(--r-xl) var(--r-xl) 0 0; padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3);
    animation: sheet-in var(--dur) var(--ease); z-index: 95; }
  .select-opt, .menu-item { min-height: 48px; font-size: 15px; }
  .select.open::before, .menu-scrim { content: ""; position: fixed; inset: 0; background: var(--scrim); z-index: 94; animation: fade-in var(--dur); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

/* 系统开了"减少动态效果"：去掉位移与缩放，只保留淡入淡出 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-property: opacity, color, background-color, border-color, box-shadow !important; scroll-behavior: auto !important; }
  .page, dialog.modal[open], dialog.drawer[open], .select-menu, .menu-pop, .toast, .hint-pop { animation-name: fade-in !important; }
  .btn:active, .chip:active { transform: none; }
  .skel, .badge.live::before { animation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
