/* Codex 管理台 —— 遵循《管理后台前端设计指南》：中性克制，灰阶 + 一个主色，变量化，跟随系统深浅色 */

/* ---------------------------------------------------------------- 变量 */
:root {
  color-scheme: light dark;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f1f1ee;
  --raised: #ffffff;
  --hover: rgba(11, 11, 11, 0.045);
  --press: rgba(11, 11, 11, 0.08);
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --text: #0b0b0b;
  --text-2: #52514e;
  --text-3: #898781;

  --primary: #2a78d6;
  --primary-hover: #256abf;
  --primary-press: #1c5cab;
  --primary-soft: rgba(42, 120, 214, 0.10);
  --primary-track: #cde2fb;
  --on-primary: #ffffff;
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px rgba(42, 120, 214, 0.55);

  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: rgba(12, 163, 12, 0.11);
  --warn: #fab219;
  --warn-text: #7a4f00;
  --warn-soft: rgba(250, 178, 25, 0.18);
  --danger: #d03b3b;
  --danger-text: #b42727;
  --danger-soft: rgba(208, 59, 59, 0.10);
  --info-text: #1c5cab;
  --info-soft: rgba(42, 120, 214, 0.10);

  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --series: #2a78d6;

  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  --ring-pop: 0 0 0 1px var(--border);

  --t-fast: 110ms;
  --t: 180ms;
  --t-slow: 260ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.3, 0, 0.8, 0.15);

  --sidebar: 232px;
  --sidebar-rail: 64px;
  --topbar: 56px;
  --field: 36px;
  --field-font: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --raised: #262624;
    --hover: rgba(255, 255, 255, 0.055);
    --press: rgba(255, 255, 255, 0.09);
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);
    --text: #f0efec;
    --text-2: #c3c2b7;
    --text-3: #898781;

    --primary: #3987e5;
    --primary-hover: #5598e7;
    --primary-press: #6da7ec;
    --primary-soft: rgba(57, 135, 229, 0.16);
    --primary-track: #184f95;
    --focus: 0 0 0 2px var(--surface), 0 0 0 4px rgba(85, 152, 231, 0.7);

    --good-text: #3fbf3f;
    --good-soft: rgba(12, 163, 12, 0.18);
    --warn-text: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.16);
    --danger: #e05252;
    --danger-text: #f07a7a;
    --danger-soft: rgba(224, 82, 82, 0.16);
    --info-text: #86b6ef;
    --info-soft: rgba(57, 135, 229, 0.16);

    --grid: #2c2c2a;
    --axis: #383835;
    --series: #3987e5;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5);
    --ring-pop: 0 0 0 1px var(--border-strong);
  }
}

@media (pointer: coarse) {
  :root { --field: 44px; --field-font: 16px; }
}

/* ---------------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--primary-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.noscript { padding: var(--s6); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 启动与加载 */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  display: inline-block; animation: spin 0.7s linear infinite; opacity: 0.7;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  display: block; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--hover) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.is-refreshing { opacity: 0.55; transition: opacity var(--t) var(--ease); pointer-events: none; }

/* ---------------------------------------------------------------- 外框：侧栏 + 顶栏 + 内容 */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100dvh; }
.app.rail { grid-template-columns: var(--sidebar-rail) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--s1);
  padding: var(--s3) var(--s2) calc(var(--s3) + env(safe-area-inset-bottom));
  border-right: 1px solid var(--border); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; margin-bottom: var(--s2); }
.brand-mark { width: 26px; height: 26px; flex: none; border-radius: 7px; background: var(--primary); display: grid; place-items: center; color: #fff; }
.brand-name { font-weight: 600; font-size: 15px; white-space: nowrap; }
.brand-sub { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border-radius: var(--r-sm); color: var(--text-2); white-space: nowrap; min-width: 0;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a svg { flex: none; }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav a:active { background: var(--press); }
.nav .nav-count { margin-left: auto; font-size: 12px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.rail .brand-text, .rail .nav-label, .rail .nav .nav-count { display: none; }
.rail .brand, .rail .nav a { justify-content: center; padding: 0; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar);
  display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s6);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar .spacer { flex: 1; }
.topbar .menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: var(--s2); color: var(--text-2); font-size: 13px; min-width: 0; }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--text); flex: none; }
.user-chip .who { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }

.content { padding: var(--s6); display: flex; flex-direction: column; gap: var(--s5); min-width: 0; }
.page-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.page-head .lead { color: var(--text-2); font-size: 13px; }
.page-head .grow { flex: 1; }

