/* finagent dashboard — design tokens, components and motion. No build step, no external assets. */

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

  --bg: #f4f3ef;
  --panel: #ffffff;
  --panel-2: #f8f7f4;
  --hover: #efeee9;
  --border: #e5e3dd;
  --border-strong: #d3d1ca;
  --text: #1f2329;
  --text-2: #383d45;
  --muted: #62666e;
  --faint: #73777e;  /* 4.5:1 on white, 4:1 on bg */
  --accent: #3e63dd;
  --accent-2: #7b93e8;
  --accent-soft: rgba(62, 99, 221, 0.08);
  --accent-ring: rgba(62, 99, 221, 0.26);
  --rise: #d9484d;
  --fall: #13804e;
  --rise-soft: rgba(217, 72, 77, 0.09);
  --fall-soft: rgba(19, 128, 78, 0.09);
  /* Status hues are deliberately not the up/down hues: --rise/--fall mean price direction and P&L only. */
  --ok: #0f7b80;
  --ok-soft: rgba(15, 123, 128, 0.09);
  --bad: #b4541a;
  --bad-soft: rgba(180, 84, 26, 0.09);
  --accent-fill: #3e63dd;  /* background under white text */
  --warn: #dd9d26;
  --warn-ink: #a56a10;
  --warn-soft: rgba(221, 157, 38, 0.12);
  --info: var(--accent);
  --info-soft: var(--accent-soft);
  --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.035), 0 1px 3px rgba(31, 35, 41, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(31, 35, 41, 0.07), 0 2px 4px -2px rgba(31, 35, 41, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(31, 35, 41, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
  /* Spacing (multiples of 4) and type scale: new rules use these; older rules move over as they are touched. */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 28px; --fs-hero: 40px;
  --topbar-h: 56px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --chart-1: #4f6fdc;
  --chart-2: #4fb0d8;
  --chart-3: #8a7fd4;
  --chart-4: #2f9e93;
  --chart-5: #d9a24a;
  --chart-6: #6a87b8;
  --chart-7: #c48aac;
  --chart-8: #9aa3ae;
  --chart-cash: #e6e6e1;
  --sky: #3c9fd2;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121417;
  --panel: #181b20;
  --panel-2: #1c2026;
  --hover: #22272e;
  --border: #272c33;
  --border-strong: #353c46;
  --text: #e2e4e8;
  --text-2: #c3c7cd;
  --muted: #959ba5;
  --faint: #777e88;
  --accent: #6f8ff0;
  --accent-2: #9db0f5;
  --accent-soft: rgba(111, 143, 240, 0.12);
  --accent-ring: rgba(111, 143, 240, 0.34);
  --rise: #e86a6c;
  --fall: #43b47c;
  --rise-soft: rgba(232, 106, 108, 0.13);
  --fall-soft: rgba(67, 180, 124, 0.13);
  --ok: #4fb5ba;
  --ok-soft: rgba(79, 181, 186, 0.13);
  --bad: #f0955a;
  --bad-soft: rgba(240, 149, 90, 0.13);
  --accent-fill: #4a68cf;
  --warn: #e0a83e;
  --warn-ink: #e6b55a;
  --warn-soft: rgba(224, 168, 62, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.55);
  --chart-1: #7590ec;
  --chart-2: #5fb6db;
  --chart-3: #9d93e0;
  --chart-4: #46ada2;
  --chart-5: #d8ab5c;
  --chart-6: #7f97c2;
  --chart-7: #c999b6;
  --chart-8: #8b929c;
  --chart-cash: #2b3038;
  --sky: #5ab0dc;
  color-scheme: dark;
}

/* Green-up / red-down (Western convention), per browser. */
:root.green-up { --rise: #13804e; --fall: #d9484d; --rise-soft: rgba(19, 128, 78, 0.09); --fall-soft: rgba(217, 72, 77, 0.09); }
:root[data-theme="dark"].green-up { --rise: #43b47c; --fall: #e86a6c; --rise-soft: rgba(67, 180, 124, 0.13); --fall-soft: rgba(232, 106, 108, 0.13); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
/* scrollIntoView / anchors stop below the sticky top bar (the only sticky layer on phones) */
html { scroll-padding-top: calc(var(--topbar-h) + 8px); }
body {
  font: 14px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
::selection { background: var(--accent-soft); }

/* ------------------------------------------------------------------ shell */
/* Static markup in index.html. Desktop: grouped sidebar + one top bar that carries the page name (pages do not repeat it
   as an h1). Phones: one fixed 48px bar (logo · page name · status · ☰ 菜单); the sidebar becomes a full-screen menu. */
.app { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
  padding: var(--s4) var(--s3); border-right: 1px solid var(--border); background: var(--panel);
}
.side-top { display: flex; align-items: center; gap: var(--s2); padding-bottom: var(--s3); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; color: var(--text); font-weight: 650; font-size: 15px; line-height: 1.25; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand .logo, .m-logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--sky)); box-shadow: 0 3px 8px -4px var(--accent-ring);
}
.brand .logo img, .m-logo img, .login .logo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.brand small { display: block; font-weight: 450; font-size: var(--fs-xs); color: var(--muted); }
.menu-close, .menu-btn, .m-logo { display: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-h { font-size: var(--fs-xs); font-weight: 600; color: var(--faint); padding: var(--s4) 10px var(--s1); }
.nav-h:first-child { padding-top: var(--s1); }
.nav a, .sidebar .nav-link {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; font-size: var(--fs-md);
  color: var(--text-2); font-weight: 500; transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav a:hover, .sidebar .nav-link:hover { background: var(--hover); text-decoration: none; }
.nav a svg, .sidebar .nav-link svg { width: 18px; height: 18px; flex: none; opacity: 0.7; }
.nav a.active, .sidebar .nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active svg, .sidebar .nav-link.active svg { opacity: 1; }
.nav a.active::before, .sidebar .nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); animation: grow-y 0.35s var(--ease);
}
.nav .count { margin-left: auto; font-size: 11px; padding: 0 7px; border-radius: 10px; background: var(--accent-fill); color: #fff; line-height: 18px; }
.sidebar .foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s2); padding-top: var(--s3); border-top: 1px solid var(--border); }
.sidebar .foot .seg { align-self: flex-start; margin-left: 6px; }
.sidebar .foot .seg .lbl { display: none; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--hover); gap: 2px; }
.seg button {
  border: 0; background: transparent; color: var(--muted); padding: 4px 10px; border-radius: 7px; font: inherit; font-size: 12.5px;
  cursor: pointer; transition: all 0.2s var(--ease); display: inline-flex; align-items: center; gap: 5px;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.seg button svg { width: 14px; height: 14px; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); height: var(--topbar-h); padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px); border-bottom: 1px solid transparent; transition: border-color 0.2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
/* the page name: the last crumb is the page title, parents are quiet links */
.crumbs { font-weight: 650; font-size: 17px; display: flex; align-items: center; gap: var(--s2); min-width: 0; overflow: hidden; letter-spacing: -0.01em; }
.crumbs a { color: var(--muted); font-weight: 500; font-size: var(--fs-md); }
.crumbs .sep { color: var(--faint); font-weight: 400; font-size: var(--fs-md); }
.crumbs > * { white-space: nowrap; flex: none; }
.crumbs > :last-child { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.pills { display: flex; flex: none; align-items: center; gap: var(--s2); justify-content: flex-end; }
.clock {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12.5px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.clock > span:first-child { color: var(--text-2); font-weight: 550; }
.clock .mk-open::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); margin-right: 5px; vertical-align: 1px; }
.clock b { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
/* states that change what the Agent may do: amber, one line, never pushes the page */
.state-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 999px; font: inherit; font-size: 12.5px;
  font-weight: 550; white-space: nowrap; border: 1px solid transparent; cursor: pointer; text-decoration: none;
}
.state-chip:hover { text-decoration: none; }
.state-chip svg { width: 13px; height: 13px; flex: none; }
.state-chip.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
.state-chip.warn.soft { background: transparent; }
.state-chip.info { background: var(--accent-soft); color: var(--accent); }
.state-chip .act { padding-left: 8px; margin-left: 2px; border-left: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--text); }
.state-chip .spinner { width: 11px; height: 11px; border-width: 2px; }
main { padding: var(--s2) 28px var(--s7); max-width: 1480px; width: 100%; margin: 0 auto; }
/* one title per page: the top bar names it; a page-head h1 that would repeat it stays hidden (class "keep" opts out) */
main .page-head h1:not(.keep) { display: none; }
main .page-head:not(:has(p, .actions, .keep, .page-status)) { display: none; }

@media (max-width: 900px) {
  :root { --topbar-h: 48px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0; z-index: 50; height: 100dvh; padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
    border: 0; visibility: hidden; opacity: 0; transform: translateY(-8px);
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), visibility 0s linear 0.2s;
  }
  body.menu-open { overflow: hidden; }
  body.menu-open .sidebar { visibility: visible; opacity: 1; transform: none; transition: opacity 0.2s var(--ease), transform 0.2s var(--ease); }
  .side-top { justify-content: space-between; min-height: 40px; }
  .menu-close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--hover); color: var(--text); cursor: pointer; }
  .menu-close svg { width: 20px; height: 20px; }
  .nav a, .sidebar .nav-link { padding: 11px 12px; font-size: 15px; }
  .nav a.active::before, .sidebar .nav-link.active::before { display: none; }
  .sidebar .foot .seg { margin: 4px 0 0; }
  .sidebar .foot .seg .lbl { display: inline; }
  .seg button { padding: 7px 12px; }
  .topbar { padding: 0 12px; gap: var(--s2); }
  .m-logo { display: grid; width: 28px; height: 28px; border-radius: 8px; }
  .crumbs { font-size: 15px; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 10px; margin-right: -4px; border: 1px solid var(--border);
    border-radius: 9px; background: var(--panel); color: var(--text); font: inherit; font-size: var(--fs-sm); font-weight: 550; cursor: pointer;
  }
  .menu-btn svg { width: 16px; height: 16px; }
  .pills { gap: 6px; }
  .pills .long { display: none; }
  .clock { padding: 3px 9px; gap: 5px; font-size: var(--fs-xs); }
  .state-chip { height: 26px; padding: 0 9px; font-size: var(--fs-xs); }
  .state-chip > svg { display: none; }
  main { padding: var(--s3) var(--s4) 40px; }
}
@media (max-width: 560px) {
  .crumbs > a, .crumbs > .sep { display: none; }  /* phones: the page name only; pages carry their own ‹ back link */
  .menu-btn span { display: none; }
  .menu-btn { width: 34px; justify-content: center; padding: 0; }
  .pills .state-chip[data-shell] ~ .state-chip.soft { display: none; }  /* paused says enough; the test-fill chip waits */
}