/* 平板：侧栏收成图标栏 */
@media (max-width: 1024px) {
  .app { grid-template-columns: var(--sidebar-rail) minmax(0, 1fr); }
  .app .brand-text, .app .nav-label, .app .nav .nav-count { display: none; }
  .app .brand, .app .nav a { justify-content: center; padding: 0; }
  .collapse-btn { display: none !important; }
}
/* 手机：单列，导航进抽屉 */
@media (max-width: 720px) {
  .app { display: block; }
  .sidebar { display: none; }
  .topbar { padding: 0 var(--s3); padding-left: max(var(--s3), env(safe-area-inset-left)); gap: var(--s2); transition: transform var(--t) var(--ease); }
  .topbar.hidden { transform: translateY(-100%); }
  .topbar .menu-btn { display: inline-flex; }
  .user-chip .who { display: none; }
  .content { padding: var(--s3); padding-bottom: calc(var(--s6) + env(safe-area-inset-bottom)); gap: var(--s4); }
  .page-head .lead { display: none; }
}

/* 抽屉导航（手机） */
.nav-drawer { position: fixed; inset: 0; z-index: 60; display: flex; }
.nav-drawer .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); animation: fade-in var(--t) var(--ease); }
.nav-drawer .panel {
  position: relative; width: min(280px, 82vw); height: 100dvh; background: var(--surface);
  padding: calc(var(--s3) + env(safe-area-inset-top)) var(--s2) var(--s3); display: flex; flex-direction: column; gap: var(--s1);
  box-shadow: var(--shadow-pop); animation: slide-in-left var(--t-slow) var(--ease);
}
.nav-drawer .nav a { height: 44px; }

/* ---------------------------------------------------------------- 卡片 */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s4) 0; flex-wrap: wrap; }
.card-head h2 { font-size: 14px; }
.card-head .sub { color: var(--text-3); font-size: 12px; }
.card-head .grow { flex: 1; }
.card-body { padding: var(--s4); }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: var(--s4); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid.top { align-items: start; }
@media (max-width: 1100px) { .grid.cols-3-1, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); } }

/* 统计块 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); }
.kpi { padding: var(--s4); display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; white-space: nowrap; }
.kpi .value small { font-size: 14px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.kpi .foot { color: var(--text-3); font-size: 12px; min-height: 18px; }
@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .kpi { padding: var(--s3); }
  .kpi .value { font-size: 20px; }
}

.meter { height: 8px; border-radius: 8px; background: var(--primary-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 8px; background: var(--primary); transition: width var(--t-slow) var(--ease); }
.meter.warn > span { background: var(--warn); }
.meter.danger > span { background: var(--danger); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--field); padding: 0 14px; border-radius: var(--r); border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 500; white-space: nowrap; user-select: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(0.98); background: var(--surface-2); }
.btn:focus-visible { box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-border: transparent; }
.btn.primary:active:not(:disabled) { background: var(--primary-press); }
.btn.danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: transparent; }
.btn.danger:active:not(:disabled) { background: var(--danger-text); }
.btn.ghost { --btn-bg: transparent; --btn-border: transparent; color: var(--text-2); }
.btn.ghost:active:not(:disabled) { background: var(--press); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: var(--field); padding: 0; }
.btn.small.icon { width: 30px; }
.btn .label { transition: opacity var(--t-fast); }
.btn.loading .label, .btn.loading > svg { opacity: 0; }
.btn.loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@media (hover: hover) {
  .btn:hover:not(:disabled) { background: var(--hover); border-color: var(--border-strong); }
  .btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
  .btn.danger:hover:not(:disabled) { background: var(--danger-text); }
  .btn.ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
  .nav a:hover { background: var(--hover); color: var(--text); }
  .nav a[aria-current="page"]:hover { background: var(--primary-soft); color: var(--primary); }
}
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- 表单 */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .field-label { font-size: 13px; font-weight: 500; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--danger-text); min-height: 0; }
.input {
  height: var(--field); width: 100%; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--surface); font-size: var(--field-font);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  appearance: none; -webkit-appearance: none;
}
textarea.input { height: auto; min-height: 72px; padding: 8px 12px; resize: vertical; }
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.mono { font-family: var(--mono); }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > svg { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.input-group > svg ~ .input { padding-left: 34px; }
.input-suffix { position: absolute; right: 10px; color: var(--text-3); font-size: 12px; pointer-events: none; }
.input-group .input.has-suffix { padding-right: 64px; }
input[type="number"]::-webkit-outer-spin-button, input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text); -webkit-box-shadow: 0 0 0 40px var(--surface) inset; transition: background-color 9999s;
}
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
@media (max-width: 720px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--s3); }
.fieldset-head { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.fieldset-head .title { font-weight: 600; font-size: 13px; }
.fieldset-head .grow { flex: 1; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

/* 开关 */
.switch {
  position: relative; width: 36px; height: 20px; flex: none; border-radius: 20px; border: 0; padding: 0;
  background: var(--border-strong); transition: background var(--t) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform var(--t) var(--ease);
}
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:disabled { opacity: 0.5; }
.switch-row { display: flex; align-items: center; gap: var(--s3); }
@media (pointer: coarse) { .switch { width: 44px; height: 26px; } .switch::after { width: 22px; height: 22px; } .switch[aria-checked="true"]::after { transform: translateX(18px); } }

/* 复选框 */
.check { display: inline-flex; align-items: flex-start; gap: var(--s2); cursor: pointer; font-size: 13px; }
.check input { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 2px 0 0; flex: none; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--surface); display: grid; place-items: center; transition: background var(--t-fast); }
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input:focus-visible { box-shadow: var(--focus); }

/* 自定义下拉 */
.select-btn {
  display: inline-flex; align-items: center; gap: var(--s2); height: var(--field); padding: 0 10px 0 12px; min-width: 120px;
  border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface); text-align: left; font-size: var(--field-font);
}
.select-btn .value { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.select-btn .placeholder { color: var(--text-3); }
.select-btn svg { color: var(--text-3); flex: none; transition: transform var(--t-fast); }
.select-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.select-btn[aria-expanded="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.popover {
  position: fixed; z-index: 80; min-width: 180px; max-height: min(320px, 60dvh); overflow-y: auto; padding: 4px;
  background: var(--raised); border-radius: var(--r); box-shadow: var(--shadow-pop), var(--ring-pop);
  animation: pop-in var(--t) var(--ease); transform-origin: top;
}
.option {
  display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 34px; padding: 6px 10px; border: 0;
  background: none; border-radius: var(--r-sm); text-align: left; color: var(--text);
}
.option .check-mark { width: 16px; flex: none; color: var(--primary); visibility: hidden; }
.option[aria-selected="true"] .check-mark { visibility: visible; }
.option[aria-selected="true"] { font-weight: 600; }
.option.active, .option:focus-visible { background: var(--hover); box-shadow: none; }
.option.danger { color: var(--danger-text); }
.option:disabled { opacity: 0.5; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------------------------------------------------------------- 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 22px;
  font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.badge svg { flex: none; }
.badge.good { background: var(--good-soft); color: var(--good-text); }
.badge.warn { background: var(--warn-soft); color: var(--warn-text); }
.badge.danger { background: var(--danger-soft); color: var(--danger-text); }
.badge.info { background: var(--info-soft); color: var(--info-text); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.info .dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---------------------------------------------------------------- 表格（窄容器变卡片） */
.table-wrap { container-type: inline-size; min-width: 0; }
.table-scroll { overflow-x: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 500; color: var(--text-2); white-space: nowrap;
  padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 12px;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; max-width: 280px; }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; }
.table td.r, .table .num { font-variant-numeric: tabular-nums; }
.table tbody tr { transition: background var(--t-fast) var(--ease); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.flash { animation: flash 1.2s var(--ease); }
@keyframes flash { from { background: var(--primary-soft); } to { background: transparent; } }
@media (hover: hover) { .table tbody tr.clickable:hover { background: var(--hover); } }
.cell-main { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cell-sub { color: var(--text-3); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cell-actions { display: flex; gap: 4px; justify-content: flex-end; }
.id-chip { display: inline-flex; align-items: center; gap: 4px; min-width: 0; font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.id-chip .copy { opacity: 0.7; }

@container (max-width: 680px) {
  table.table, .table thead, .table tbody, .table tr, .table td { display: block; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table tbody tr { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 0; max-width: none; text-align: left !important; }
  .table td.c-hide { display: none; }
  .table td[data-label]:not(.c-main):not(.c-side):not(.c-actions)::before { content: attr(data-label) "　"; color: var(--text-3); font-size: 12px; }
  .table td.c-main { grid-column: 1; }
  .table td.c-side { grid-column: 2; grid-row: 1; justify-self: end; }
  .table td.c-actions { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .table td:not(.c-main):not(.c-side):not(.c-actions) { grid-column: 1; font-size: 12px; color: var(--text-2); }
  .table td.c-actions .cell-actions .btn:not(.more) { display: none; }
}

.empty { padding: 40px var(--s4); text-align: center; color: var(--text-2); display: flex; flex-direction: column; gap: var(--s2); align-items: center; }
.empty .title { font-weight: 600; color: var(--text); }
.list-foot { display: flex; justify-content: center; padding: var(--s3); border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- 工具条与筛选 */
.toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.toolbar .search { width: min(320px, 100%); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 26px;
  background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 500; border: 0;
}
.chip button { width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: grid; place-items: center; }
.chip button:active { background: var(--press); }
.summary-line { color: var(--text-2); font-size: 13px; }
.summary-line strong { color: var(--text); font-weight: 600; }
.filter-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--s3); }
@media (max-width: 720px) {
  .toolbar .search { width: auto; flex: 1; }
  .toolbar .search ~ .grow { display: none; }
  .toolbar .hide-mobile { display: none; }
}

/* ---------------------------------------------------------------- 对话框、底部面板、抽屉 */
.overlay { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: var(--s4); }
.overlay .scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); animation: fade-in var(--t) var(--ease); }
.dialog {
  position: relative; width: min(520px, 100%); max-height: min(86dvh, 820px); display: flex; flex-direction: column;
  background: var(--raised); border-radius: var(--r-lg); box-shadow: var(--shadow-pop), var(--ring-pop);
  animation: dialog-in var(--t-slow) var(--ease);
}
.dialog.wide { width: min(720px, 100%); }
.dialog-head { display: flex; align-items: center; gap: var(--s2); padding: var(--s4) var(--s5) 0; }
.dialog-head h2 { font-size: 16px; flex: 1; }
.dialog-body { padding: var(--s4) var(--s5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); }
.dialog-body p { color: var(--text-2); }
.dialog-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: 0 var(--s5) var(--s5); flex-wrap: wrap; }
.overlay.closing .scrim { animation: fade-out var(--t-fast) var(--ease-out) forwards; }
.overlay.closing .dialog, .overlay.closing .drawer { animation: dialog-out var(--t-fast) var(--ease-out) forwards; }

.overlay.side { place-items: stretch; justify-items: end; padding: 0; }
.drawer {
  position: relative; width: min(560px, 100vw); height: 100dvh; background: var(--raised); display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop), var(--ring-pop); animation: slide-in-right var(--t-slow) var(--ease);
}
.overlay.side.closing .drawer { animation: slide-out-right var(--t-fast) var(--ease-out) forwards; }
.drawer .dialog-head { padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.drawer .dialog-body { flex: 1; }

@media (max-width: 720px) {
  .overlay { place-items: end stretch; padding: 0; }
  .dialog, .dialog.wide {
    width: 100%; max-height: 92dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheet-in var(--t-slow) var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dialog::before { content: ""; width: 36px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .dialog-head { padding: var(--s3) var(--s4) 0; }
  .dialog-body { padding: var(--s3) var(--s4); }
  .dialog-foot { padding: 0 var(--s4) var(--s4); }
  .dialog-foot .btn { flex: 1; }
  .overlay.closing .dialog { animation: sheet-out var(--t-fast) var(--ease-out) forwards; }
  .overlay.side { place-items: end stretch; }
  .drawer { width: 100%; height: 94dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation: sheet-in var(--t-slow) var(--ease); }
  .overlay.side.closing .drawer { animation: sheet-out var(--t-fast) var(--ease-out) forwards; }
  .popover.sheet {
    left: 0 !important; right: 0 !important; top: auto !important; bottom: 0 !important; width: 100% !important; max-height: 70dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); animation: sheet-in var(--t) var(--ease);
  }
  .popover.sheet .option { min-height: 44px; font-size: 15px; }
  .sheet-scrim { position: fixed; inset: 0; z-index: 79; background: rgba(0, 0, 0, 0.35); animation: fade-in var(--t) var(--ease); }
}

/* ---------------------------------------------------------------- 描述列表、提示、时间线 */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { min-width: 0; word-break: break-all; }
.section-title { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: none; letter-spacing: 0.02em; }
pre.code {
  margin: 0; padding: var(--s3); border-radius: var(--r); background: var(--surface-2); font: 12px/1.6 var(--mono);
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
.notice { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r); font-size: 13px; align-items: flex-start; }
.notice svg { flex: none; margin-top: 2px; }
.notice.warn { background: var(--warn-soft); color: var(--text); }
.notice.warn svg { color: var(--warn-text); }
.notice.danger { background: var(--danger-soft); color: var(--text); }
.notice.danger svg { color: var(--danger-text); }
.notice.info { background: var(--info-soft); color: var(--text); }
.notice.info svg { color: var(--info-text); }
.notice.good { background: var(--good-soft); }
.notice.good svg { color: var(--good-text); }
.notice .title { font-weight: 600; }
.notice .detail { color: var(--text-2); }
.notice .grow { flex: 1; min-width: 0; }
.checks { display: flex; flex-direction: column; gap: var(--s2); }
.check-row { display: flex; gap: var(--s3); align-items: flex-start; font-size: 13px; padding: 2px 0; }
.check-row .icon { flex: none; margin-top: 1px; }
.check-row .icon.ok { color: var(--good-text); }
.check-row .icon.warn { color: var(--warn-text); }
.check-row .icon.error { color: var(--danger-text); }
.check-row .title { font-weight: 500; }
.check-row .detail { color: var(--text-2); font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: var(--s2); font-size: 13px; }
.timeline time { color: var(--text-3); font-variant-numeric: tabular-nums; }
.secret-box { display: flex; gap: var(--s2); align-items: stretch; }
.secret-box code { flex: 1; min-width: 0; padding: 10px 12px; border-radius: var(--r); background: var(--surface-2); word-break: break-all; font-size: 13px; }

/* ---------------------------------------------------------------- 图表（单系列柱） */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--series); transition: opacity var(--t-fast); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:focus-visible { outline: none; }
.chart .bar.dim { opacity: 0.45; }
.chart .peak { fill: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; padding: 8px 10px; border-radius: var(--r-sm); min-width: 120px;
  background: var(--raised); box-shadow: var(--shadow-pop), var(--ring-pop); font-size: 12px; transform: translate(-50%, calc(-100% - 10px));
  transition: opacity var(--t-fast);
}
.tooltip .t-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tooltip .t-label { color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.tooltip .t-key { width: 10px; height: 2px; border-radius: 2px; background: var(--series); }

/* ---------------------------------------------------------------- 登录 */
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--s4);
  padding-top: max(var(--s4), env(safe-area-inset-top)); padding-bottom: max(var(--s4), env(safe-area-inset-bottom));
}
.login-card { width: min(380px, 100%); padding: var(--s8) var(--s6); display: flex; flex-direction: column; gap: var(--s5); }
.login-card .brand { padding: 0; margin: 0; height: auto; }
.login-card h1 { font-size: 20px; }
.login-card .lead { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.otp {
  height: 52px; text-align: center; font: 600 24px/1 var(--mono); letter-spacing: 0.35em; padding-left: 0.35em;
  font-variant-numeric: tabular-nums;
}
.login-msg { min-height: 20px; font-size: 13px; color: var(--danger-text); }
.login-card .btn { height: 44px; }
@media (max-width: 720px) { .login-card { border: 0; background: transparent; padding: var(--s6) var(--s2); } }

/* ---------------------------------------------------------------- 提示条（Toast） */
.toasts {
  position: fixed; z-index: 100; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--s2); align-items: center; width: min(420px, calc(100vw - 24px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 10px 12px 10px 14px; border-radius: var(--r);
  background: var(--raised); box-shadow: var(--shadow-pop), var(--ring-pop); font-size: 13px; animation: toast-in var(--t) var(--ease);
}
.toast .msg { flex: 1; min-width: 0; }
.toast svg { flex: none; }
.toast.good svg { color: var(--good-text); }
.toast.error svg { color: var(--danger-text); }
.toast.info svg { color: var(--info-text); }
.toast.leaving { animation: toast-out var(--t-fast) var(--ease-out) forwards; }

/* ---------------------------------------------------------------- 动效 */
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes slide-in-right { from { transform: translateX(100%); } }
@keyframes slide-out-right { to { transform: translateX(100%); } }
@keyframes slide-in-left { from { transform: translateX(-100%); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px); } }
.view-enter { animation: fade-in var(--t) var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-property: opacity, background-color, border-color, color !important; }
  .dialog, .drawer, .popover, .toast, .nav-drawer .panel, .popover.sheet { animation: fade-in var(--t) linear !important; }
  .overlay.closing .dialog, .overlay.closing .drawer, .toast.leaving { animation: fade-out var(--t-fast) linear forwards !important; }
  .skeleton { animation: none; }
  .btn:active:not(:disabled) { transform: none; }
}

@media (forced-colors: active) {
  .badge, .chip, .btn { border: 1px solid CanvasText; }
  .chart .bar { fill: CanvasText; }
}