/* ------------------------------------------------------------------ page + motion */
.page { display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 10px 0 2px; }
.page-head h1 { font-size: 24px; font-weight: 680; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reveal { animation: rise 0.55s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes flash-up { 0% { background: var(--rise-soft); } 100% { background: transparent; } }
@keyframes flash-down { 0% { background: var(--fall-soft); } 100% { background: transparent; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
.flash-up { animation: flash-up 1.2s var(--ease); border-radius: 6px; }
.flash-down { animation: flash-down 1.2s var(--ease); border-radius: 6px; }

/* ------------------------------------------------------------------ grid & cards */
.grid { display: grid; gap: 20px; }
.grid > *, .page > *, main > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease), transform 0.25s var(--ease);
  min-width: 0; position: relative;
}
.card.lift:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 0; min-height: 34px; flex-wrap: wrap; }
.card-head h2 { font-size: 14.5px; font-weight: 620; }
.card-head .desc { color: var(--muted); font-size: 13px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 12px 0 6px; }
.card-head:has(+ .card-body[hidden]:last-child) { padding-bottom: 16px; }  /* a folded card (流程设置) keeps its bottom edge */
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------ KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (min-width: 1360px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } .kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 1100px) { .kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { padding: 18px 20px 16px; overflow: hidden; }
.kpi .label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .label svg { width: 14px; height: 14px; opacity: 0.7; }
.kpi .value { font-size: 25px; font-weight: 680; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .value small { font-size: 13px; font-weight: 550; color: var(--muted); margin-left: 3px; }
.kpi .sub { margin-top: 4px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kpi .spark { position: absolute; right: 14px; top: 16px; width: 60px; height: 26px; opacity: 0.9; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; padding: 1px 7px; border-radius: 6px; }
.delta.up { color: var(--rise); background: var(--rise-soft); }
.delta.down { color: var(--fall); background: var(--fall-soft); }
.delta.flat { color: var(--muted); background: var(--hover); }
.up { color: var(--rise); }
.down { color: var(--fall); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }

/* ------------------------------------------------------------------ badges, chips, codes */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 550; background: var(--hover); color: var(--text-2); white-space: nowrap; line-height: 20px;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
:root[data-theme="dark"] .badge.ok { color: var(--ok); background: var(--ok-soft); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
:root[data-theme="dark"] .badge.bad { color: var(--bad); background: var(--bad-soft); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
:root[data-theme="dark"] .badge.warn { color: var(--warn-ink); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.live .dot { animation: pulse 1.6s infinite; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 550;
  background: var(--hover); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; line-height: 19px;
}
a.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip svg { width: 12px; height: 12px; flex: none; }
/* reason / note tags: words, not codes (the code is in the tooltip); long reasons are cut, the tooltip has them whole */
.code {
  display: inline-block; font-size: 12px; line-height: 18px; padding: 1px 7px; border-radius: 6px; margin: 2px 4px 2px 0;
  background: var(--bad-soft); color: var(--bad); border: 1px solid color-mix(in srgb, var(--bad) 20%, transparent); cursor: help;
  max-width: 15em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
:root[data-theme="dark"] .code { color: var(--bad); }
.code.note { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.sym { font-weight: 650; letter-spacing: 0.01em; }
.sym-badge {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; font-size: 10.5px; font-weight: 700;
  color: var(--text-2); background: var(--panel-2); border: 1px solid var(--border); letter-spacing: 0; flex: none;
}
.sym-badge.long { font-size: 9px; letter-spacing: -0.03em; }  /* four letters fit the 28 px tile */
.agent-badge { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.agent-ico { border-radius: 30%; display: inline-grid; place-items: center; font-style: normal; color: var(--text-2); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--border); font-weight: 700; flex: none; letter-spacing: -0.02em; }

/* ------------------------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font: inherit; font-weight: 550; cursor: pointer;
  transition: transform 0.12s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  white-space: nowrap; box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .switch input:focus-visible + span {
  outline: none; box-shadow: 0 0 0 3px var(--accent-ring);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; box-shadow: 0 2px 6px -2px var(--accent-ring); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent-fill) 88%, #000); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 32%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.busy { pointer-events: none; }
.btn.busy::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 550; color: var(--text-2); min-width: 0; }
label.field .hint { font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 7px 11px; min-height: 36px; width: 100%; transition: border-color 0.2s, box-shadow 0.2s;
}
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
textarea { min-height: 140px; resize: vertical; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }
.row > .btn, .row > .shrink { flex: 0 0 auto; }
.hint { color: var(--muted); font-size: 13px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 500; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch > span:first-of-type {
  position: relative; width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); flex: none;
  transition: background 0.25s var(--ease);
}
.switch > span:first-of-type::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.3s var(--ease-spring);
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch .text small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 12px 12px; text-align: left; vertical-align: middle; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
th {
  font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border); background: var(--panel); position: sticky; top: 0;
}
td { border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tr.link { cursor: pointer; }
tr.link:hover td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 240px; max-width: 520px; }
a.cell-sym { color: var(--text); }
a.cell-sym:hover { text-decoration: none; }
a.cell-sym:hover .sym { color: var(--accent); }
.cell-sym { display: flex; align-items: center; gap: 10px; }
.cell-sym small { display: block; color: var(--muted); font-size: 12px; font-weight: 450; }
.wbar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.wbar .track { display: block; width: 56px; height: 6px; border-radius: 6px; background: var(--hover); overflow: hidden; }
.wbar .fill { display: block; height: 100%; border-radius: 6px; background: var(--accent); transform-origin: left; animation: grow-x 0.9s var(--ease) both; }

/* ------------------------------------------------------------------ empty / skeleton */
.empty { padding: 34px 18px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { width: 34px; height: 34px; opacity: 0.45; }
.skel {
  border-radius: 8px; background: linear-gradient(90deg, var(--hover) 0px, var(--panel-2) 120px, var(--hover) 240px);
  background-size: 800px 100%; animation: shimmer 1.4s infinite linear;
}
.skel-line { height: 12px; margin: 8px 0; }
.skel-block { height: 100%; min-height: 90px; }

/* ------------------------------------------------------------------ charts */
.chart-wrap { position: relative; }
.chart { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 2 4; }
.chart .axis { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .zero { stroke: var(--border-strong); }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.3s var(--ease) forwards; }
.chart .line.bench { stroke-dasharray: 4 4; stroke-width: 1.6; opacity: 0.85; }
.chart .line.bench.draw { stroke-dasharray: none; }
.chart .area { opacity: 0; animation: fade 0.9s var(--ease) 0.35s forwards; }
.chart .area.static, .chart .line.static { animation: none; opacity: 1; }
.chart .cross { stroke: var(--faint); stroke-dasharray: 3 3; pointer-events: none; opacity: 0; transition: opacity 0.15s; }
.chart .cross-dot { pointer-events: none; opacity: 0; transition: opacity 0.15s; stroke: var(--panel); stroke-width: 2; }
.chart-wrap.hover .cross, .chart-wrap.hover .cross-dot { opacity: 1; }
.chart .bar { transform-box: fill-box; transform-origin: bottom; animation: grow-y 0.7s var(--ease) both; }
.chart .bar.neg { transform-origin: top; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 9px 11px; border-radius: 10px; font-size: 12px;
  background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(4px);
  transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.chart-wrap.hover .tip { opacity: 1; transform: none; }
.tip .t { color: var(--muted); margin-bottom: 4px; font-weight: 550; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.tip .r span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.tip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--muted) 0 4px, transparent 4px 7px) !important; }

.donut-wrap { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; justify-content: center; }
.donut { width: 168px; height: 168px; flex: none; }
.donut circle.seg { fill: none; stroke-width: 18; transition: stroke-width 0.25s var(--ease), opacity 0.25s; cursor: pointer;
 }
.donut.hovering circle.seg { opacity: 0.35; }
.donut.hovering circle.seg.on { opacity: 1; stroke-width: 22; }
.donut .c1 { font-size: 11.5px; fill: var(--muted); }
.donut .c2 { font-size: 17px; font-weight: 680; fill: var(--text); }
.donut-legend { display: flex; flex-direction: column; gap: 2px; flex: 1 1 210px; min-width: 0; }
.donut-legend .li { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto auto; gap: 9px; align-items: center; padding: 5px 8px;
  border-radius: 8px; cursor: default; transition: background 0.15s; font-size: 13px; }
.donut-legend .li:hover, .donut-legend .li.on { background: var(--hover); }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .v { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.donut-legend .p { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 48px; text-align: right; }

/* gauges */
.gauges { display: flex; flex-direction: column; gap: 16px; }
.gauge .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13px; }
.gauge .top b { font-variant-numeric: tabular-nums; font-weight: 640; }
.gauge .top .lim { color: var(--muted); font-size: 12px; }
.gauge .track { position: relative; height: 8px; border-radius: 8px; background: var(--hover); margin-top: 7px; }
.gauge .fill { position: absolute; inset: 0 auto 0 0; border-radius: 8px; background: var(--accent); transform-origin: left;
  animation: grow-x 1s var(--ease) both; transition: width 0.6s var(--ease); }
.gauge .fill.warn { background: var(--warn); }
.gauge .fill.bad { background: var(--bad); }
.gauge .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--text-2); opacity: 0.55; }
.gauge .note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ring */
.ring { --p: 0; --c: var(--accent); width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 10.5px;
  font-weight: 650; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--hover) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--panel); }
.ring span { position: relative; }

/* ------------------------------------------------------------------ run stepper & activity */
.stepper { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; position: relative; }
.step { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; position: relative; font-size: 12.5px; color: var(--muted); }
.step::before { content: ""; position: absolute; top: 14px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 2px; background: var(--border); }
.step:first-child::before { display: none; }
.step.done::before, .step.active::before { background: var(--accent); transform-origin: left; }
.step.fresh::before { animation: grow-x 0.5s var(--ease) both; }
.step .ball {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong);
  background: var(--panel); color: var(--faint); font-weight: 650; font-size: 12px; position: relative; z-index: 1;
  transition: all 0.35s var(--ease);
}
.step .ball svg { width: 15px; height: 15px; }
.step.done .ball { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.step.done.fresh .ball { animation: pop 0.4s var(--ease-spring); }
.step.active .ball { border-color: var(--accent); color: var(--accent); }
.step.active .ball::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0.35; animation: pulse-ring 1.6s infinite; }
@keyframes pulse-ring { 0% { transform: scale(0.85); opacity: 0.5; } 100% { transform: scale(1.35); opacity: 0; } }
.step.fail .ball { background: var(--bad); border-color: var(--bad); color: #fff; }
.step.done, .step.active { color: var(--text); font-weight: 550; }
.step small { color: var(--muted); font-weight: 400; font-size: 12px; margin-top: -4px; }

.feed { display: flex; flex-direction: column; }
.feed .item {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) minmax(90px, 26%) 64px; gap: 12px; align-items: center;
  padding: 10px 20px; border-bottom: 1px solid var(--border); animation: slide-in 0.4s var(--ease) both; font-size: 13.5px;
}
.feed .item:last-child { border-bottom: 0; }
.feed .item.static { animation: none; }
.feed .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.feed .ico svg { width: 15px; height: 15px; }
.feed .ico.t-research { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .feed .ico.t-research { color: var(--accent-2); }
.feed .ico.t-market { background: color-mix(in srgb, var(--sky) 12%, transparent); color: var(--sky); }
.feed .ico.t-account { background: var(--warn-soft); color: var(--warn-ink); }
.feed .ico.t-decision { background: var(--accent-soft); color: var(--accent); }
.feed .ico.t-system { background: var(--hover); color: var(--muted); }
.feed .ico.t-bad { background: var(--bad-soft); color: var(--bad); }
.feed .what { min-width: 0; }
.feed .what b { font-weight: 600; }
.feed .what .args { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }
.feed .wf { position: relative; height: 6px; background: var(--hover); border-radius: 6px; }
.feed .wf span { position: absolute; top: 0; bottom: 0; min-width: 3px; border-radius: 6px; background: var(--accent-2); opacity: 0.8; }
.feed .ts { text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* timeline (audit) */
.timeline { list-style: none; margin: 0; padding: 0 18px; position: relative; }
.timeline li { display: grid; grid-template-columns: 22px 120px minmax(0, 1fr); gap: 12px; padding: 9px 0; position: relative; animation: rise 0.4s var(--ease) both; }
.timeline li::before { content: ""; position: absolute; left: 10px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline li:first-child::before { top: 16px; }
.timeline li:last-child::before { bottom: calc(100% - 16px); }
.timeline .node { width: 21px; height: 21px; border-radius: 50%; background: var(--panel); border: 2px solid var(--border-strong); position: relative; z-index: 1; margin-top: 1px; display: grid; place-items: center; }
.timeline .node svg { width: 11px; height: 11px; }
.timeline .node.k-run { border-color: var(--accent); color: var(--accent); }
.timeline .node.k-ok { border-color: var(--ok); color: var(--ok); }
.timeline .node.k-bad { border-color: var(--bad); color: var(--bad); }
.timeline .node.k-warn { border-color: var(--warn); color: var(--warn); }
.timeline .when { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.timeline .body b { font-weight: 600; }
.timeline .payload { color: var(--muted); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* trace chain (order drawer) */
.chain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.chain > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; position: relative; padding-bottom: 22px; animation: rise 0.45s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.chain > li::before { content: ""; position: absolute; left: 16px; top: 34px; bottom: 0; width: 2px; background: var(--border); }
.chain > li:last-child::before { display: none; }
.chain .n svg { width: 17px; height: 17px; }
.chain .n { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chain .n.ok { background: var(--ok-soft); color: var(--ok); }
.chain .n.bad { background: var(--bad-soft); color: var(--bad); }
.chain h3 { font-size: 14px; font-weight: 620; margin: 6px 0 10px; }
/* hashes, ids and session behind one click (order trace, run info) */
details.fp { margin-top: 12px; padding: 6px 12px; background: var(--panel-2); }
details.fp summary { color: var(--muted); font-weight: 500; }
details.fp dl.kv { margin: 8px 0 4px; gap: 6px 14px; font-size: 12.5px; }

dl.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; margin: 0; font-size: 13.5px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ drawer, modal, toast */
.backdrop { position: fixed; inset: 0; background: rgba(10, 13, 19, 0.36); backdrop-filter: blur(2px); z-index: 40; animation: fade 0.25s var(--ease); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 41; background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: drawer-in 0.4s var(--ease);
}
.drawer.closing { animation: drawer-out 0.25s var(--ease) forwards; }
.backdrop.closing { animation: fade 0.25s var(--ease) reverse forwards; }
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes drawer-out { to { transform: translateX(40px); opacity: 0; } }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.drawer header h2 { font-size: 16px; }
.drawer .scroll { overflow-y: auto; padding: 20px; flex: 1; }
@keyframes tick-up { from { background: color-mix(in srgb, var(--rise) 22%, transparent); } to { background: transparent; } }
@keyframes tick-down { from { background: color-mix(in srgb, var(--fall) 22%, transparent); } to { background: transparent; } }
.tick-up { animation: tick-up 0.9s ease-out; }
.tick-down { animation: tick-down 0.9s ease-out; }
.live-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.live-chip.on i { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 15%, transparent); }
.live-chip.off { color: var(--warn-ink); }
.live-chip.off i { background: var(--warn); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: calc(100vw - 40px); }
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 11px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 13px; max-width: 420px; animation: toast-in 0.35s var(--ease-spring);
}
.toast svg { width: 16px; height: 16px; flex: none; }
.toast.err { background: var(--bad); color: #fff; }
.toast.out { animation: toast-out 0.25s var(--ease) forwards; }
@keyframes toast-in { from { transform: translateY(12px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toast-out { to { transform: translateY(8px); opacity: 0; } }

/* ------------------------------------------------------------------ misc components */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--hover); border-radius: 10px; }
.tabs button { white-space: nowrap; border: 0; background: transparent; padding: 4px 11px; border-radius: 7px; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; transition: all 0.2s var(--ease); }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); font-weight: 550; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input[type="search"] { width: 200px; min-height: 32px; padding: 5px 11px; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 11px; background: var(--warn-soft); color: var(--text-2); font-size: 13px; border: 1px solid color-mix(in srgb, var(--warn) 28%, transparent); }
.notice svg { width: 16px; height: 16px; color: var(--warn); flex: none; margin-top: 2px; }
.notice.info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 24%, transparent); }
.notice.info svg { color: var(--info); }
pre.block { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; overflow: auto; max-height: 460px; font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0 0; }
details { border: 1px solid var(--border); border-radius: 11px; padding: 10px 14px; background: var(--panel); }
details + details { margin-top: 10px; }
summary { cursor: pointer; font-weight: 550; display: flex; align-items: center; gap: 8px; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "›"; display: inline-block; transition: transform 0.2s var(--ease); color: var(--muted); font-size: 16px; line-height: 1; }
details[open] summary::before { transform: rotate(90deg); }
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: 14px; padding: 28px; text-align: center; color: var(--muted); cursor: pointer;
  transition: all 0.25s var(--ease); background: var(--panel-2); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.dropzone svg { width: 30px; height: 30px; color: var(--accent); transition: transform 0.3s var(--ease-spring); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text-2); }
.dropzone.over svg { transform: translateY(-4px) scale(1.1); }
.dropzone b { color: var(--text); }
.research-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.research-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; }
.research-card h3 { font-size: 14.5px; font-weight: 620; line-height: 1.4; }
.research-card .preview { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.research-card .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; font-size: 12px; color: var(--muted); }
.split { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

/* ------------------------------------------------------------------ prose (markdown) */
.prose { max-width: 820px; font-size: 14.5px; line-height: 1.75; color: var(--text-2); overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); margin: 1.6em 0 0.6em; line-height: 1.35; }
.prose h1 { font-size: 22px; } .prose h2 { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--border); } .prose h3 { font-size: 15.5px; } .prose h4 { font-size: 14.5px; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0.75em 0; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0.6em 0; }
.prose li { margin: 0.25em 0; }
.prose blockquote { margin: 1em 0; padding: 4px 16px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; color: var(--text-2); }
.prose code { background: var(--hover); padding: 1px 5px; border-radius: 5px; }
.prose pre { background: var(--panel-2); border: 1px solid var(--border); padding: 12px 14px; border-radius: 10px; overflow: auto; font-size: 12.5px; white-space: pre-wrap; overflow-wrap: break-word; }
.prose pre code { background: none; padding: 0; }
.prose table { width: fit-content; max-width: 100%; margin: 1em 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; display: block; overflow-x: auto; }
.prose th, .prose td { white-space: normal; overflow-wrap: break-word; min-width: 3.5em; padding: 7px 12px; font-size: 13px; text-transform: none; letter-spacing: 0; position: static; }  /* not `anywhere`: it shrinks every column to one character and splits numbers */
.prose th { color: var(--text); background: var(--panel-2); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }
.prose a { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ login */
.login { min-height: 70vh; display: grid; place-items: center; }
.login .card { width: min(440px, 100%); padding: 28px; }
.login .logo { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--sky)); margin-bottom: 14px; box-shadow: 0 10px 24px -10px var(--accent-ring); }

/* ------------------------------------------------------------------ market (K-line) */
.market { gap: var(--s4); }
.mk-head { display: flex; align-items: baseline; gap: var(--s2) var(--s5); flex-wrap: wrap; padding-top: var(--s1); }
.mk-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.mk-title h1 { font-size: 24px; font-weight: 680; letter-spacing: -0.01em; }
.mk-name { font-size: var(--fs-md); color: var(--muted); white-space: nowrap; }
.mk-quote { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 550; min-height: 30px; }
.mk-quote .px { font-size: 24px; font-weight: 650; letter-spacing: -0.02em; color: var(--text); }
.mk-hold { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.mk-hold b { color: var(--text); font-weight: 600; }
.mk-hold b.up { color: var(--rise); } .mk-hold b.down { color: var(--fall); }
.mk-search { margin-left: auto; position: relative; width: min(220px, 100%); align-self: center; }
.mk-search svg { position: absolute; left: 11px; top: 50%; width: 15px; height: 15px; transform: translateY(-50%); color: var(--faint); }
.mk-search input { padding-left: 32px; text-transform: uppercase; border-radius: 10px; min-height: 34px; }
.mk-search input::placeholder { text-transform: none; }
.mk-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.mk-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel);
  color: var(--text-2); font-size: var(--fs-sm); font-weight: 550; white-space: nowrap; transition: border-color 0.2s var(--ease), color 0.2s var(--ease); }
.mk-chip:hover { border-color: var(--accent-ring); color: var(--accent); text-decoration: none; }
.mk-chip.on { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); }
.mk-chip .held { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.7; }
/* the side list is as tall as the chart card beside it and scrolls inside */
.mk-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s4); align-items: stretch; }
.mk-side { position: relative; min-width: 0; }
.mk-trades-card { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.mk-trades { flex: 1; min-height: 0; overflow-y: auto; margin-top: var(--s2); border-top: 1px solid var(--border); }
.mk-chart-card { overflow: hidden; }
.mk-toolbar { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4) 0; }
.mk-toolbar .spacer { flex: 1; }
.mk-toolbar select.sm { width: auto; min-height: 0; }
.mk-rg-sel { display: none; }
.tabs.sub button { padding: 3px 9px; font-size: 12px; }
.mk-layers .menu-pop { left: 0; right: auto; min-width: 200px; display: flex; flex-direction: column; gap: 10px; }
.mk-layers summary .lbl { margin-left: 2px; }
.mk-check { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-2); cursor: pointer; user-select: none; white-space: nowrap; }
#mk-src .lbl { white-space: nowrap; }
.mk-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; padding: 10px var(--s4) 0; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 30px; }
.mk-legend b { color: var(--text); font-weight: 600; }
.mk-legend .t { color: var(--text-2); font-weight: 600; }
.mk-legend .ma i { display: inline-block; width: 10px; height: 2px; border-radius: 2px; margin-right: 5px; vertical-align: 3px; }
.mk-legend .mk-rng { margin-left: auto; color: var(--muted); }
.mk-here { display: inline-flex; align-items: center; gap: 5px; color: var(--accent); font-weight: 600; }
.mk-here svg { width: 13px; height: 13px; }
.mk-stage { position: relative; height: 460px; margin: 6px 4px 0; }
/* the zoom helper makes its host position:relative (.cz): keep the chart filling the stage */
.mk-stage > .mk-chart, .mk-stage > .mk-tv { position: absolute; inset: 0; }
.mk-chart.in { animation: chart-in 0.7s var(--ease) both; }
@keyframes chart-in { from { opacity: 0; clip-path: inset(0 100% 0 0); } to { opacity: 1; clip-path: inset(0 0 0 0); } }
.mk-chart.loading { opacity: 0.45; transition: opacity 0.2s; }
.mk-tip { position: absolute; left: 0; top: 0; z-index: 6; width: 290px; padding: 11px 13px; border-radius: 12px; pointer-events: none;
  background: color-mix(in srgb, var(--panel) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 12.5px; transition: transform 0.08s linear; animation: fade 0.15s var(--ease); }
.mk-tip .tip-h { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.mk-tip .tip-h .badge { margin-left: auto; }
.mk-tip p { margin: 7px 0; color: var(--text-2); line-height: 1.5; }
/* indicator readings: one quiet line under the chart (never over it) */
.mk-ind { display: flex; gap: 6px 18px; flex-wrap: wrap; align-items: baseline; padding: 10px var(--s4) 12px; border-top: 1px solid var(--border); margin-top: 6px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.mk-ind .ind b { font-weight: 600; color: var(--text); }
.mk-more { border: 0; padding: 0; background: none; border-radius: 0; }
.mk-more summary { font-size: 12.5px; font-weight: 500; color: var(--accent); }
.mk-more summary::before { display: none; }
.mk-more summary::after { content: " ›"; }
.mk-more[open] { flex-basis: 100%; }
.mk-more[open] summary::after { content: " ‹"; }
.mk-ind-more { display: flex; gap: 6px 18px; flex-wrap: wrap; margin-top: 6px; }
/* the Agent's orders: one line each, the chosen one opens in place */
.tr-list { display: flex; flex-direction: column; }
.tr { position: relative; border-bottom: 1px solid var(--border); }
.tr:last-child { border-bottom: 0; }
.tr.anom::before { content: ""; position: absolute; left: 0; top: 8px; height: 26px; width: 3px; border-radius: 0 3px 3px 0; background: var(--bad); }
.tr-sum { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto 14px; gap: 2px var(--s2); align-items: center; width: 100%; padding: 10px var(--s4) 10px var(--s5);
  border: 0; background: none; font: inherit; font-size: var(--fs-sm); color: var(--text); text-align: left; cursor: pointer; }
.tr-sum:hover, .tr.on .tr-sum { background: var(--panel-2); }
.tr-sum time { color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-what { font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-who { color: var(--muted); font-size: var(--fs-xs); }
.tr-sum .chev { width: 13px; height: 13px; color: var(--faint); transition: transform 0.2s var(--ease); }
.tr.on .chev { transform: rotate(180deg); }
.tr-why { grid-column: 2 / -1; font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-detail { padding: 2px var(--s4) var(--s4) var(--s5); background: var(--panel-2); font-size: var(--fs-sm); animation: fade 0.25s var(--ease); }
.tr-since { margin-bottom: var(--s2); color: var(--text-2); font-variant-numeric: tabular-nums; }
.tr-detail dl.kv { font-size: var(--fs-sm); gap: 6px 12px; }
.tr-text { margin: var(--s2) 0 0; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; }
.tr-text .muted { margin-right: 8px; }
.tr-acts { display: flex; gap: var(--s4); margin-top: var(--s3); }
.mk-none { padding: var(--s4) var(--s5); display: flex; gap: 8px; align-items: center; }
.mk-none svg { width: 15px; height: 15px; flex: none; }
.mk-wait { padding: var(--s5); display: flex; gap: 10px; align-items: center; min-height: 220px; justify-content: center; }
/* company data: one card, four tabs */
.mk-co .card-head .tabs button { font-size: var(--fs-sm); }
.mk-fbody { min-height: 120px; padding-bottom: var(--s2); }
.mk-prof { padding: var(--s4) var(--s5) var(--s3); }
.mk-tags { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s3); }
.mk-kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3) var(--s5); margin: 0; max-width: 900px; }
.mk-kv dt { font-size: var(--fs-xs); color: var(--muted); }
.mk-kv dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.range52 { margin-top: var(--s4); max-width: 560px; }
.range52 .label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.range52 .bar { position: relative; height: 6px; border-radius: 6px; background: var(--hover); }
.range52 .bar i { position: absolute; top: -4px; width: 4px; height: 14px; border-radius: 3px; background: var(--accent); transform: translateX(-2px); }
.range52 .ends { display: flex; justify-content: space-between; font-size: 12px; margin-top: 5px; font-variant-numeric: tabular-nums; }
.desc-more { margin-top: var(--s4); padding: 8px 12px; max-width: 860px; }
.desc-more p { margin: 8px 0 2px; font-size: 13px; line-height: 1.65; color: var(--text-2); }
/* the statement table scrolls sideways with its first column held */
.mk-fund-wrap { margin-top: var(--s2); }
table.fund th { text-transform: none; letter-spacing: 0; }
table.fund td { padding-top: 7px; padding-bottom: 7px; font-size: 13px; }
table.fund th:first-child, table.fund td:first-child { position: sticky; left: 0; z-index: 1; background: var(--panel); color: var(--muted); }
table.fund tbody tr:hover td:first-child { background: var(--panel-2); }
ul.news, ul.filings { list-style: none; margin: 0; padding: 0; }
ul.news li, ul.filings li { padding: 12px 20px; border-bottom: 1px solid var(--border); }
ul.news li:last-child, ul.filings li:last-child { border-bottom: 0; }
ul.news a { color: var(--text); font-weight: 560; line-height: 1.45; }
ul.news a:hover { color: var(--accent); }
ul.news p { margin: 4px 0 0; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
ul.filings li { display: flex; gap: 12px; align-items: flex-start; }
ul.filings .form { flex: none; min-width: 64px; text-align: center; font-family: var(--mono); font-size: 11.5px; font-weight: 600; padding: 2px 6px;
  border-radius: 6px; background: var(--hover); color: var(--text-2); }
@media (max-width: 1180px) {
  .mk-grid { grid-template-columns: minmax(0, 1fr); }
  .mk-trades-card { position: static; max-height: 460px; }
}
@media (max-width: 900px) {
  .mk-head { gap: 2px var(--s3); }
  .mk-search { order: 1; width: 136px; }
  .mk-quote { order: 2; }
  .mk-hold { order: 3; }
  .mk-title h1 { font-size: 20px; }
  .mk-quote .px { font-size: 20px; }
  .mk-hold { flex-basis: 100%; min-height: 20px; }  /* reserved: the holding line arrives with the chart data */
  .mk-toolbar { padding: 10px var(--s3) 0; gap: 6px; }
  .mk-rg { display: none; }
  .mk-rg-sel { display: block; }
  .mk-layers summary .lbl, #mk-src .lbl { display: none; }
  .mk-legend { padding: 8px var(--s3) 0; gap: 4px 10px; font-size: var(--fs-xs); }
  .mk-legend .ohl, .mk-legend .ma, .mk-legend .mk-here { display: none; }
  .mk-stage { height: 340px; margin: 4px 0 0; }
  .mk-ind { padding: 8px var(--s3) 10px; gap: 4px 12px; font-size: var(--fs-xs); }
  .mk-kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mk-prof { padding: var(--s3) var(--s4); }
  .tr-sum { padding: 10px var(--s3) 10px var(--s4); }
  .tr-detail { padding: 2px var(--s3) var(--s3) var(--s4); }
  .mk-co .card-head .tabs { max-width: 100%; overflow-x: auto; }
  ul.news li, ul.filings li { padding: 12px 16px; }
}

/* ------------------------------------------------------------------ main agent chat */
.chat-page { gap: 0; }
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: var(--s4); height: calc(100vh - var(--topbar-h) - 32px); min-height: 520px; }
.chat-list { display: flex; flex-direction: column; overflow: hidden; }
.chat-list-head { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; padding: var(--s3) var(--s3) var(--s2); }
.chat-list-head .tabs button .n { font-size: 11px; color: var(--faint); margin-left: 2px; font-variant-numeric: tabular-nums; }
.chat-search { position: relative; margin: 0 var(--s3) var(--s2); }
.chat-search svg { position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--faint); }
.chat-search input { min-height: 32px; padding: 5px 10px 5px 30px; font-size: var(--fs-sm); border-radius: 9px; }
.chat-sessions { overflow-y: auto; padding: 0 var(--s2) var(--s2); display: flex; flex-direction: column; gap: 1px; border-top: 1px solid var(--border); }
.chat-group { font-size: var(--fs-xs); color: var(--faint); font-weight: 600; padding: var(--s3) 10px var(--s1); }
.chat-none { padding: var(--s4) 10px; }
.chat-item { display: block; padding: 8px 10px; border-radius: 9px; color: var(--text-2); transition: background 0.15s var(--ease); }
.chat-item:hover { background: var(--hover); text-decoration: none; }
.chat-item.on { background: var(--accent-soft); }
.chat-item .t { font-weight: 550; color: var(--text); display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); }
.chat-item .tt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item time { flex: none; font-size: 11.5px; color: var(--faint); font-weight: 400; font-variant-numeric: tabular-nums; }
.chat-item .p { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .src { color: var(--text-2); margin-right: 6px; }
.chat-item .src::after { content: "·"; margin-left: 6px; color: var(--faint); }
.chat-back { display: none; }
.chat-head .sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-compose { display: flex; align-items: flex-end; gap: var(--s2); }
.chat-compose textarea { flex: 1; }
.chat-compose .ch-send { width: 46px; height: 46px; padding: 0; border-radius: 12px; flex: none; }
.chat-compose .ch-send svg { width: 17px; height: 17px; }
.chat-compose #ch-stop { height: 46px; }
/* ⋯ menus (details.menu): a small popover under the button; app.js closes it on an outside click */
details.menu { position: relative; border: 0; padding: 0; background: none; border-radius: 0; }
details.menu > summary { list-style: none; font-size: 16px; letter-spacing: 1px; }
details.menu > summary::before { display: none; }
details.menu .menu-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: max-content; min-width: 220px; max-width: min(340px, 86vw);
  padding: var(--s3); border-radius: 12px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
details.menu .menu-pop dl.kv { gap: 6px 14px; }
details.menu .menu-acts { display: flex; gap: var(--s1); margin-top: var(--s3); padding-top: var(--s2); border-top: 1px solid var(--border); }
details.menu .menu-acts .danger { color: var(--bad); }
.dot.live { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); color: var(--accent); flex: none; animation: pulse 1.6s infinite; }
.chat-main { display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-head .ttl { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text; }
.chat-head .grow > .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-thread { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; scroll-behavior: smooth;
  background: radial-gradient(1200px 400px at 50% -200px, var(--accent-soft), transparent); }
.msg { display: flex; gap: 10px; animation: rise 0.35s var(--ease) both; max-width: 820px; }
.msg.user { flex-direction: column; align-items: flex-end; align-self: flex-end; max-width: min(760px, 86%); }
.msg.user .bubble { background: var(--accent-fill); color: #fff; padding: 10px 14px; border-radius: 16px 16px 4px 16px; white-space: pre-wrap; overflow-wrap: anywhere;
  box-shadow: 0 8px 20px -12px var(--accent-ring); line-height: 1.6; }
.msg.user .faint { margin-top: 3px; }
.msg.bot .col { min-width: 0; flex: 1; }
.msg.bot .body { background: var(--panel); border: 1px solid var(--border); border-radius: 4px 16px 16px 16px; padding: 12px 16px; box-shadow: var(--shadow-sm); }
.msg.bot .meta { margin-top: 4px; padding-left: 4px; }
.msg.bot.failed .body { border-color: color-mix(in srgb, var(--bad) 32%, transparent); }
.md { font-size: 14px; line-height: 1.72; color: var(--text-2); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: 0.55em 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 15px; color: var(--text); margin: 1em 0 0.4em; }
.md ul, .md ol { padding-left: 1.4em; margin: 0.5em 0; }
.md code { background: var(--hover); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--panel-2); border: 1px solid var(--border); padding: 10px 12px; border-radius: 10px; overflow: auto; font-size: 12.5px; }
.md table { display: block; overflow-x: auto; max-width: 100%; margin: 0.8em 0; border: 1px solid var(--border); border-radius: 10px; }
.md th, .md td { white-space: nowrap; padding: 6px 11px; font-size: 12.5px; text-transform: none; letter-spacing: 0; position: static; }
.md th { background: var(--panel-2); color: var(--text); }
.md blockquote { margin: 0.8em 0; padding: 4px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.md + .tool, .tool + .md, .tool + .tool, .run-card + .md, .run-card + .tool, .md + .md { margin-top: 10px; }
details.tool { padding: 0; border-radius: 10px; background: var(--panel-2); overflow: hidden; }
details.tool summary { padding: 7px 11px; font-weight: 500; font-size: 12.5px; gap: 8px; }
details.tool summary::before { display: none; }
details.tool .ti { width: 18px; height: 18px; border-radius: 6px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
details.tool .ti svg { width: 12px; height: 12px; }
details.tool.ok .ti { background: var(--ok-soft); color: var(--ok); }
details.tool.bad .ti { background: var(--bad-soft); color: var(--bad); }
details.tool .args { color: var(--muted); font-family: var(--mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
details.tool pre { margin: 0; padding: 8px 12px; border-top: 1px solid var(--border); font: 11.5px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; color: var(--text-2); }
details.tool pre.out { color: var(--muted); }
.spin { width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.run-card { display: flex; align-items: center; gap: 12px; margin-top: 8px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-soft), transparent); color: var(--text); animation: pop 0.4s var(--ease-spring); }
.run-card:hover { text-decoration: none; box-shadow: 0 8px 20px -12px var(--accent-ring); }
.run-card > svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.run-card .spacer { flex: 1; }
.typing { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.typing .spark { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--accent), var(--accent-2), var(--accent)); animation: spin 1.1s linear infinite;
  mask: radial-gradient(circle, transparent 3px, #000 4px); -webkit-mask: radial-gradient(circle, transparent 3px, #000 4px); }
.typing .dots { display: inline-flex; gap: 4px; }
.typing .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: 0.4; animation: bounce 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: 0.15s; } .typing .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.35; } 40% { transform: translateY(-4px); opacity: 1; } }
.caret { display: inline-block; width: 7px; height: 15px; margin-left: 2px; vertical-align: -2px; background: var(--accent); border-radius: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.chat-warn { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 7px 10px; border-radius: 9px; background: var(--bad-soft); color: var(--bad); font-size: 12.5px; }
.chat-warn svg { width: 14px; height: 14px; flex: none; }
.chat-compose { border-top: 1px solid var(--border); padding: 12px 14px; background: var(--panel); }
.chat-compose textarea { min-height: 46px; max-height: 220px; resize: none; font: 14px/1.55 var(--font); border-radius: 12px; padding: 11px 13px; }
.chat-empty { margin: auto; max-width: 620px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 10px; }
.chat-empty h2 { font-size: 20px; }
.chat-empty p { margin: 0; line-height: 1.7; }
.chat-empty .suggest { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chat-empty .suggest .chip { cursor: pointer; padding: 7px 12px; border-radius: 10px; font-size: 13px; white-space: normal; text-align: left; line-height: 1.45; font-weight: 500; background: var(--panel); transition: all 0.2s var(--ease); }
.chat-empty .suggest .chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ------------------------------------------------------------------ responsive */
/* ------------------------------------------------------------------ 工作流 */
.switch.big > span:first-of-type { transform: scale(1.12); }
.switch.big .text { font-weight: 620; color: var(--text); }
.wf-line { list-style: none; margin: 0; padding: 4px 0 2px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0; }
.wf-step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 6px; min-width: 0; }
.wf-step::before { content: ""; position: absolute; top: 17px; left: calc(-50% + 20px); right: calc(50% + 20px); height: 2px; background: var(--border); }
.wf-step:first-child::before { display: none; }
.wf-step.done::before, .wf-step.running::before, .wf-step.active::before { background: var(--accent); }
.wf-dot { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 2px solid var(--border-strong); color: var(--muted); position: relative; }
.wf-dot svg { width: 16px; height: 16px; }
.wf-step.done .wf-dot { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.wf-step.failed .wf-dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.wf-step.running .wf-dot, .wf-step.active .wf-dot { border-color: var(--accent); color: var(--accent); }
.wf-step.running .wf-dot::after, .wf-step.active .wf-dot::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0.35; animation: pulse-ring 1.6s infinite; }
.wf-step.off .wf-dot, .wf-step.skipped .wf-dot { border-style: dashed; opacity: 0.6; }
.wf-body { display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; max-width: 100%; }
.wf-top { display: flex; flex-direction: column; align-items: center; line-height: 1.3; }
.wf-top b { font-size: 13px; font-weight: 600; }
.wf-runs { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.wf-run { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); color: var(--text-2); text-decoration: none; background: var(--panel-2); }
.wf-run svg { width: 11px; height: 11px; }
.wf-run.failed, .wf-run.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.wf-run.done, .wf-run.no_decision { color: var(--accent); border-color: var(--accent-ring); }
.wf-run .spinner { width: 10px; height: 10px; }
.wf-detail { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-list { display: flex; flex-direction: column; }
.wf-task { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); }
.wf-task .what { flex: 1; min-width: 0; }
.wf-task:first-child { border-top: 0; }
.wf-task .what a { color: var(--text); font-weight: 550; text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-task .what a:hover { color: var(--accent); }
.wf-events { display: flex; flex-direction: column; gap: 8px; }
.wf-ev { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: 10px; align-items: baseline; font-size: 13.5px; padding: 9px 12px; border-radius: 9px; background: var(--panel-2); }
.wf-ev.workflow_paused, .wf-ev.exit_failed, .wf-ev.workflow_slot_failed { background: var(--bad-soft); }
.wf-ev.schedule_skipped, .wf-ev.workflow_limit { background: var(--warn-soft); }
.wf-time { display: flex; align-items: center; gap: 8px; }
.wf-time input[type=time] { flex: 1; min-width: 0; }
.wf-time input:disabled { opacity: 0.45; }
.mini { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 400; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.exit-bar { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.exit-bar .track { position: relative; height: 6px; border-radius: 6px; background: var(--hover); border: 1px solid var(--border); }  /* stop / target are levels: neutral */
.exit-bar .mark { position: absolute; top: -3px; width: 4px; height: 12px; margin-left: -2px; border-radius: 2px; background: var(--text-2); }
.exit-bar .mark.near { background: var(--warn); }

/* ------------------------------------------------------------------ 工作流 · 运行 · 订单 · 绩效 · 设置 (page redesign) */
.side { color: var(--text-2); }
.why { color: var(--bad); }
.why svg, .why-soft svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.why-soft { color: var(--warn-ink); }
.card-head h2 .help, details.fold > summary h2 .help { margin-left: 2px; }
.field-label { display: inline-flex; align-items: center; gap: 2px; }
.unit-in { position: relative; display: block; }
.unit-in input { padding-right: 52px; }
.unit-in .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--fs-xs); font-weight: 450; pointer-events: none; }
tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
td.wrap-note { white-space: normal; min-width: 120px; }
.runs-t th, .pf-agents th { text-transform: none; letter-spacing: 0; }
.runs-t th:last-child { width: 40%; }
.runs-t td.wrap-note .chip { margin-right: 4px; }
.notice.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 24%, transparent); }
.notice.bad svg { color: var(--bad); }
.linkish { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.linkish:hover { text-decoration: underline; text-underline-offset: 3px; }
.linkish.why { color: var(--bad); }
.run-bar { gap: var(--s2) 10px; }
.run-bar b { font-weight: 620; }
#run-alert { display: flex; flex-direction: column; gap: var(--s2); }
#run-alert[hidden] { display: none; }
/* a card that folds: <details class="card fold"><summary><h2>…</h2><span class="desc">…</span></summary>…</details> */
details.card.fold { padding: 0; border-radius: var(--radius); background: var(--panel); }
details.card.fold > summary { padding: var(--s4) 20px; gap: 10px; min-height: 52px; }
details.card.fold > summary h2 { font-size: 14.5px; font-weight: 620; flex: none; display: inline-flex; align-items: center; }
details.card.fold > summary .desc { color: var(--muted); font-size: var(--fs-sm); font-weight: 400; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.card.fold[open] > summary { padding-bottom: var(--s1); }
details.card.fold + details.card.fold { margin-top: 0; }

/* 工作流: 全部系统 — one quiet row per system; the dot carries the state, words only where something needs a look */
.wf-sec { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin: var(--s5) 2px calc(-1 * var(--s1)); }
/* The side gutters are tracks of their own: a subgrid's padding is not counted in the parent's track sizes. */
.sys-list { display: grid; grid-template-columns: 4px 10px max-content minmax(0, 1fr) max-content max-content 10px 4px; column-gap: var(--s4); }
.sys-row { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-items: center;
  padding: 11px 0; color: inherit; border-top: 1px solid var(--border); min-height: 44px; }
.sys-row > :first-child { grid-column: 2; }
.sys-row:first-child { border-top: 0; }
a.sys-row:hover { background: var(--hover); text-decoration: none; }
.sys-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); }
.sys-dot.ok { background: var(--ok); }
.sys-dot.wait { background: var(--accent-2); }
.sys-dot.warn { background: var(--warn); }
.sys-dot.bad { background: var(--bad); }
.sys-name { display: flex; align-items: baseline; gap: var(--s2); min-width: 0; }
.sys-name b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-name small { color: var(--faint); font-size: var(--fs-xs); white-space: nowrap; }
.sys-state { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); }
.sys-state > span:last-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sys-next, .sys-count { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-count { text-align: right; }
.sys-go { color: var(--faint); }
.sys-row.planned .sys-state { grid-column: 4 / -2; }
.sys-row.planned b { color: var(--muted); font-weight: 500; }
@media (max-width: 760px) {
  .sys-list { display: flex; flex-direction: column; }
  .sys-row { grid-template-columns: 10px minmax(0, 1fr) auto; column-gap: var(--s3); row-gap: 2px; padding: 10px 16px; }
  .sys-row > :first-child { grid-column: 1; }
  .sys-row .sys-state { grid-column: 2 / 4; grid-row: 2; }
  .sys-row .sys-next { grid-column: 2 / 4; grid-row: 3; }
  .sys-row .sys-count { grid-column: 3; grid-row: 1; }
  .sys-row .sys-go { display: none; }
  .sys-row.planned .sys-state { grid-column: 2 / 4; grid-row: 2; white-space: normal; }
}

/* 工作流: the automation strip */
.wf-strip { display: flex; align-items: center; gap: var(--s4) var(--s6); flex-wrap: wrap; padding: 18px 20px; }
.wf-strip.on { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); background: linear-gradient(90deg, var(--accent-soft), transparent 55%), var(--panel); }
.wf-state { flex: 1 1 300px; min-width: 0; align-items: center; }
.wf-state .text b { display: block; font-size: var(--fs-lg); font-weight: 640; color: var(--text); }
.wf-state .text small { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; margin-top: 1px; }
.wf-state .text small.why-soft { color: var(--warn-ink); gap: 4px; }
.wf-state .text small svg { width: 12px; height: 12px; }
.wf-stats { display: flex; flex-wrap: wrap; row-gap: var(--s3); }
.wf-stats > * { padding: 0 var(--s5); border-left: 1px solid var(--border); color: inherit; min-width: 88px; }
.wf-stats > :first-child { border-left: 0; padding-left: 0; }
.wf-stats a:hover { text-decoration: none; }
.wf-stats a:hover .k { color: var(--accent); }
.wf-stats .k { font-size: var(--fs-xs); color: var(--muted); }
.wf-stats .v { font-size: 17px; font-weight: 640; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wf-stats .v small { font-size: var(--fs-xs); color: var(--muted); font-weight: 450; margin-left: 3px; }
.wf-stats .v.warn { color: var(--warn-ink); }
.wf-manual { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.wf-pick { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-sm); color: var(--muted); }
.wf-pick select { width: auto; min-width: 190px; }
.wf-manual #wf-busy { display: inline-flex; align-items: center; gap: 6px; }
.wf-manual #wf-busy .spinner { width: 12px; height: 12px; }
details.wf-adv { margin-top: var(--s3); border: 0; padding: 0; background: none; }
details.wf-adv > summary { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; width: fit-content; }
details.wf-adv .row { margin-top: var(--s3); }
.wf-prompt { margin-top: var(--s3); font-size: var(--fs-xs); }

/* 运行详情 */
.run-head { display: flex; gap: var(--s4); align-items: center; flex-wrap: wrap; }
.rh-main { min-width: 0; flex: 1 1 240px; }
.rh-title { font-size: var(--fs-lg); font-weight: 620; }
.rh-end { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.card-foot.why { color: var(--bad); display: flex; align-items: center; gap: 6px; }
.card-foot.why svg { width: 14px; height: 14px; flex: none; }
.dec-sum { font-size: var(--fs-lg); font-weight: 620; line-height: 1.45; }
.dec-view { margin: var(--s2) 0 0; color: var(--text-2); white-space: pre-wrap; line-height: 1.65; }
.dec-refs { margin-top: var(--s3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#run-process .stepper { margin: var(--s2) 0 var(--s1); }
#run-feed { border-top: 1px solid var(--border); }
.run-raw { margin-top: var(--s4); }

/* order rows (订单, 运行详情): a grid on wide screens, a two-line card on phones */
.olist { display: flex; flex-direction: column; }
.orow { --cols: 100px 70px 46px 52px 84px 104px 96px minmax(0, 1fr); display: grid; grid-template-columns: var(--cols); gap: 12px; align-items: center;
  padding: 11px 20px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 13.5px; position: relative; min-width: 0; }
.run-orders .orow { --cols: 70px 46px 52px 84px 84px 104px 48px minmax(0, 1fr); }
.orow:last-child { border-bottom: 0; }
.orow > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orow.head { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); padding-top: 2px; padding-bottom: 8px; }
a.orow { text-decoration: none; transition: background 0.15s var(--ease); }
a.orow:hover { background: var(--panel-2); text-decoration: none; }
.orow.sel { background: var(--accent-soft); }
.orow.bad::before, .orow.warn::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--bad); }
.orow.warn::before { background: var(--warn); }
.orow .num { text-align: right; font-variant-numeric: tabular-nums; }
.orow .c-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.orow .c-note { white-space: normal; line-height: 1.5; font-size: var(--fs-sm); }
.orow .c-note .small { font-size: var(--fs-xs); }
.orow .c-agent .agent-badge { font-weight: 500; gap: 6px; }
.orow .brk, .orow .m-only { display: none; }
.olist-more { padding: 10px 20px 4px; }

/* 订单 */
.ord-sum { display: flex; align-items: center; gap: var(--s2) var(--s5); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.ord-sum b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.ord-sum .spacer { flex: 1; }
.ord-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: var(--s4) 20px var(--s1); }
.ord-search { position: relative; flex: 0 1 220px; min-width: 150px; }
.ord-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.ord-search input { padding-left: 32px; min-height: 34px; }
.ord-bar select { width: auto; min-height: 34px; padding: 5px 30px 5px 11px; }
.ord-bar .spacer { flex: 1; }
.drawer header.dr-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t a" "s a"; gap: 2px var(--s3); align-items: center; }
.dr-head .dr-t { grid-area: t; display: flex; align-items: center; gap: 10px; min-width: 0; }
.dr-head .dr-t h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-head .dr-t .badge { flex: none; }
.dr-head .dr-s { grid-area: s; color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-head .dr-a { grid-area: a; display: flex; gap: 6px; align-items: center; }
.dr-verdict { padding: 14px 16px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--border); margin-bottom: var(--s5); line-height: 1.6; }
.dr-verdict.bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 22%, transparent); }
.dr-verdict.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.dr-verdict .big { font-size: var(--fs-lg); font-weight: 620; display: flex; align-items: center; gap: 6px; }
.dr-verdict .big svg { width: 16px; height: 16px; flex: none; }
.dr-verdict.bad .big { color: var(--bad); }
.dr-verdict.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.dr-verdict.ok .big { color: var(--ok); }
.dr-verdict.warn .big { color: var(--warn-ink); }
.dr-verdict ul { margin: 6px 0 0; padding-left: 1.2em; color: var(--text-2); }
.dr-verdict .muted { margin-top: 2px; }
.drawer .chain h3 { margin-top: 7px; }

/* 绩效 */
.pf-hero { padding: 0; }
.pf-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pf-kpis > div { padding: 18px 22px 16px; border-left: 1px solid var(--border); min-width: 0; }
.pf-kpis > div:first-child { border-left: 0; }
.pf-kpis .k { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 2px; }
.pf-kpis .v { font-size: var(--fs-2xl); font-weight: 660; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; line-height: 1.25; }
.pf-kpis .s { color: var(--muted); font-size: var(--fs-xs); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.pf-more { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); padding: 0; background: none; }
details.pf-more > summary { padding: 10px 22px; font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s4) var(--s5); padding: var(--s1) 22px var(--s4); margin: 0; }
.pf-grid dt { font-size: var(--fs-xs); color: var(--muted); }
.pf-grid dd { margin: 2px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pf-more-foot { padding: 0 22px var(--s4); }
.pf-agents td { vertical-align: middle; }
.pf-agents .pnl { min-width: 150px; }
.pf-agents .pnl b { font-weight: 640; font-size: 14px; }
.pbar { display: block; position: relative; height: 4px; margin-top: 6px; border-radius: 4px; background: var(--hover); }
.pbar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--muted); opacity: 0.55; }
.pbar .z { position: absolute; top: -3px; bottom: -3px; width: 1px; background: var(--border-strong); }

/* 设置 */
.set-layout { display: grid; grid-template-columns: 156px minmax(0, 760px); gap: var(--s6); align-items: start; }
.set-nav { position: sticky; top: calc(var(--topbar-h) + 12px); display: flex; flex-direction: column; gap: 2px; padding-top: 2px; }
.set-nav button { text-align: left; border: 0; background: none; font: inherit; font-size: 13.5px; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.set-nav button:hover { background: var(--hover); color: var(--text); }
.set-nav button.on { color: var(--accent); background: var(--accent-soft); font-weight: 550; }
.set-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.set-sec { scroll-margin-top: calc(var(--topbar-h) + 12px); }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4) 18px; }
.set-grid .full { grid-column: 1 / -1; }
.set-agent { display: grid; grid-template-columns: 70px minmax(0, 1fr) 130px; gap: var(--s3); align-items: center; }
.set-agent + .set-agent { margin-top: var(--s3); }
.set-agent b { font-weight: 600; }
.set-line { display: flex; align-items: center; gap: var(--s2) var(--s3); flex-wrap: wrap; }
.set-line .spacer { flex: 1; }
.set-status { display: flex; align-items: center; gap: var(--s2); font-weight: 550; }
.set-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.set-status.ok::before { background: var(--ok); }
.set-status.warn::before { background: var(--warn); }
.set-status.bad::before { background: var(--bad); }
.set-sub { color: var(--muted); font-size: var(--fs-xs); font-weight: 400; }
.set-sec details { background: var(--panel-2); }
.set-sec details[open] > summary { margin-bottom: 10px; }
.set-diag { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-xs); color: var(--muted); }
.set-diag .split > :last-child { white-space: nowrap; }
.set-prompts details { background: var(--panel); }
.set-prompts summary .muted { font-weight: 400; font-size: var(--fs-sm); }
.set-prompts details details { margin-top: 8px; background: var(--panel-2); }
.savebar { position: sticky; bottom: var(--s4); z-index: 25; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-radius: 12px;
  background: var(--panel); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); max-width: 760px; margin: 0 0 0 calc(156px + var(--s6)); animation: rise 0.3s var(--ease); }
.savebar .spacer { flex: 1; }
.savebar b { font-weight: 600; }
@media (max-width: 1100px) {
  .pf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pf-kpis > div:nth-child(3) { border-left: 0; }
  .pf-kpis > div:nth-child(n + 3) { border-top: 1px solid var(--border); }
}
@media (max-width: 900px) {
  .wf-stats { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .wf-stats > * { padding: 0 var(--s2); min-width: 0; }
  .wf-stats .v { font-size: 15px; }
  .wf-pick select { min-width: 0; }
  .wf-pick { flex: 1 1 200px; }
  .wf-pick select { flex: 1; }
  .set-layout { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .set-nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .set-nav button { flex: none; padding: 6px 11px; background: var(--hover); border-radius: 999px; font-size: var(--fs-sm); }
  .set-grid { grid-template-columns: minmax(0, 1fr); }
  .set-agent { grid-template-columns: minmax(0, 1fr) 110px; }
  .set-agent b { grid-column: 1 / -1; }
  .savebar { margin-left: 0; bottom: var(--s3); }
  .pf-kpis > div { padding: 14px 16px 12px; }
  .pf-kpis .v { font-size: 22px; }
  details.pf-more > summary, .pf-grid, .pf-more-foot { padding-left: 16px; padding-right: 16px; }
  .pf-agents .opt { display: none; }
  .pf-agents .pnl { min-width: 110px; }
  .ord-bar { padding: var(--s3) 16px var(--s1); }
  .ord-search { flex: 1 1 100%; }
  .ord-bar select { flex: 1 1 0; min-width: 0; padding: 4px 22px 4px 9px; font-size: var(--fs-sm); background-position: right 6px center; }
  .ord-bar .spacer { display: none; }
  .ord-bar #ord-csv .lbl { display: none; }
  details.card.fold > summary { flex-wrap: wrap; row-gap: 2px; }
  details.card.fold > summary .desc { white-space: normal; flex-basis: 100%; padding-left: 18px; }
  .set-grid.nums { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
}
@media (max-width: 720px) {
  .orow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; padding: 12px 16px; }
  .orow.head { display: none; }
  .orow > * { overflow: visible; }
  .orow .m-hide, .orow .d-only { display: none; }
  .orow .m-only { display: inline; }
  .orow .num { text-align: left; }
  .orow .c-sym { order: 1; font-size: 14.5px; }
  .orow .c-side { order: 2; }
  .orow .c-qty { order: 3; }
  .orow .c-qty::after { content: " 股"; color: var(--muted); }
  .orow .c-px { display: none; }
  .orow .c-amt { order: 4; margin-left: auto; font-weight: 600; }
  .orow .brk { display: block; order: 5; flex-basis: 100%; height: 0; }
  .orow .c-time { order: 6; font-size: var(--fs-xs); }
  .orow .c-agent { order: 7; font-size: var(--fs-xs); color: var(--muted); }
  .orow .c-agent .agent-ico { display: none; }
  .orow .c-agent .agent-badge { font-weight: 400; }
  .orow .c-note { order: 8; flex-basis: 100%; font-size: var(--fs-xs); }
  .orow .c-note:empty { display: none; }
  .dr-head .dr-a .lbl { display: none; }
  .drawer header.dr-head { padding: 12px 16px; }
  .run-bar .lbl { display: none; }
  .m-hide { display: none !important; }
  .near-stop { color: var(--warn-ink); }
  .orow .np { display: none; }
  /* runs table → two-line cards: agent · fills · time on top, start time and note below */
  .runs-t thead { display: none; }
  .runs-t, .runs-t tbody { display: block; }
  .runs-t tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
  .runs-t tr:last-child { border-bottom: 0; }
  .runs-t td { border: 0; padding: 0 !important; white-space: nowrap; }
  .runs-t td.r-agent { order: 1; }
  .runs-t td.r-fill { order: 2; margin-left: auto; }
  .runs-t td.r-fill::before { content: "成交 "; color: var(--muted); font-size: var(--fs-xs); }
  .runs-t td.r-fill.none { display: none; }
  .runs-t td.r-fill.none + td.r-dur { margin-left: auto; }
  .runs-t td.r-dur { order: 3; color: var(--muted); }
  .runs-t td.r-brk { order: 4; flex-basis: 100%; height: 0; }
  .runs-t td.r-time { order: 5; font-size: var(--fs-xs); }
  .runs-t td.r-note { order: 6; min-width: 0; font-size: var(--fs-xs); white-space: normal; }
  .runs-t tr.row-bad { box-shadow: inset 3px 0 0 var(--bad); }
  .runs-t tr.row-bad td:first-child { box-shadow: none; }
}
.runs-t td.r-brk { display: none; }
@media (max-width: 720px) { .runs-t td.r-brk { display: block; } }
/* phones: ⓘ bubbles span the screen width under the icon (shared .help rule + app.js clampHelp) */

/* ------------------------------------------------------------------ 研究终端 */
.term-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.term-tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--hover); }
.term-tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 550; font-size: 13px; white-space: nowrap; }
.term-tabs a svg { width: 14px; height: 14px; }
.term-tabs a:hover { color: var(--text); }
.term-tabs a.on { background: var(--panel); color: var(--accent); box-shadow: var(--shadow-sm); }
.term-session { display: flex; align-items: center; gap: 8px; }
.term { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; align-items: start; }
.term-nav { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; padding: 4px 0; scrollbar-width: thin; }
/* the rail (terminal.js): 研究 / 交易 sections, folding groups with icons (the open page's group open), one-page groups as plain links */
.term-sname { font-size: 11px; font-weight: 600; color: var(--faint); padding: 0 12px 6px; }
.term-sec + .term-sec { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.term-link { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 9px; color: var(--text-2); text-decoration: none; font-size: 13.5px; }
.term-link > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-link svg, .term-gname svg { width: 15px; height: 15px; flex: none; color: var(--muted); }
.term-link:hover { background: var(--hover); text-decoration: none; }
.term-link.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.term-link.on svg { color: var(--accent); }
.term-link .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); flex: none; }
.term-link .dot.bad { background: var(--bad); } .term-link .dot.warn { background: var(--warn); }
.term-gname { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 12px; border: 0; border-radius: 9px; background: none; font: inherit;
  font-size: 13.5px; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.term-gname:hover { background: var(--hover); }
.term-gname > span { flex: 1; min-width: 0; }
.term-chev { width: 6px; height: 6px; border: solid var(--faint); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); margin: 0 3px 0 2px; transition: transform 0.15s var(--ease); flex: none; }
.term-group.open .term-chev { transform: rotate(45deg); }
.term-glinks { display: none; padding: 1px 0 4px; }
.term-group.open .term-glinks { display: block; }
.term-glinks .term-link { padding-left: 35px; font-size: 13px; }
.term-pick { display: none; gap: 8px; }
.term-pick select { min-width: 0; }
.term-mselect { flex: 0 0 auto; width: auto; }
.term-select { flex: 1; width: 100%; }
.term-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; container: term-main / inline-size; }
.term-doc .term-tbl { overflow-x: auto; max-width: 100%; }
/* The site sizes its iframe box (.x-embed: fixed height, overflow hidden); our redrawn apps replace the iframe and set their own height.
   The id keeps this above the mirrored site sheet, which loads later. */
#term-main .x-embed:has(.of-app) { height: auto; overflow: visible; }

/* the synced page: site classes arrive as x-<class> (and xm-<part> for CSS-module classes) */
.term-doc { display: flex; flex-direction: column; gap: 16px; color: var(--text-2); font-size: 14px; line-height: 1.6; min-width: 0; }
/* Site theme variables used by synced inline styles (site.css maps the rest); bullish = --rise per the user's colour setting. */
.term-doc { --supportive: var(--rise); --pressure: var(--fall); --cinnabar: var(--fall); --mixed: var(--muted); --acc: var(--accent);
  --acc-bright: var(--accent); --acc-soft: var(--accent-soft); --sub: var(--muted); --line: var(--border); --card: var(--panel); --card-2: var(--panel-2); }
.term-doc h1 { font-size: 24px; font-weight: 680; color: var(--text); letter-spacing: -0.01em; }
.term-doc h2 { font-size: 16px; font-weight: 640; color: var(--text); }
.term-doc a { color: var(--accent); }
.x-pagehead { padding: 4px 0 2px; }
.x-pagehead .x-sub { color: var(--muted); margin-top: 6px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.x-tag, .xm-tag { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.x-panel, .xm-hero, .tc-panel, .tc-generic { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.x-blocklabel { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 640; color: var(--text); margin-bottom: 4px; }
.x-blocklabel + div:not([class]) { color: var(--muted); font-size: 13px; }  /* a card's intro line (kit foldFine moves most into the ⓘ) */
.x-s-sec { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 4px; }
.x-s-item { padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }  /* rows with hairlines, as the site draws them */
.x-s-item:last-child { border-bottom: 0; }
#term-main .x-panel > .x-blocklabel:first-child { margin-top: 2px; }  /* the site sheet's 38px label gap is meant between blocks, not under a card's top edge */
.x-s-item .x-top, .x-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.x-lbl { color: var(--muted); font-size: 12.5px; }
.x-val { font-weight: 680; font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.x-ctx { color: var(--muted); font-size: 12px; margin-top: 4px; }
.x-num { font-variant-numeric: tabular-nums; }
.x-muted { color: var(--muted); }
.x-risk { margin-top: 18px; font-size: 11px; line-height: 1.8; color: var(--faint); border-top: 1px solid var(--border); padding-top: 14px; }
.xm-heroLab { color: var(--muted); font-size: 12px; font-weight: 600; }
.xm-heroName { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 12px; }
.xm-heroName b { font-size: 30px; font-weight: 700; color: var(--text); }
.xm-heroName span { color: var(--muted); }
.xm-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.xm-kpi .x-k { color: var(--muted); font-size: 12px; }
.xm-kpi .x-v { font-size: 22px; font-weight: 680; color: var(--text); font-variant-numeric: tabular-nums; }
.xm-kpi .x-n { color: var(--faint); font-size: 12px; }
.xm-leader { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 13px; }
.xm-tk { font-weight: 650; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 7px; }
.xm-sechd { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.xm-sechd span { color: var(--muted); font-size: 12.5px; }
.xm-rows { display: flex; flex-direction: column; gap: 8px; }
.xm-row { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.xm-row.xm-main { border-color: var(--accent-ring); box-shadow: 0 0 0 3px var(--accent-soft); }
.xm-top { display: flex; align-items: center; gap: 10px; }
.xm-rk { color: var(--faint); font-variant-numeric: tabular-nums; width: 18px; }
.xm-nm { font-weight: 620; color: var(--text); flex: 1; min-width: 0; }
.xm-nm span { color: var(--faint); font-weight: 400; margin-left: 6px; font-size: 12px; }
.xm-sc { font-weight: 680; font-variant-numeric: tabular-nums; color: var(--text); }
.xm-bar { height: 6px; border-radius: 6px; background: var(--hover); margin: 7px 0; overflow: hidden; }
.xm-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.xm-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.xm-life { padding: 0 7px; border-radius: 6px; border: 1px solid var(--border); }
.xm-gates { display: inline-flex; gap: 3px; }
.xm-gate { width: 17px; height: 17px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 10.5px; background: var(--hover); color: var(--faint); }
.xm-gate.xm-ok { background: var(--accent-soft); color: var(--accent); }
.xm-up { color: var(--rise); } .xm-down { color: var(--fall); } .xm-flat { color: var(--muted); }
.term-doc table { border-collapse: collapse; width: 100%; font-size: 13px; }
.term-doc th, .term-doc td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }

/* client components re-drawn from their props */
.tc-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.tc-head b { color: var(--text); font-weight: 640; }
.tc-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tc-big { font-size: 26px; font-weight: 700; color: var(--text); }
.tc-big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.tc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.tc-inout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tc-inout .chip { margin: 4px 4px 0 0; }
.tc-mover, .tc-heat { display: grid; grid-template-columns: 52px minmax(0, 1fr) 90px 64px; gap: 8px; align-items: center; padding: 4px 0; font-size: 13px; }
.tc-heat { grid-template-columns: 26px minmax(80px, 1fr) 72px minmax(80px, 1.4fr) 48px 60px; }
.tc-mover .faint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tc-mbar { display: block; height: 7px; border-radius: 7px; background: var(--hover); overflow: hidden; }
.tc-mbar i { display: block; height: 100%; border-radius: 7px; background: var(--accent); }
.tc-mbar.up i { background: var(--rise); } .tc-mbar.down i { background: var(--fall); }
.tc-chart { min-height: 200px; }
.tc-kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; margin: 6px 0 10px; }
.tc-kv > div { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.tc-sub { border-top: 1px solid var(--border); padding: 8px 0; }
.tc-sub > summary { cursor: pointer; }
.tc-table td, .tc-table th { white-space: nowrap; }
.tc-intro { margin: 0; max-width: 860px; font-size: 13px; line-height: 1.75; color: var(--muted); }
.term-doc > .x-pagehead + .tc-intro { margin-top: -8px; }  /* a subtitle of the page head */
.tc-feed { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* one reading column: ‹ 上一篇 · the full list in a dropdown · 下一篇 › above the article (kit artNav) */
.tc-reader { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 30px 28px; min-width: 0; }
.tc-reader h2 { font-size: 22px; margin: 6px 0 14px; line-height: 1.4; max-width: 720px; }
.tc-reader .tc-chips { margin: 0 0 14px; }
.tc-reader .prose { max-width: 720px; font-size: 15px; line-height: 1.8; }
.tc-reader .prose pre { font: 13px/1.85 var(--font); padding: 14px 18px; border-left: 3px solid var(--border-strong); }  /* the reports use fences for price maps and plans, not code: the site reads them as prose */
.term-ai .prose { max-width: none; }
.term-ai .ai-body.clamp { max-height: 260px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.term-ai .ai-more { margin-top: 6px; }
.gex-wrap { position: relative; }
.gex-wrap canvas { display: block; border-radius: 8px; }
.gex-tip { min-height: 18px; margin-top: 6px; font-family: var(--mono); }
select.sm { height: 28px; padding: 0 8px; font-size: 12.5px; border-radius: 8px; }
/* 订单流 (orderflow.js) */
.of-app { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); min-width: 0; margin-top: 14px; }
.of-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 8px; }
.of-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.of-ctl input[type=date] { height: 28px; padding: 0 8px; font-size: 12.5px; border-radius: 8px; }
.of-sets { display: inline-flex; flex-wrap: wrap; gap: 4px 10px; }
.of-price b { font-family: var(--mono); font-size: 15px; }
.of-note .notice { margin: 0 0 8px; }
.of-legend { min-height: 20px; display: flex; flex-wrap: wrap; gap: 2px 14px; font-family: var(--mono); margin-bottom: 4px; }
.of-lg { white-space: nowrap; }
.of-chart { position: relative; height: 380px; width: 100%; }
.of-chart.of-tall { height: 560px; }
.of-layers { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; font-size: 12.5px; }
.of-chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font-size: 12.5px; }
.of-chk.dis { opacity: .5; cursor: not-allowed; }
.of-chk i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.of-sub { display: flex; align-items: baseline; gap: 10px; margin: 16px 0 6px; }
.of-scroll { overflow-x: auto; overflow-y: hidden; max-width: 100%; border-radius: 8px; }
.of-scroll canvas, .of-secvol { display: block; }
.of-tip { min-height: 16px; font-family: var(--mono); }
.of-hist { margin: 14px 0 -6px; }
.of-wcols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.of-wrow { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; padding: 3px 0; font-size: 12.5px; }
.of-wrow b { font-family: var(--mono); min-width: 74px; }
.of-wpct { font-family: var(--mono); min-width: 52px; }
.of-wnote { margin-top: 10px; line-height: 1.6; }
@media (max-width: 720px) { .of-app { padding: 12px 10px; } .of-chart { height: 300px; } .of-chart.of-tall { height: 440px; } .of-wcols { grid-template-columns: 1fr; } }

@media (max-width: 1180px) {
  .wf-line { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 18px; }
  .wf-step:nth-child(5)::before { display: none; }
  .form-grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .wf-line { grid-template-columns: minmax(0, 1fr); row-gap: 0; }
  .wf-step { flex-direction: row; align-items: flex-start; text-align: left; padding: 8px 0; gap: 12px; }
  .wf-step::before { display: block; left: 17px; right: auto; top: -10px; width: 2px; height: 18px; }
  .wf-step:first-child::before { display: none; }
  .wf-body, .wf-top { align-items: flex-start; }
  .wf-runs { justify-content: flex-start; }
  .wf-task { padding: 12px 16px; gap: 10px; }
  .wf-task > .chip { display: none; }
  .wf-ev { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .form-grid.four { grid-template-columns: minmax(0, 1fr); }
  .term { grid-template-columns: minmax(0, 1fr); }
  /* phones and narrow windows: the rail becomes one row of two pickers (market ▾ · page ▾); the market tabs go with it */
  .term-nav { position: static; max-height: none; overflow: visible; padding: 0; }
  .term-rail { display: none; }
  .term-pick { display: flex; }
  .term-page .term-tabs { display: none; }
  .term-page .term-top:has(> #term-session:empty) { display: none; }
  .term-tabs { overflow-x: auto; max-width: 100%; }
  .xm-kpis, .tc-grid2, .tc-inout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tc-grid2 { grid-template-columns: minmax(0, 1fr); }
  .tc-reader { padding: 18px 16px; }
  .tc-reader .prose { font-size: 14.5px; line-height: 1.8; }
  .tc-heat { grid-template-columns: 22px minmax(0, 1fr) 70px 44px; }
  .tc-heat > :nth-child(3), .tc-heat > :nth-child(6) { display: none; }
}

@media (max-width: 1180px) {
  .g-main { grid-template-columns: minmax(0, 1fr); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  /* phones: the list and a conversation are two views; a conversation has a ‹ back to the list */
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--topbar-h) - 24px); min-height: 420px; }
  .chat.has-sid .chat-list, .chat:not(.has-sid) .chat-main { display: none; }
  .chat-back { display: grid; place-items: center; width: 32px; height: 32px; margin-left: -6px; border-radius: 8px; color: var(--text-2); flex: none; }
  .chat-back svg { width: 18px; height: 18px; }
  .chat-thread { padding: 14px 12px; }
  .chat-head { gap: 8px; padding: 8px 10px; }
  .chat-compose { padding: 10px; }
  .chat-compose textarea { min-height: 42px; padding: 9px 12px; }
  .chat-compose .ch-send, .chat-compose #ch-stop { height: 42px; }
  .chat-compose .ch-send { width: 42px; }
  .msg.user { max-width: 92%; }
  .msg.bot > .agent-ico { display: none; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .donut-wrap { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .stepper { grid-template-columns: repeat(5, minmax(56px, 1fr)); overflow-x: auto; }
  .feed .item { grid-template-columns: 30px minmax(0, 1fr) 56px; }
  .feed .wf { display: none; }
  .timeline li { grid-template-columns: 22px minmax(0, 1fr); }
  .timeline .when { grid-column: 2; }
  .kpis, .kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi { padding: 14px 16px 13px; }
  .page { gap: 18px; }
  .card-head { padding: 14px 16px 0; }
  .card-body { padding: 14px 16px 16px; }
  th:first-child, td:first-child { padding-left: 16px; }
  th:last-child, td:last-child { padding-right: 16px; }
  .feed .item { padding: 10px 16px; }
  .kpi .value { font-size: 19px; }
  .kpi .spark { display: none; }
  .card-head .actions { margin-left: 0; flex-wrap: wrap; }
  .page-head h1 { font-size: 21px; }
  .page-head .actions { margin-left: 0; }
  .drawer .scroll { padding: 16px; }
}

/* Phones: the terminal chrome above the page title fits in three rows (markets, page, sync controls). */
@media (max-width: 560px) {
  .term-tabs a { padding: 6px 10px; }
  .term-tabs a svg { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
  .chart .line.draw { stroke-dashoffset: 0; }
}

/* pushed in-place update of a research page: no entry animation, nothing flashes */
.term-main.quiet .reveal { animation: none; opacity: 1; transform: none; }

/* ------------------------------------------------------------------ app pages: shared bits (page bar, stat row, ⓘ help, status ink) */
.page-bar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; min-height: 32px; }
.page-bar .spacer { flex: 1; }
.warn-ink { color: var(--warn-ink); }
.bad-ink { color: var(--bad); }
.help { position: relative; display: inline-grid; place-items: center; width: 18px; height: 18px; color: var(--faint); cursor: help; vertical-align: middle; flex: none; outline: none; border-radius: 50%; }
.help svg { width: 15px; height: 15px; }
.help:hover, .help:focus-visible { color: var(--muted); }
.help:focus-visible { box-shadow: 0 0 0 3px var(--accent-ring); }
.help::after {
  content: attr(data-tip); display: none; position: absolute; z-index: 30; top: calc(100% + 6px); left: -8px; width: max-content; max-width: min(320px, 78vw);
  padding: 9px 11px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
  color: var(--text-2); font-size: 12.5px; font-weight: 400; line-height: 1.6; white-space: pre-line; text-align: left; letter-spacing: 0;
  transform: translateX(var(--help-dx, 0px));  /* app.js shifts a bubble that would cross the window edge */
  pointer-events: none;  /* a bubble never covers the controls under it */
  box-sizing: border-box;  /* `*` does not reach pseudo-elements */
}
/* the block holding an open bubble rises above its neighbours (cards with entry animations are stacking contexts) */
:is(.reveal, .card, .page-bar, .card-head):has(.help:is(:hover, :focus)) { position: relative; z-index: 35; }
.help:hover::after, .help:focus::after { display: block; }
.help.end::after { left: auto; right: -8px; }
/* phones: the bubble spans the screen (16px gutters) under the ⓘ; app.js sets the offsets on tap/focus. Not position:fixed —
   a card's finished entry animation would become its containing block. */
@media (max-width: 900px) {
  .help::after, .help.end::after { left: var(--help-left, -8px); right: auto; width: var(--help-w, min(320px, 78vw)); max-width: none; z-index: 60; transform: none; }
}
.stat-row { display: flex; margin: 0; }
.stat-row > div { padding: 0 var(--s5); border-left: 1px solid var(--border); min-width: 0; }
.stat-row > div:first-child { border-left: 0; padding-left: 0; }
.stat-row dt { font-size: var(--fs-xs); color: var(--muted); }
.stat-row dd { margin: 2px 0 0; font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); }
.stat-row dd small { font-size: var(--fs-xs); color: var(--muted); font-weight: 450; margin-left: 6px; }

/* ------------------------------------------------------------------ 总览 */
.ov-hero { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--s4) var(--s6); padding: var(--s5); }
.ov-label { font-size: var(--fs-sm); color: var(--muted); }
.ov-eq { font-size: var(--fs-hero); font-weight: 650; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; margin-top: 2px; min-height: 46px; }
.ov-ret { margin-top: var(--s1); font-size: 15px; display: flex; gap: var(--s2); align-items: baseline; flex-wrap: wrap; font-variant-numeric: tabular-nums; min-height: 24px; }
.ov-ret b { font-weight: 600; }
.ov-stats { margin-left: auto; padding-bottom: 3px; }
.ov-hold { display: flex; flex-direction: column; }
table.ov-pos td { padding-top: 10px; padding-bottom: 10px; vertical-align: top; }
table.ov-pos td .small { font-size: var(--fs-xs); }
.ov-sym { display: flex; flex-direction: column; color: var(--text); line-height: 1.35; }
.ov-sym small { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.ov-sym:hover { text-decoration: none; }
.ov-sym:hover .sym { color: var(--accent); }
.ov-wbar { display: block; width: 64px; height: 3px; margin: 7px 0 0 auto; border-radius: 3px; background: var(--hover); overflow: hidden; }
.ov-wbar i { display: block; height: 100%; background: var(--accent); opacity: 0.55; border-radius: 3px; }
.ov-cash td { color: var(--text-2); }
.ov-risk { margin-top: auto; padding: var(--s3) var(--s5) var(--s4); border-top: 1px solid var(--border); }
.ov-risk-head { display: flex; align-items: center; gap: var(--s2); }
.ov-risk-head b { font-size: var(--fs-sm); font-weight: 600; }
.ov-risk-head .spacer { flex: 1; }
.ov-risk-warn { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--warn-ink); line-height: 1.5; }
.ov-risk-warn svg { width: 14px; height: 14px; flex: none; margin-top: 3px; }
.ov-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px var(--s5); margin: var(--s3) 0 0; }
.ov-limits > div { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--fs-sm); min-width: 0; }
.ov-limits dt { color: var(--muted); white-space: nowrap; }
.ov-limits dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.ov-limits .warn dd { color: var(--warn-ink); font-weight: 600; }
.ov-empty { padding: var(--s4) var(--s5); font-size: var(--fs-sm); }
.ov-live { padding: var(--s2) var(--s5) var(--s2); }
.ov-live-h { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s3); }
.ov-live-h .spacer { flex: 1; }
.act-list { display: flex; flex-direction: column; }
.act-row {
  position: relative; display: grid; grid-template-columns: 92px 200px minmax(0, 1fr) 16px; gap: var(--s3); align-items: center;
  padding: 11px var(--s5); border-top: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-sm);
}
.act-row:first-child { border-top: 0; }
.act-row:hover { background: var(--panel-2); text-decoration: none; }
.act-row time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-row .who { display: flex; align-items: center; gap: 7px; min-width: 0; white-space: nowrap; }
.act-row .who > span:nth-of-type(1) { color: var(--text); font-weight: 600; }
.act-row .what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-variant-numeric: tabular-nums; }
.act-row .what b { font-weight: 600; }
.act-row .what .sep { color: var(--faint); margin: 0 8px; }
.act-row .what .rej { color: var(--text-2); }
.act-row .go { width: 14px; height: 14px; color: var(--faint); opacity: 0; transition: opacity 0.15s; }
.act-row:hover .go { opacity: 1; }
.act-row.anom::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--warn); }
.act-row.anom.bad::before { background: var(--bad); }
.act-row .spinner { width: 11px; height: 11px; vertical-align: -1px; }
@media (max-width: 900px) {
  .ov-hero { padding: var(--s4); gap: var(--s3); }
  .ov-eq { font-size: 32px; min-height: 38px; }
  .ov-stats { margin-left: 0; width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) 0; padding: var(--s3) 0 0; border-top: 1px solid var(--border); }
  .ov-stats > div { padding: 0 var(--s3); }
  .ov-stats > div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .ov-risk { padding: var(--s3) var(--s4) var(--s4); }
  .ov-live { padding: var(--s2) var(--s4); }
  .act-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what what" "who time"; gap: 4px var(--s2); padding: 10px var(--s4); }
  .act-row .what { grid-area: what; white-space: normal; }
  .act-row .who { grid-area: who; font-size: var(--fs-xs); }
  .act-row .who .agent-ico { display: none; }
  .act-row time { grid-area: time; font-size: var(--fs-xs); }
  .act-row .go { display: none; }
  .ov .page-bar > .muted { flex-basis: 100%; }
  .ov .page-bar .spacer { display: none; }
  .ov .tabs.sub button { padding: 3px 8px; }
}
#ov-notice:empty { display: none; }

/* ------------------------------------------------------------------ 我的研究 */
.rs-search { position: relative; width: 220px; }
.rs-search svg { position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--faint); }
.rs-search input { min-height: 30px; padding: 4px 10px 4px 30px; font-size: var(--fs-sm); border-radius: 9px; }
.rs-group { font-size: var(--fs-xs); font-weight: 600; color: var(--faint); padding: var(--s3) var(--s5) var(--s1); border-top: 1px solid var(--border); }
.rs-group:first-child { border-top: 0; }
.rs-row { display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s3) var(--s5); color: var(--text-2); border-top: 1px solid var(--border); }
.rs-group + .rs-row { border-top: 0; }
.rs-row:first-child { border-top: 0; }
.rs-row:hover { background: var(--panel-2); text-decoration: none; }
.rs-main { flex: 1; min-width: 0; }
.rs-t { font-size: 15px; font-weight: 600; color: var(--text); line-height: 1.45; }
.rs-row:hover .rs-t { color: var(--accent); }
.rs-p { margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rs-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--s2); }
.rs-tags .chip { font-weight: 500; }
.rs-tags .chip.more { color: var(--muted); background: transparent; }
.rs-meta { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: var(--fs-xs); color: var(--muted); padding-top: 3px; font-variant-numeric: tabular-nums; }
.rs-none { padding: var(--s5); font-size: var(--fs-sm); }
.rs-drawer .scroll { gap: var(--s4); }
.rs-drawer header .help { margin-left: -2px; }
.rs-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.rs-fields .field:first-child { grid-column: 1 / -1; }
/* one report: a reading column (≈45 Chinese characters a line) */
.rs-article { width: 100%; max-width: 800px; margin: 0 auto; padding: var(--s6) 40px var(--s7); }
.rs-back { display: none; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--s3); }
.rs-back svg { width: 14px; height: 14px; }
.rs-title { font-size: 24px; font-weight: 680; line-height: 1.4; color: var(--text); }
.rs-sub { margin-top: var(--s2); font-size: var(--fs-sm); color: var(--muted); line-height: 1.6; }
.rs-article .rs-tags { margin-top: var(--s3); }
.rs-article .notice { margin-top: var(--s4); }
.rs-article .prose { margin-top: var(--s5); padding-top: var(--s5); border-top: 1px solid var(--border); max-width: none; font-size: 15px; line-height: 1.8; }
@media (max-width: 900px) {
  .rs .page-bar { gap: var(--s2); }
  .rs .page-bar #r-tier { order: 1; flex-basis: 100%; overflow-x: auto; max-width: max-content; }
  .rs-search { flex: 1; width: auto; }
  .rs .page-bar .spacer { display: none; }
  .rs-row { padding: var(--s3) var(--s4); gap: var(--s3); }
  .rs-group { padding: var(--s3) var(--s4) var(--s1); }
  .rs-meta { display: none; }
  .rs-fields { grid-template-columns: minmax(0, 1fr); }
  .rs-article { padding: var(--s4) var(--s4) var(--s6); }
  .rs-back { display: inline-flex; }
  .rs-title { font-size: 20px; }
  .rs-article .prose { font-size: 15px; }
}

/* ------------------------------------------------------------------ 策略 (research strategies' paper ledgers) */
.st.quiet .reveal { animation: none; }  /* pushed in-place updates: nothing re-enters */
.st-lede { color: var(--text-2); font-size: var(--fs-sm); }
.st-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: var(--s5); }
.st-card { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4) var(--s5) var(--s4); transition: box-shadow 0.25s var(--ease), border-color 0.25s var(--ease); }
.st-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.st-card.off .st-c-main, .st-card.off .st-c-stats { opacity: 0.72; }
.st-c-head { display: flex; align-items: center; gap: var(--s2); min-height: 28px; }
.st-c-head .spacer { flex: 1; }
.st-c-title { display: flex; align-items: baseline; gap: var(--s2); min-width: 0; }
.st-name { color: var(--text); font-size: 15.5px; font-weight: 640; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-name::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }  /* the whole card opens the strategy */
.st-name:hover { text-decoration: none; }
.st-card:hover .st-name { color: var(--accent); }
.st-name:focus-visible { outline: none; }
.st-name:focus-visible::after { box-shadow: 0 0 0 3px var(--accent-ring); }
.st-asset { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; }
.st-act { position: relative; z-index: 1; flex: none; }  /* above the card-wide link */
.st-c-head .badge { position: relative; z-index: 1; flex: none; }
.st-c-state, .st-state { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; }
.st-c-state.wait, .st-c-state.off, .st-state.wait, .st-state.off { color: var(--muted); }
.st-c-state.warn, .st-state.warn { color: var(--warn-ink); }
.st-c-state.bad, .st-state.bad { color: var(--bad); }
.st-c-main { display: flex; align-items: flex-end; gap: var(--s4); }
.st-c-val { min-width: 0; flex: 1; }
.st-c-val .k { color: var(--muted); font-size: var(--fs-xs); display: flex; gap: 6px; align-items: baseline; }
.st-c-val .k small { color: var(--faint); font-size: var(--fs-xs); }
.st-c-val .v { font-size: 26px; font-weight: 660; letter-spacing: -0.02em; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-c-val .v.none, .st-hero-v.none { font-size: var(--fs-lg); font-weight: 500; color: var(--faint); letter-spacing: 0; }
.st-spark { flex: none; width: 120px; height: 36px; }
.st-spark .spark { display: block; width: 100%; height: 100%; }
.st-c-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin: 0; padding-top: var(--s3); border-top: 1px solid var(--border); }
.st-c-stats dt { color: var(--muted); font-size: var(--fs-xs); }
.st-c-stats dd { margin: 2px 0 0; font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-c-stats dd.faint, .st-c-stats dd .faint { font-weight: 450; }

/* one strategy */
.st-back { display: none; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--muted); margin-right: var(--s2); }
.st-back svg { width: 14px; height: 14px; }
.st-one .page-bar .btn { flex: none; }
.st-hero { display: flex; align-items: flex-end; flex-wrap: wrap; gap: var(--s4) var(--s6); padding: var(--s5); }
.st-hero-main { min-width: 0; }
.st-hero-k { font-size: var(--fs-sm); color: var(--muted); display: flex; align-items: center; gap: 4px; }
.st-hero-v { font-size: 34px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-hero-s { margin-top: var(--s1); }
.st-stats { margin-left: auto; padding-bottom: 3px; }
.st-stats dd.st-dd-soft { font-size: var(--fs-sm); font-weight: 500; color: var(--faint); }
.st-tracks { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; margin: -6px 0; }
.st-tracks .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.st-wait { display: flex; gap: var(--s4); align-items: flex-start; padding: var(--s5); }
.st-wait > svg { width: 22px; height: 22px; color: var(--faint); flex: none; margin-top: 2px; }
.st-wait b { font-weight: 620; }
.st-wait p { margin: 4px 0 0; line-height: 1.65; }
.st-wait .st-when { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
figure.st-chart { margin: 0; min-height: 200px; }
.st-none { padding: var(--s2) 0; }
.st-items .st-none { padding: var(--s2) var(--s5) var(--s3); }
.st-item { display: flex; gap: var(--s4); align-items: flex-start; padding: 11px var(--s5); border-top: 1px solid var(--border); }
.st-item:first-child { border-top: 0; }
.st-i-main { flex: 1; min-width: 0; }
.st-i-t { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.st-i-t b { font-weight: 640; }
.st-dir { font-size: var(--fs-xs); font-weight: 600; color: var(--text-2); background: var(--hover); border-radius: 5px; padding: 0 6px; line-height: 19px; }
.st-i-s { margin-top: 2px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.6; }
.st-i-v { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.st-i-v b { font-weight: 640; }
.st-sub { padding: 10px var(--s5) 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--faint); border-top: 1px solid var(--border); }
.st-sub + .st-item { border-top: 0; }
.st-items > .st-sub:first-child { border-top: 0; padding-top: 0; }

/* fills: a grid on wide screens, two lines on phones */
.st-fills { display: flex; flex-direction: column; }
.st-f { display: grid; grid-template-columns: 92px 112px 96px 84px 84px minmax(72px, 1fr) minmax(0, 210px); gap: 12px; align-items: center;
  padding: 10px var(--s5); border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text); }
.st-f.head { border-top: 0; padding-top: 2px; padding-bottom: 8px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.st-f > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-f .num { text-align: right; font-variant-numeric: tabular-nums; }
.st-f .c-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.st-f .c-act b { font-weight: 600; }
.st-f .c-res { font-weight: 600; }
.st-f .c-why { color: var(--text-2); font-size: var(--fs-sm); }
.st-f .c-src { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; font-size: var(--fs-xs); white-space: normal; }
.st-f .brk { display: none; }
.st-flag { flex: none; font-size: 11.5px; line-height: 18px; padding: 0 6px; border-radius: 5px; background: var(--hover); color: var(--text-2); cursor: help; }
.st-flag.warn { background: var(--warn-soft); color: var(--warn-ink); }
.st-more { padding: 8px var(--s5) 2px; }

/* comparison with the site */
.st-par-none { display: flex; flex-direction: column; gap: 4px; }
.st-par-none b { font-weight: 600; color: var(--text-2); }
.st-par-sum { display: flex; align-items: baseline; gap: var(--s2) var(--s5); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.st-par-sum > div { display: flex; align-items: baseline; gap: var(--s2); }
.st-par-sum > div b { font-size: 24px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.st-par-sum span b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.st-par-list { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s4); }
.st-par-g, .st-par-r { display: flex; gap: var(--s3); align-items: baseline; padding: 8px 12px; border-radius: 9px; background: var(--panel-2); font-size: var(--fs-sm); }
.st-par-g span { flex: 1; min-width: 0; color: var(--text-2); }
.st-par-g b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.st-par-g.warn, .st-par-r.warn { box-shadow: inset 3px 0 0 var(--warn); }  /* differences: a quiet amber edge, not a filled block */
.st-par-r { flex-wrap: wrap; }
.st-par-r .c-day { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 48px; }
.st-par-r .c-k { color: var(--text-2); }
.st-par-r .c-f { display: flex; flex-wrap: wrap; gap: 4px 12px; flex-basis: 100%; padding-left: 60px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.st-par-r .c-f:empty { display: none; }
.st-par-foot { margin-top: var(--s3); }
.st-about { margin: 0 0 var(--s4); color: var(--text-2); line-height: 1.7; max-width: 720px; }
.st-kv { max-width: 560px; }
.st-io { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s5); }
.st-io > div:only-child, .st-io > div:first-child:nth-last-child(2):has(+ div[hidden]) { grid-column: 1 / -1; }
.st-sub0 { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); margin-bottom: var(--s2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.st-sub0 .muted { font-weight: 400; }
.st-log { display: flex; flex-direction: column; }
.st-log-r { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; gap: var(--s3); align-items: baseline; padding: 7px 0; border-top: 1px solid var(--border); font-size: var(--fs-sm); }
.st-log-r:first-child { border-top: 0; }
.st-log-r .c-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.st-log-r > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 1100px) {
  .st-stats { margin-left: 0; width: 100%; }
}
@media (max-width: 900px) {
  .st-grid { gap: var(--s3); }
  .st-card { padding: var(--s4); }
  .st-hero { padding: var(--s4); gap: var(--s3); }
  .st-hero-v { font-size: 28px; }
  .st-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3) 0; padding: var(--s3) 0 0; border-top: 1px solid var(--border); }
  .st-stats > div { padding: 0 var(--s3); }
  .st-stats > div:nth-child(odd) { border-left: 0; padding-left: 0; }
  .st-one .page-bar .st-tz { display: none; }
  .st-item, .st-sub { padding-left: var(--s4); padding-right: var(--s4); }
  .st-io { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .st-f { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 10px var(--s4); }
  .st-f.head { display: none; }
  .st-f > * { overflow: visible; }
  .st-f .c-act { order: 1; }
  .st-f .c-px { order: 2; text-align: left; }
  .st-f .c-qty { order: 3; text-align: left; color: var(--muted); font-size: var(--fs-xs); }
  .st-f .c-res { order: 4; margin-left: auto; }
  .st-f .c-res .d-only { display: none; }
  .st-f .brk { display: block; order: 5; flex-basis: 100%; height: 0; }
  .st-f .c-time { order: 6; font-size: var(--fs-xs); }
  .st-f .c-why { order: 7; font-size: var(--fs-xs); }
  .st-f .c-src { order: 8; }
  .st-par-r .c-f { padding-left: 0; }
}
@media (max-width: 560px) {
  .st-back { display: inline-flex; }
  .st-act .lbl { display: none; }
  .btn.sm.st-act { width: 30px; padding: 0; }
  .st-name { white-space: normal; }
  .st-c-stats dd { white-space: normal; }
  .st-spark { width: 96px; }
  .st-c-val .v { font-size: 24px; }
  .st-log-r { grid-template-columns: 78px minmax(0, 1fr); }
  .st-log-r > :nth-child(3) { grid-column: 2; }
}
.st-card-min { gap: var(--s2); }
.st-wait b .help { margin-left: 4px; }

/* ---------------------------------------------------------------- operator controls (controls.js) */
.ops-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.ops-tile { display: flex; flex-direction: column; gap: 3px; padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel-2); min-width: 0; transition: border-color .2s, background-color .2s; }
.ops-tile.bad { border-color: color-mix(in srgb, var(--bad) 38%, transparent); background: var(--bad-soft); }
.ops-tile.warn { border-color: color-mix(in srgb, var(--warn) 36%, transparent); }
.ops-tile .k { color: var(--faint); font-size: var(--fs-xs); display: flex; align-items: center; gap: 4px; }
.ops-tile .v { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.ops-tile .sub { color: var(--muted); font-size: var(--fs-xs); min-height: 1.4em; }
.ops-tile .btn { align-self: flex-start; margin-top: 6px; }
.ops-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; }
.ops-dot.ok { background: var(--ok); }
.ops-dot.warn { background: var(--warn); }
.ops-dot.bad { background: var(--bad); animation: ops-pulse 1.6s ease-in-out infinite; }
@keyframes ops-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--bad) 18%, transparent); } }
.ops-latched, .ops-alerts { margin-top: var(--s3); }
.ops-row { display: flex; align-items: center; gap: var(--s2); padding: 7px 0; border-top: 1px solid var(--border); min-width: 0; }
.ops-row:first-child { border-top: 0; }
.ops-row > span:not(.badge):not(.chip) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops-row .btn { margin-left: auto; flex: none; }
.ops-end { margin-left: auto; flex: none; }
.ops-alerts > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); padding: 4px 0; }
.ops-list { max-height: 280px; overflow: auto; }
.st-ctl { display: inline-flex; gap: 2px; }
@media (max-width: 900px) {
  .ops-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .ops-tile { padding: var(--s2) var(--s3); }
  .ops-row { flex-wrap: wrap; }
}

/* ask(): a reason-taking confirm */
dialog.ask { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.ask[open] { animation: ask-in .18s ease-out; }
dialog.ask::backdrop { background: rgba(15, 18, 22, 0.32); backdrop-filter: blur(2px); }
@keyframes ask-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }
.ask-form { display: flex; flex-direction: column; gap: var(--s3); padding: var(--s5); }
.ask-form h3 { margin: 0; font-size: var(--fs-lg); }
.ask-body { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.ask-choices { display: flex; flex-direction: column; gap: var(--s2); }
.ask-choice { display: flex; gap: var(--s2); align-items: flex-start; padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.ask-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.ask-choice input { margin-top: 3px; }
.ask-choice span { display: flex; flex-direction: column; gap: 2px; }
.ask-choice small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.ask-form textarea { resize: vertical; min-height: 54px; }
.ask-actions { display: flex; justify-content: flex-end; gap: var(--s2); }

/* ------------------------------------------------------------------ 自主决策 */
.own .own-hd { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t a" "s a"; gap: 6px 16px; padding: 18px 20px; align-items: center; }
.own-t { grid-area: t; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.own-t h1 { font-size: 19px; font-weight: 660; letter-spacing: -0.01em; margin: 0; }
.own-sub { grid-area: s; font-size: var(--fs-sm); }
.own-sub b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.own-cd { font-variant-numeric: tabular-nums; }
.own-a { grid-area: a; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.own-note { display: flex; gap: 6px; align-items: center; padding: 0 20px 16px; margin-top: -6px; }
.own-note svg { width: 14px; height: 14px; flex: none; }
.own-tracks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.own-track { padding: 16px 18px 14px; display: flex; flex-direction: column; gap: 8px; animation: rise 0.45s var(--ease) both; animation-delay: calc(var(--i, 0) * 60ms); }
.own-track-h { display: flex; align-items: center; gap: 8px; min-width: 0; }
.own-track-h b { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.own-track-h > span:last-child { margin-left: auto; }
.own-track-v { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; }
.own-track-v .big { font-size: 22px; font-weight: 680; letter-spacing: -0.02em; }
.own-last { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--panel-2); border-radius: 9px; padding: 6px 10px;
  font: inherit; font-size: var(--fs-sm); color: var(--text); cursor: pointer; text-align: left; transition: border-color 0.2s var(--ease); }
.own-last:hover { border-color: var(--accent-ring); }
.own-last .faint { margin-left: auto; }
.own-last.none { cursor: default; border-style: dashed; background: none; }
.own-stage { height: 480px; }
.own-key { display: flex; gap: 6px 16px; flex-wrap: wrap; align-items: center; padding: 10px var(--s4) 12px; border-top: 1px solid var(--border); margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.own-key .spacer { flex: 1; }
.own-key .k-line { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--accent); vertical-align: 3px; margin-right: 6px; }
.own-key .k-line.bad { border-top-color: var(--bad); }
.own-key .k-line.ok { border-top-color: var(--ok); }
.own-key .k-line.dashed { border-top-style: dashed; }
.own-log { display: flex; flex-direction: column; border-top: 1px solid var(--border); margin-top: 12px; }
.own-row { display: grid; grid-template-columns: 118px 92px 84px minmax(0, 1fr) 48px; gap: 12px; align-items: center; padding: 10px 20px;
  border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; font-size: 13.5px; color: var(--text); text-align: left; cursor: pointer;
  transition: background 0.15s var(--ease); }
.own-log.multi .own-row { grid-template-columns: 118px 128px 92px 84px minmax(0, 1fr) 48px; }
.own-row > .chip { justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.own-row:hover { background: var(--hover); }
.own-row.sel { background: var(--accent-soft); }
.own-row.idle { color: var(--text-2); }
.own-row.idle .own-act { color: var(--muted); font-weight: 500; }
.own-when { font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; line-height: 1.3; }
.own-when small { font-size: 11px; }
.own-act { font-weight: 600; white-space: nowrap; }
.own-act.long { color: var(--rise); }
.own-act.short { color: var(--fall); }
.own-sum { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.own-row.refused .own-sum { color: var(--bad); }
.own-rr { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12.5px; }
.own-reg { display: flex; flex-direction: column; gap: 0; }
.own-reg-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.own-reg-row:first-child { border-top: 0; padding-top: 0; }
.own-reg-row .muted { margin-top: 3px; }
.own-reasons { list-style: none; padding: 0 !important; display: flex; flex-direction: column; gap: 4px; }
.own-reasons li { font-size: 13px; }
.own-reasons .mono.faint { margin-right: 6px; }
.own-man { display: flex; flex-direction: column; margin-top: 8px; font-size: 12.5px; }
.own-man-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 70px; gap: 2px 10px; padding: 7px 0; border-top: 1px solid var(--border); }
.own-man-row > :nth-child(4) { grid-column: 1 / 3; }
.own-man-row > :nth-child(5) { text-align: right; }
.own-man-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.own-ev { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.own-ev-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: start; padding: 7px 10px; border-radius: 9px; background: var(--panel-2); }
.own-ev-row > .mono { grid-column: 2; overflow-wrap: anywhere; }
.own-json { max-height: 360px; overflow: auto; font-size: 11.5px; line-height: 1.5; background: var(--panel-2); border-radius: 9px; padding: 10px 12px; margin: 8px 0; white-space: pre; }
.own-json-a { display: flex; justify-content: flex-end; margin-top: 6px; }
@media (max-width: 760px) {
  .own .own-hd { grid-template-columns: minmax(0, 1fr); grid-template-areas: "t" "s" "a"; padding: 16px; }
  .own-a { justify-content: flex-start; }
  .own-stage { height: 360px; }
  .own-row, .own-log.multi .own-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "w v" "a a" "s s"; gap: 3px 10px; padding: 10px 16px; }
  .own-row > .own-when { grid-area: w; flex-direction: row; gap: 8px; }
  .own-row > .badge, .own-row > span[title] { grid-area: v; justify-self: end; }
  .own-row > .own-act { grid-area: a; }
  .own-row > .own-sum { grid-area: s; white-space: normal; }
  .own-row > .chip, .own-row > .own-rr, .own-row > span:empty { display: none; }
  .own-key .spacer { display: none; }
}
.own-track-s.why { display: flex; align-items: center; gap: 4px; }
.own-bm-wrap { overflow-x: auto; }
table.own-bm { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.own-bm th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.own-bm td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.own-bm th:first-child, table.own-bm td:first-child { text-align: left; }
table.own-bm .own-bm-name { display: inline-flex; align-items: center; gap: 6px; }
table.own-bm tr.own-bm-ref td { background: var(--panel-2); }
table.own-bm td.own-insuff { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.own-bm-foot { margin-top: 10px; line-height: 1.6; }
.own-tx-final { color: var(--text); margin: 8px 0; }
.own-tx-tools { margin: 6px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 4px; }
.own-llm { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.own-llm h3 { margin: 0 0 4px; }
.own-llm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 0; }
.own-llm-row label { display: inline-flex; align-items: center; gap: 6px; }
.own-llm-row input.sm[name=model] { max-width: 100%; }
