/* Hedge World — design system.
   Light theme built around a monochrome charcoal accent. Hairline panels, soft
   elevation, and a single motion curve. Colour still carries meaning:
   charcoal = interactive, green = long / gain, red = short / loss, amber = attention. */

:root {
  /* surfaces */
  --bg: #f3f4f9;
  --bg-glow-1: rgba(113, 135, 113, 0.14);
  --bg-glow-2: rgba(113, 135, 113, 0.10);
  --panel: #ffffff;
  --panel-2: #f4f5fa;
  --panel-3: #e9ebf3;
  --line: #e1e4ee;
  --line-soft: #eceef4;

  /* text */
  --text: #181b2a;
  --text-2: #545971;
  --text-3: #8b90a6;

  /* brand / interactive — muted sage green, solid */
  --accent: #718771;
  --accent-2: #637563;
  --accent-soft: rgba(113, 135, 113, 0.30);
  --accent-line: #3f4d3f;
  --accent-ink: #ffffff;
  --gradient: #718771;

  /* semantic (deepened for contrast on white) */
  --pos: #059669;
  --neg: #e11d48;
  --warn: #d97706;

  --font-ui: "Segoe UI Variable Text", "Segoe UI", "PingFang SC", "HarmonyOS Sans SC",
    "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-num: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Segoe UI", "PingFang SC",
    "Microsoft YaHei UI", system-ui, sans-serif;

  /* shape & motion */
  --topbar-h: 50px;
  --status-h: 30px;
  --sidebar-w: 242px;
  --sidebar-collapsed-w: 68px;
  --ease-kinetic: cubic-bezier(0.65, 0.01, 0.05, 0.99);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --radius: 12px;
  --radius-s: 8px;
  --radius-pill: 999px;
  --shadow: 0 6px 20px rgba(17, 24, 39, 0.08);
  --shadow-lg: 0 18px 44px rgba(17, 24, 39, 0.14);
  --glow: 0 0 0 3px rgba(113, 135, 113, 0.35);
  --ease: cubic-bezier(0.65, 0.05, 0, 1);
  --dur: 0.18s;
}

/* Dark theme — pure black, neutral greys, no glow. */
[data-theme="dark"] {
  --bg: #000000;
  --bg-glow-1: transparent;
  --bg-glow-2: transparent;
  --panel: #0d0d0d;
  --panel-2: #141414;
  --panel-3: #1d1d1d;
  --line: #262626;
  --line-soft: #1c1c1c;
  --text: #f2f2f2;
  --text-2: #b0b0b0;
  --text-3: #7a7a7a;
  --accent: #9bb89b;
  --accent-2: #84a084;
  --accent-soft: rgba(155, 184, 155, 0.25);
  --accent-line: #b8d4b8;
  --accent-ink: #ffffff;
  --pos: #34d399;
  --neg: #fb7185;
  --warn: #fbbf24;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.65);
  --glow: 0 0 0 3px rgba(155, 184, 155, 0.30);
}
html[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  color: var(--text);
  font: 13px/1.55 var(--font-ui);
  background:
    radial-gradient(900px 480px at 12% -8%, var(--bg-glow-1), transparent 60%),
    radial-gradient(820px 460px at 92% -12%, var(--bg-glow-2), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, p, dl, dd, pre { margin: 0; }
h1 { font-size: 17px; font-weight: 650; letter-spacing: 0.01em; }
h2 { font-size: 13.5px; font-weight: 650; }
a { color: var(--accent-line); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: #a5b4fc; }
i { font-style: normal; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent-line); outline-offset: 2px; border-radius: 4px; }

::selection { background: rgba(113, 135, 113, 0.4); }

/* thin, themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--panel-3); border: 2px solid transparent; background-clip: padding-box; border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: #c6cadb; background-clip: padding-box; }

.num { font-variant-numeric: tabular-nums; }
.big { font-family: var(--font-num); font-size: 15px; font-weight: 650; letter-spacing: 0.01em; }
.dim { color: var(--text-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn-text { color: var(--warn); }

/* ------------------------------------------------------------ frame */
/* ----------------------------------------------------- left sidebar */
.sidebar-inner {
  position: fixed; top: 0; left: 0; bottom: var(--status-h); z-index: 30;
  width: var(--sidebar-w); display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
}
.sb-header { height: 60px; display: flex; align-items: center; padding: 0 16px; flex-shrink: 0; }
.sb-header .brand { gap: 10px; }
.sb-header .brand-mark { width: 28px; height: 28px; }

.sb-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; }
.fs-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.nav-link {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-size: 13.5px; font-weight: 550;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}
.nav-link::before {
  content: ""; position: absolute; left: 0; top: 50%;
  width: 3px; height: 18px; border-radius: 3px; background: var(--accent);
  transform: translateY(-50%) scaleY(0);
  transition: transform 0.28s var(--ease-back);
}
.nav-link:hover { background: var(--panel-2); color: var(--text); transform: translateX(2px); }
.sb-icon {
  width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center;
  color: var(--text-3);
  transition: color 0.2s var(--ease), transform 0.28s var(--ease-back);
}
.nav-link:hover .sb-icon { color: var(--accent); transform: scale(1.1); }
.menu-list-item.current .nav-link {
  background: var(--accent-soft); color: var(--accent-line); font-weight: 650;
}
.menu-list-item.current .nav-link::before { transform: translateY(-50%) scaleY(1); }
.menu-list-item.current .sb-icon { color: var(--accent-line); }

.sb-footer {
  flex-shrink: 0; padding: 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px;
}
/* Machine lever switch (native port, scaled to the sidebar). */
.toggle-container {
  --knob-size: 1.75em;
  justify-content: center; display: flex; position: relative;
  align-self: center; width: fit-content;
  font-size: 10px; margin: 6px 0;
}
.toggle-input {
  z-index: 2; transform-origin: 50% 4.75em;
  width: var(--knob-size); height: var(--knob-size);
  opacity: 0; cursor: pointer; border-radius: 50%;
  transition: transform 0.24s cubic-bezier(0.65, 1.35, 0.5, 1);
  position: absolute; bottom: 132.5%; transform: rotate(-25deg); margin: 0;
}
.toggle-input:checked { transform: rotate(25deg); }
.toggle-handle-wrapper {
  z-index: 1; width: 200%; position: absolute; bottom: -135%; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 62.125%, #0000 50%);
  mask-image: linear-gradient(#000 62.125%, #0000 50%);
}
.toggle-handle {
  transform-origin: bottom; flex-direction: column; align-items: center;
  transition: transform 0.24s cubic-bezier(0.65, 1.35, 0.5, 1);
  display: flex; transform: rotate(-25deg);
}
.toggle-input:checked + .toggle-handle-wrapper > .toggle-handle { transform: rotate(25deg); }
.toggle-handle-knob {
  z-index: 1; width: var(--knob-size); height: var(--knob-size);
  background-image: radial-gradient(at 70% 30%, #fedee2 4%, #d63534 12%, #d63534 24%, #a81a1a 50%, #a81a1a 65%, #d63534 75%);
  border-radius: 50%; transition: transform 0.24s cubic-bezier(0.65, 1.35, 0.5, 1); position: relative;
}
.toggle-input:checked + .toggle-handle-wrapper .toggle-handle-knob { transform: rotate(-90deg); }
.toggle-handle-knob::after {
  content: ""; border-radius: inherit; opacity: 0; width: 100%; height: 100%;
  transition: opacity 0.2s; position: absolute; top: 0; left: 0; box-shadow: inset 0 0 8px 2px #fff6;
}
@media (hover: hover) {
  .toggle-input:hover + .toggle-handle-wrapper .toggle-handle-knob::after,
  .toggle-input:focus-visible + .toggle-handle-wrapper .toggle-handle-knob::after { opacity: 1; }
}
.toggle-handle-bar-wrapper { width: 0.5em; height: 3em; position: relative; }
.toggle-handle-bar {
  top: calc(var(--knob-size) / 2 * -1); width: 100%;
  height: calc(100% + var(--knob-size) / 2);
  background-image: linear-gradient(90deg, #777475, #a4a4a4, #fff 45%, #fff 55%, #a4a4a4, #777475);
  background-position-x: 0.06125em;
  transition: background-position-x 0.24s cubic-bezier(0.65, 1.35, 0.5, 1);
  position: absolute; left: 0; box-shadow: inset 0 1em 0.25em #0006;
}
.toggle-input:checked + .toggle-handle-wrapper .toggle-handle-bar { background-position-x: -0.06125em; }
.toggle-base {
  background-color: #fff; background-image: linear-gradient(#fff, #d7d7d7);
  border-radius: 3.125em; width: 3.5em; height: 1.125em; padding: 0.25em;
  position: relative; box-shadow: 0 -0.25em 0.5em #fff, 0 0.25em 0.5em #d7d7d7; align-self: flex-end;
}
.toggle-base-inside {
  border-radius: inherit; background-image: linear-gradient(#a6a6a6, #7d7d7d);
  width: 100%; height: 100%; position: relative;
  box-shadow: inset 0 0.0625em #fff3, inset 0 -0.03125em #fff, inset 0 -0.0625em 0.25em #0000001a;
}
.toggle-base-inside::after {
  content: ""; border-radius: inherit; width: 100%; height: 100%; box-shadow: inherit;
  opacity: 0; background-image: linear-gradient(#5ab054, #438c3c);
  transition: opacity 0.24s cubic-bezier(0.65, 1.35, 0.5, 1); position: absolute;
}
.toggle-input:checked ~ .toggle-base .toggle-base-inside::after { opacity: 1; }
/* Inside the change-password card: anchor to the bottom-right, base sitting on
   the card's bottom edge. */
.pw-panel { position: relative; }
.pw-panel .toggle-container {
  position: absolute; right: 20px; bottom: 0; margin: 0;
}
.sb-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sb-avatar {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--gradient); color: var(--accent-ink); font-weight: 700; font-size: 13px;
}
.sb-username {
  font-size: 13px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sb-logout {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 10px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-2); font: inherit; font-size: 13.5px; font-weight: 550;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.sb-logout:hover { background: var(--panel-2); color: var(--text); }
.sb-logout .sb-icon { color: var(--text-3); }
.sb-logout:hover .sb-icon { color: var(--text); }

/* collapse toggle in the header */
.sb-collapse {
  margin-left: auto; width: 30px; height: 30px; flex-shrink: 0;
  display: grid; place-items: center; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel); cursor: pointer;
  color: var(--text-2);
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.sb-collapse:hover { background: var(--panel-2); color: var(--accent-line); border-color: var(--accent); }
.collapse-icon { width: 18px; height: 18px; display: grid; place-items: center; }
.collapse-icon svg { width: 100%; height: 100%; transition: transform 0.35s var(--ease-back); }

/* ------------------------------------------------ collapsed state */
body[data-collapsed="true"] { --sidebar-w: var(--sidebar-collapsed-w); }
body[data-collapsed="true"] .sb-header { padding: 0; justify-content: center; }
body[data-collapsed="true"] .sb-header .brand { display: none; }
body[data-collapsed="true"] .sb-collapse { margin-left: 0; border-color: transparent; background: transparent; }
body[data-collapsed="true"] .collapse-icon svg { transform: rotate(180deg); }
body[data-collapsed="true"] .sb-nav { padding: 8px 10px; }
body[data-collapsed="true"] .nav-link {
  justify-content: center; padding: 10px 0; gap: 0;
}
body[data-collapsed="true"] .nav-link::before { display: none; }
body[data-collapsed="true"] .nav-link-text { display: none; }
body[data-collapsed="true"] .sb-footer { padding: 12px 10px; align-items: center; }
body[data-collapsed="true"] .sb-user { justify-content: center; }
body[data-collapsed="true"] .sb-username { display: none; }
body[data-collapsed="true"] .sb-logout { justify-content: center; padding: 9px 0; }
body[data-collapsed="true"] .logout-label { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; color: var(--text); }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; padding: 4px;
  background: #11141f;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}
.brand-mark svg { width: 100%; height: 100%; }
.brand-name { font-family: var(--font-num); font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }

.nav { display: flex; height: 100%; gap: 2px; }
.nav a {
  display: flex; align-items: center; padding: 0 15px;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur) var(--ease);
}
.nav a:hover { color: var(--text); }
.nav a.on { color: var(--text); border-bottom-color: var(--accent); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who {
  color: var(--text-2); font-size: 12.5px;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: var(--radius-pill);
}

/* UI chrome (nav, buttons, labels, headings, badges) is not selectable;
   data values and explanatory notes stay selectable/copyable. */
#sidebar, #statusbar, .topbar, .btn, label, .panel-head, .tabs, .seg,
.brand, .cc-v-title, .guard-section-label, .guard-badge, .status-pill,
.guard-fixed-head, .guard-field > label, .fee-cell > span {
  -webkit-user-select: none; user-select: none;
}
.info-pop, .info-pop p { -webkit-user-select: text; user-select: text; }

.app-main {
  padding: 22px 24px calc(var(--status-h) + 26px);
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* in-page loading indicator while the next route is fetching */
.page-loading {
  min-height: 62vh; display: flex; align-items: center; justify-content: center;
  animation: page-loading-in 0.25s var(--ease) both;
}
.bars {
  --bar-duration: 1.2s; --bar-delay: 0.2s;
  display: inline-flex; align-items: stretch; gap: 5%;
  width: 34px; height: 30px; color: var(--accent);
}
.bars .bar {
  display: inline-block; height: 100%; width: 30%; border-radius: 2px;
  background: currentColor; transform-origin: center;
  animation: loading-wave-bars var(--bar-duration) ease-in-out infinite;
}
@keyframes loading-wave-bars {
  0%, 100% { transform: scaleY(1); opacity: 0.5; }
  50% { transform: scaleY(0.6); opacity: 1; }
}
@keyframes page-loading-in { from { opacity: 0; } to { opacity: 1; } }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (prefers-reduced-motion: reduce) {
  .bars .bar { animation: none; }
  .page-loading { animation: none; }
}

/* route transition: content fades up, cards stagger via inline animation-delay */
.page-enter { animation: page-fade-up 0.5s var(--ease) both; }
@keyframes page-fade-up {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .page-enter { animation: none; }
}

.statusbar {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 20;
  height: var(--status-h);
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden;
}
.venue-links, .feed-meta { display: flex; align-items: center; gap: 18px; }
.venue-link { display: inline-flex; align-items: center; gap: 6px; }
.venue-link b, .feed-meta b { font-family: var(--font-num); font-weight: 650; color: var(--text); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot.up { background: var(--pos); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 18%, transparent); }
.dot.warn { background: var(--warn); }
.dot.down { background: var(--neg); }
.feed-mode { color: var(--text); }
.feed-mode.mock { color: var(--warn); }

/* ------------------------------------------------------------ building blocks */

.panel {
  position: relative;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.stack { display: grid; gap: 16px; margin-inline: auto; width: 100%; }
.stack.narrow { max-width: 980px; }

.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.tabs button {
  appearance: none; background: none; border: 0; cursor: pointer;
  padding: 12px 16px 11px; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.tab-pane.tab-in { animation: tab-fade-in 0.24s var(--ease) both; }
@keyframes tab-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tab-pane.tab-in { animation: none; }
}

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
.toolbar-label { color: var(--text-3); margin-left: 6px; }
.toolbar-meta { margin-left: auto; color: var(--text-3); font-size: 12px; }
.toolbar-meta b { color: var(--text); font-family: var(--font-num); }
.hint { padding: 0 16px 12px; color: var(--text-3); font-size: 12px; max-width: 78ch; }

.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 16px;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-s);
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
    background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover { border-color: var(--panel-3); background: var(--panel-3); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.primary {
  background: var(--gradient); border-color: transparent; color: var(--accent-ink); font-weight: 650;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22);
}
.btn.primary:hover { background: var(--accent-2); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.26); }
.btn.danger { background: transparent; border-color: color-mix(in srgb, var(--neg) 60%, var(--line)); color: var(--neg); }
.btn.danger:hover { background: color-mix(in srgb, var(--neg) 14%, transparent); border-color: var(--neg); }
.btn.quiet { background: transparent; color: var(--text-2); border-color: transparent; }
.btn.quiet:hover { background: var(--panel-2); color: var(--text); }
.btn.small { height: 26px; padding: 0 11px; font-size: 12px; }
.btn.wide { width: 100%; height: 38px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--panel); }
.seg button {
  appearance: none; cursor: pointer; border: 0; border-right: 1px solid var(--line);
  height: 28px; padding: 0 12px; font: inherit; font-size: 12px; font-weight: 500;
  background: transparent; color: var(--text-2);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--accent-line); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  appearance: none; cursor: pointer;
  height: 28px; padding: 0 13px; font: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-2); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  transition: all var(--dur) var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--panel-3); }
.chip.on { color: var(--accent-ink); border-color: transparent; background: var(--gradient); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.16); }

input, select {
  height: 32px; padding: 0 11px;
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: var(--panel-3); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
select { cursor: pointer; }
.search { width: 240px; }

.tag {
  display: inline-block; margin-left: 6px; padding: 0 7px;
  font-size: 11px; line-height: 18px; color: var(--text-2);
  border: 1px solid var(--line); border-radius: 5px;
}

.side {
  display: inline-block; min-width: 18px; margin-right: 6px; padding: 0 4px;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; border-radius: 5px;
}
.side.long { color: var(--pos); background: color-mix(in srgb, var(--pos) 14%, transparent); }
.side.short { color: var(--neg); background: color-mix(in srgb, var(--neg) 14%, transparent); }

.inst { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.empty { padding: 30px 16px; color: var(--text-3); text-align: center; }

.alert { margin: 14px 16px 0; padding: 12px 14px; border-radius: var(--radius-s); border: 1px solid; font-size: 12.5px; }
.alert p { margin-top: 4px; }
.alert .btn { margin-top: 8px; }
.alert.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.alert.danger { border-color: color-mix(in srgb, var(--neg) 60%, transparent); color: var(--text); background: color-mix(in srgb, var(--neg) 12%, transparent); }
.alert.danger b { color: var(--neg); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 12.5px; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.prose { padding: 14px 16px 16px; color: var(--text-2); max-width: 76ch; }
.prose p + p, .prose pre + p { margin-top: 9px; }
.prose pre {
  margin-top: 9px; padding: 11px 13px; overflow-x: auto;
  font: 12px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--radius-s);
}

/* ----------------------------------------------------- info "!" + popover */
.info-wrap { position: absolute; right: 16px; top: 14px; z-index: 25; }
/* funding: align to the tab row centre while staying on whole pixels (crisp ring) */
.funding-note { top: 8px; }
/* inline placement inside a panel-head (no absolute anchoring) */
.position-note { position: static; margin-left: -2px; }
.inline-note { position: static; margin-left: auto; align-self: center; }

.info-fab {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); color: var(--text-2);
  cursor: pointer; padding: 0;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.info-fab svg { width: 17px; height: 17px; display: block; }
.info-fab:hover {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent-line);
}
.info-wrap.open .info-fab,
.info-fab:active { background: var(--accent); border-color: var(--accent); color: #fff; }

.info-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(300px, 80vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(24, 27, 42, 0.14);
  padding: 13px 15px; color: var(--text-2); font-size: 12.5px; line-height: 1.65;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.info-pop p + p { margin-top: 8px; }
.info-wrap.open .info-pop { opacity: 1; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .info-pop { transition: opacity 0.2s; }
  .info-fab { transition: none; }
}

/* -------------------------------- collapsing venue cards (keys) */
.cc-cards { display: flex; gap: 10px; height: 308px; padding: 4px 4px 6px; }
.cc-card {
  position: relative; flex: 0.7; min-width: 60px; border-radius: 14px;
  overflow: hidden; cursor: pointer; background: #1c1f23;
  transition: flex 0.7s cubic-bezier(0.2, 1, 0.3, 1); will-change: flex;
}
.cc-card.active { flex: 2.8; }
.cc-img { position: absolute; inset: 0; }
.cc-img svg {
  width: 100%; height: 100%; transform: scale(1.06);
  filter: grayscale(28%) brightness(0.82);
  transition: transform 0.8s cubic-bezier(0.2, 1, 0.3, 1), filter 0.7s var(--ease);
}
.cc-card.active .cc-img svg { transform: scale(1); filter: grayscale(0) brightness(1); }
.cc-card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top, rgba(9, 11, 13, 0.74) 0,
    rgba(9, 11, 13, 0.26) 46%, rgba(9, 11, 13, 0.14) 100%);
}
.cc-content {
  position: relative; z-index: 2; height: 100%; padding: 16px;
  display: flex; flex-direction: column; color: #fff;
}
.status-pill { font-size: 11px; padding: 3px 10px; border-radius: 999px; letter-spacing: 0.04em; }
.status-pill.on { background: rgba(113, 135, 113, 0.95); color: #fff; }
.status-pill.off { background: rgba(255, 255, 255, 0.18); color: rgba(255, 255, 255, 0.92); }
.cc-meta { margin-top: auto; display: flex; flex-direction: column; gap: 9px; }
.cc-title {
  font-size: 20px; font-weight: 650; opacity: 0; transform: translateY(6px);
  transition: opacity 0.35s var(--ease) 0.1s, transform 0.5s var(--ease) 0.1s;
}
.cc-fp, .cc-date, .test-result {
  font-size: 11.5px; opacity: 0; transform: translateY(6px);
  transition: opacity 0.35s var(--ease), transform 0.5s var(--ease);
}
.cc-card.active .cc-title,
.cc-card.active .cc-fp,
.cc-card.active .cc-date,
.cc-card.active .test-result { opacity: 1; transform: none; }
.cc-card.active .cc-fp, .cc-card.active .cc-date,
.cc-card.active .test-result { transition-delay: 0.16s; }
.cc-fp .dim { color: rgba(255, 255, 255, 0.62); }
.cc-fp .inst { color: #fff; }
.cc-date { color: rgba(255, 255, 255, 0.6); }
.test-result.pos { color: #7ee2b8; }
.test-result.neg { color: #ff9db4; }
.cc-actions {
  display: flex; flex-wrap: wrap; gap: 6px; opacity: 0; transform: translateY(6px);
  transition: opacity 0.4s var(--ease) 0.2s, transform 0.5s var(--ease) 0.2s;
}
.cc-card.active .cc-actions { opacity: 1; transform: none; }
.cc-actions .btn {
  background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.26); color: #fff;
}
.cc-actions .btn:hover { background: rgba(255, 255, 255, 0.3); }
.cc-actions .btn.danger { background: rgba(225, 29, 72, 0.88); border-color: transparent; }
.cc-v-title {
  position: absolute; left: 50%; bottom: 18px; z-index: 2;
  writing-mode: vertical-rl; transform: translateX(-50%) rotate(180deg);
  font-size: 12px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: rgba(255, 255, 255, 0.92);
  transition: opacity 0.3s var(--ease);
  opacity: 0;
}
.cc-card.active .cc-v-title { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .cc-card, .cc-img svg, .cc-title, .cc-actions, .cc-fp, .cc-fp, .test-result { transition-duration: 0.15s !important; }
}

/* -------------------------------- guard & fee layout (settings) */
.guard-body { display: flex; flex-direction: column; gap: 18px; padding: 18px 20px 22px; }
.guard-section-label {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 12px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text);
}
.guard-section-label .dim { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11.5px; }
.guard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.guard-field {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 9px;
  background: var(--panel-2);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.guard-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.guard-field label { font-size: 13px; font-weight: 600; }
.guard-field .inline-form { display: flex; align-items: center; gap: 8px; }
.guard-field .inline-form input { flex: 1; min-width: 0; }
.guard-meta { display: flex; flex-direction: column; gap: 3px; }
.guard-range, .guard-note { font-size: 11px; line-height: 1.5; }

/* notional-cap slider (plan A) */
.g-slider-row { display: flex; align-items: center; gap: 10px; }
/* M3 Expressive slider (native DOM port) */
.m3-slider {
  flex: 1; min-width: 0; height: 44px;
  display: flex; user-select: none; touch-action: none;
}
.m3-inner {
  position: relative; width: 100%; height: 100%;
  display: flex; align-items: center; padding: 0 22px;
}
.m3-track { position: relative; width: 100%; height: 16px; }
.m3-seg { position: absolute; top: 0; height: 16px; }
.m3-active {
  left: 0; z-index: 1; background: var(--accent);
  border-radius: 8px 2px 2px 8px;
}
.m3-inactive {
  right: 0; z-index: 0; background: var(--accent-soft);
  border-radius: 2px 8px 8px 2px;
}
.m3-thumb {
  position: absolute; top: 50%; transform: translate(-50%, -50%);
  width: 44px; height: 44px; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  cursor: grab; outline: none;
}
.m3-thumb::before {
  content: ""; width: 4px; height: 44px; border-radius: var(--radius-pill);
  background: var(--accent); transition: width 0.2s var(--ease);
}
.m3-slider.is-dragging .m3-thumb { cursor: grabbing; }
.m3-slider.is-dragging .m3-thumb::before { width: 2px; }
.m3-halo {
  position: absolute; top: 50%; left: 50%; width: 40px; height: 40px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: var(--accent); opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
.m3-thumb:hover .m3-halo { opacity: 0.08; }
.m3-thumb:focus-visible .m3-halo { opacity: 0.10; }
.m3-slider.is-dragging .m3-halo { opacity: 0.10; }
.m3-dot {
  position: absolute; top: 50%; right: 8px; width: 6px; height: 6px;
  transform: translateY(-50%); border-radius: 50%;
  background: var(--accent); opacity: 0.4;
}

.g-amount {
  width: 72px; flex: 0 0 auto; height: 36px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--panel); padding: 0 8px; color: var(--text);
  font: 600 15px var(--font-num); outline: none;
  transition: border-color 0.22s var(--ease), box-shadow 0.22s var(--ease), transform 0.2s var(--ease-back);
}
.g-amount::-webkit-outer-spin-button, .g-amount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.g-amount:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.g-range-meta { display: flex; justify-content: space-between; }
@keyframes g-amount-pulse {
  0% { transform: scale(1); color: var(--text); }
  35% { transform: scale(1.1); color: var(--accent-line); }
  100% { transform: scale(1); color: var(--text); }
}
.g-amount.g-pulse { animation: g-amount-pulse 0.34s var(--ease-back); }
@media (prefers-reduced-motion: reduce) {
  .m3-thumb, .m3-thumb::before, .m3-halo, .g-amount, .g-amount.g-pulse { transition: none; animation: none; }
}

/* Inline view-notes control inside the order ticket */
.tk-edge-head { display: flex; align-items: center; gap: 8px; }
.tk-info { position: relative; display: inline-flex; line-height: 0; align-self: center; margin-top: 5px; }
.tk-info-fab {
  width: 22px; height: 22px; border-radius: 50%;
}
.tk-info-fab svg { width: 13px; height: 13px; }
.tk-info.open .tk-info-fab { background: var(--accent); border-color: var(--accent); color: #fff; transform: none; }

.tk-info-pop {
  position: absolute; left: 0; top: calc(100% + 10px); z-index: 70;
  width: min(264px, 82vw); padding: 0; overflow: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(24, 27, 42, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}
.tk-info.open .tk-info-pop { opacity: 1; pointer-events: auto; }
.tk-info-arrow {
  position: absolute; top: -5px; left: 14px; width: 9px; height: 9px;
  background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
  transform: rotate(45deg);
}
.tk-info-head {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 14px; font-size: 12px; font-weight: 650; letter-spacing: 0.02em;
  color: var(--text); background: var(--panel-2);
  border-bottom: 1px solid var(--line-soft);
}
.tk-info-head-ico { width: 14px; height: 14px; color: var(--accent-2); display: inline-flex; }
.tk-info-head-ico svg { width: 14px; height: 14px; }
.tk-info-body { padding: 12px 14px 13px; color: var(--text-2); font-size: 12.5px; line-height: 1.65; }
.tk-info-body p + p { margin-top: 8px; }
@media (prefers-reduced-motion: reduce) {
  .tk-info-pop, .tk-info-fab { transition: opacity .2s; transform: none; }
}
.guard-fixed-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.guard-fixed {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 7px;
}
.guard-fixed-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.guard-fixed-note { font-size: 11px; line-height: 1.5; }
.guard-badge { font-size: 11px; padding: 3px 9px; border-radius: var(--radius-pill); font-weight: 600; white-space: nowrap; }
.guard-badge.on { background: var(--accent-soft); color: var(--accent-2); }
.guard-badge.off { background: rgba(225, 29, 72, 0.12); color: var(--neg); }
.guard-badge.muted { background: var(--line); color: var(--text); }
.fee-block { display: flex; flex-direction: column; gap: 12px; }
.fee-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.fee-cell {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 11px; background: var(--panel-2);
  transition: border-color 0.25s var(--ease);
}
.fee-cell:focus-within { border-color: var(--accent); }
.fee-cell span { font-size: 11px; }
.fee-cell input { width: 100%; min-width: 0; }
@media (max-width: 1100px) { .fee-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 860px) {
  .guard-grid, .guard-fixed-list { grid-template-columns: 1fr; }
  .fee-grid { grid-template-columns: repeat(2, 1fr); }
}

.stats { display: flex; flex-wrap: wrap; gap: 14px 46px; padding: 16px; }
.stat { display: grid; gap: 3px; }
.stat span { color: var(--text-3); font-size: 12px; }
.stat b.big { font-size: 20px; }

/* ------------------------------------------------------------ tables */

.table-scroll { overflow-x: auto; }
.board-wrap { overflow: visible; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  padding: 10px 13px; text-align: left; font-weight: 600; font-size: 11.5px;
  letter-spacing: 0.03em; text-transform: uppercase; white-space: nowrap;
  color: var(--text-3); border-bottom: 1px solid var(--line);
}
table.data td { padding: 9px 13px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; vertical-align: middle; }
table.data tr:last-child > td { border-bottom: 0; }
table.data th.num, table.data td.num { text-align: right; }
table.data .sub { font-size: 11.5px; color: var(--text-3); }
table.data .sub.pos { color: var(--pos); }
table.data .sub.neg { color: var(--neg); }

table.board th { position: sticky; top: var(--topbar-h); z-index: 2; background: var(--panel); }
table.board tr.row { cursor: pointer; }
table.board tr.row > td { padding-top: 7px; padding-bottom: 7px; transition: background var(--dur) var(--ease); }
table.board tr.row:hover > td, table.board tr.row.open > td { background: var(--accent-soft); }
table.board .rank { width: 46px; color: var(--text-3); }
table.board .spread { text-align: right; }
table.board .win { line-height: 1.4; }
.row-action { width: 1%; text-align: right; }

.expander {
  appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px; font: inherit; color: var(--text);
}
.expander b { font-size: 13.5px; font-weight: 650; letter-spacing: 0.02em; }
.chev {
  width: 7px; height: 7px; margin: 0 2px;
  border-right: 1.5px solid var(--text-3); border-bottom: 1.5px solid var(--text-3);
  transform: rotate(-45deg); transition: transform var(--dur) var(--ease);
}
.expander[aria-expanded="true"] .chev { transform: rotate(45deg); border-color: var(--accent-line); }

/* 机会页 · 最佳路径：两腿各一行，行内带该所的当前资费与结算周期 */
.route { white-space: nowrap; }
.route .legline { display: flex; align-items: center; }
.route .legline + .legline { margin-top: 2px; }
.route .fund,
.route-leg .fund {
  margin-left: 6px; font-size: 11.5px; font-variant-numeric: tabular-nums; color: var(--text-3);
}
.route .fund.pos, .route-leg .fund.pos { color: var(--pos); }
.route .fund.neg, .route-leg .fund.neg { color: var(--neg); }
.route-leg .legline + .legline { margin-top: 2px; }

.coverage { white-space: nowrap; }
.cov-dots { display: inline-flex; gap: 3px; margin-right: 8px; vertical-align: middle; }
.cov-dots i { width: 6px; height: 12px; border-radius: 2px; background: var(--line); }
.cov-dots i.on { background: var(--accent); }

tr.detail > td { padding: 0 0 0 46px !important; background: var(--bg); border-bottom: 1px solid var(--line) !important; }
table.routes th { position: static; background: transparent; }
table.routes tr.stale td { opacity: 0.5; }
.route-leg .venue { margin-right: 8px; }

/* ------------------------------------------------------------ form errors */

.form label, .ticket-body label { color: var(--text-2); font-size: 12px; margin-top: 5px; font-weight: 500; }
.form-error { min-height: 18px; color: var(--neg); font-size: 12.5px; }

.form { display: grid; gap: 7px; padding: 16px; max-width: 340px; }
.form .btn { margin-top: 7px; justify-self: start; }

/* ------------------------------------------------------------ trading */

.trade { display: grid; gap: 16px; }

.pair-head { display: flex; align-items: center; flex-wrap: nowrap; gap: 20px; padding: 10px 16px; }
.pair-id { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px 14px; flex: 0 1 auto; }
.pair-id h1 { font-family: var(--font-num); font-size: 23px; font-weight: 750; letter-spacing: 0.03em; margin-right: 4px; }
.pair-actions { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; flex-wrap: nowrap; gap: 10px; }
.pair-leg { display: inline-flex; align-items: baseline; gap: 2px; }
.pair-leg .venue { font-weight: 650; margin-right: 6px; }
.leg-vol { margin-left: 8px; font-size: 12px; font-variant-numeric: tabular-nums; }
.leg-vol.dim { color: var(--text-3); }
.route-select { max-width: 200px; height: 28px; font-size: 12px; }
.pair-stats { display: flex; gap: 26px; margin-left: auto; flex: 0 0 auto; }
.pair-stats .stat b.big { font-size: 17px; }

.pair-switcher { display: inline-flex; align-items: center; margin-left: 4px; }

/* Custom venue dropdown */
.vd { position: relative; display: inline-flex; }
.vd-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  height: 26px; padding: 0 10px 0 11px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 650; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-pill); cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.vd-trigger:hover { border-color: var(--accent); background: var(--panel); }
.vd.open .vd-trigger { border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
.vd-value { line-height: 1; }
.vd-caret {
  width: 8px; height: 8px; flex: 0 0 auto;
  border-right: 1.6px solid var(--text-2); border-bottom: 1.6px solid var(--text-2);
  transform: translateY(-1px) rotate(45deg);
  transition: transform .2s var(--ease);
}
.vd.open .vd-caret { transform: translateY(1px) rotate(225deg); }

.vd-menu {
  position: absolute; top: calc(100% + 7px); left: 0; z-index: 60;
  min-width: 168px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: vd-pop .16s var(--ease);
}
@keyframes vd-pop { from { opacity: 0; } to { opacity: 1; } }
.vd-option {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 9px; font-family: var(--font-ui); font-size: 13px; font-weight: 550;
  color: var(--text); background: transparent; border: 0; border-radius: var(--radius-s);
  cursor: pointer; text-align: left;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.vd-option:hover { background: var(--accent-soft); }
.vd-option[aria-selected="true"] { color: var(--accent-2); font-weight: 650; }
.vd-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.vd-opt-label { flex: 1 1 auto; }
.vd-check { width: 9px; height: 5px; flex: 0 0 auto; opacity: 0;
  border-left: 1.6px solid var(--accent-2); border-bottom: 1.6px solid var(--accent-2);
  transform: rotate(-45deg); }
.vd-option[aria-selected="true"] .vd-check { opacity: 1; }

.pick-leg { display: inline-flex; align-items: center; gap: 6px; }

/* Other-routes dropdown */
.route-dd-trigger { min-width: 178px; justify-content: space-between; }
.route-dd-menu {
  left: auto; right: 0; min-width: 290px;
  max-height: 360px; overflow-y: auto;
}
.route-option {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 10px; font-family: var(--font-ui); font-size: 12.5px;
  color: var(--text); background: transparent; border: 0;
  border-radius: var(--radius-s); cursor: pointer; text-align: left;
  transition: background .14s var(--ease);
}
.route-option:hover { background: var(--accent-soft); }
.route-option-label { flex: 1 1 auto; font-weight: 550; }
.route-option-ratio {
  flex: 0 0 auto; font-family: var(--font-num); font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.route-option-ratio.pos { color: var(--pos); }
.route-option-ratio.neg { color: var(--neg); }

.trade-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.trade-main, .trade-rail { display: grid; gap: 16px; min-width: 0; }

.legend { display: inline-flex; gap: 16px; color: var(--text-2); font-size: 12px; }
.swatch { display: inline-block; width: 12px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.swatch.entry { background: var(--warn); }
.swatch.exit { background: var(--accent-line); }
.swatch.long { background: var(--pos); }
.swatch.short { background: var(--neg); }
.swatch.spread { background: var(--accent-line); }
.swatch.mid { background: #8b9bb8; }

.chart-row { display: grid; grid-template-columns: minmax(0, 1fr) 250px; align-items: stretch; }
.chart-stack { display: grid; grid-template-rows: minmax(260px, 1.65fr) auto minmax(150px, 0.85fr); min-height: 520px; min-width: 0; }
.chart-wrap { position: relative; min-height: 0; }
.chart-wrap.funding { min-height: 150px; }
.chart-subhead {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 5px 11px 3px; border-top: 1px solid var(--line-soft);
}
.chart-wrap canvas, .chart-wrap #spread-chart, .chart-wrap #funding-chart {
  position: absolute; left: 4px; top: 6px; width: calc(100% - 4px); height: calc(100% - 6px); cursor: crosshair;
}
.chart-tip {
  position: absolute; top: 14px; z-index: 3; pointer-events: none;
  padding: 9px 11px; font-size: 12px; line-height: 1.7; white-space: nowrap;
  background: var(--panel-3); border: 1px solid var(--line); border-radius: var(--radius-s);
  box-shadow: var(--shadow);
}
.chart-tip b { font-family: var(--font-num); }
.chart-ind { position: relative; }
.ind-trigger.active { border-color: var(--accent); color: var(--accent-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.chart-ind-menu {
  position: absolute; left: 0; top: calc(100% + 7px); z-index: 60;
  min-width: 208px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  animation: vd-pop .16s var(--ease);
}
.ind-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; font-size: 13px; font-weight: 550; color: var(--text);
  border-radius: var(--radius-s); cursor: pointer;
  transition: background .14s var(--ease);
}
.ind-row:hover { background: var(--accent-soft); }
.ind-input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.ind-box {
  width: 16px; height: 16px; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1.5px solid var(--line);
  border-radius: 5px; transition: background .15s var(--ease), border-color .15s var(--ease);
}
.ind-tick {
  width: 8px; height: 4px; opacity: 0;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  transition: opacity .13s var(--ease);
}
.ind-input:checked + .ind-box { background: var(--accent); border-color: var(--accent); }
.ind-input:checked + .ind-box .ind-tick { opacity: 1; }
.ind-input:focus-visible + .ind-box { box-shadow: 0 0 0 3px var(--accent-soft); }
.ind-label { flex: 1 1 auto; }
.ind-sep { height: 1px; margin: 6px 8px; background: var(--line-soft); }

.books { border-left: 1px solid var(--line-soft); display: grid; grid-template-rows: 1fr 1fr; }
.book { padding: 10px 11px; min-height: 0; }
.book + .book { border-top: 1px solid var(--line-soft); }
.book-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; }
.book-state { font-size: 11.5px; }
.book-cols, .depth { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 6px; }
.book-cols { margin: 7px 0 3px; color: var(--text-3); font-size: 11px; }
.book-cols span:not(:first-child), .depth span:not(:first-of-type) { text-align: right; }
.book-rows .empty { padding: 32px 6px; font-size: 12px; }
.depth { position: relative; font-size: 11.5px; line-height: 20px; }
.depth .bar { position: absolute; right: 0; top: 1px; bottom: 1px; border-radius: 2px; opacity: 0.16; }
.depth.ask .bar { background: var(--neg); }
.depth.bid .bar { background: var(--pos); }
.depth.ask span:first-of-type { color: var(--neg); }
.depth.bid span:first-of-type { color: var(--pos); }
.depth span { position: relative; }
.depth-mid {
  display: flex; justify-content: space-between; align-items: baseline;
  margin: 4px 0; padding: 4px 0; font-size: 11.5px;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
.depth-mid b { font-family: var(--font-num); font-size: 13px; }

table.terminal td, table.terminal th { padding: 9px 11px; }
.lev-btn {
  appearance: none; cursor: pointer; font: inherit; color: var(--accent-line); font-weight: 550;
  background: none; border: 0; border-bottom: 1px dashed var(--accent); padding: 0;
}
.lev-input { width: 60px; height: 26px; padding: 0 7px; text-align: right; }

.ticket .panel-head { border-top: 1px solid var(--line-soft); }
.ticket-body { display: grid; gap: 7px; padding: 14px 16px 16px; }
.ticket-body .hint { padding: 0; }
.ticket-actions { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 9px; margin-top: 11px; }
/* Hedge ticket only: 估算 / 开仓 / 平仓 / 补单. Single-leg keeps the three columns above. */
#ticket-pair > .ticket-actions { grid-template-columns: 1fr 1.2fr 1fr 1fr; }
.quote-out:not(:empty) { margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line-soft); }
.quote-out .hint { padding: 0; }
.quote-out .hint.neg { color: var(--neg); }
.quote-out .hint.pos { color: var(--pos); }

.event-log { max-height: 260px; overflow-y: auto; padding: 5px 0; }
.event { display: grid; grid-template-columns: 64px 1fr; gap: 8px; padding: 6px 16px; font-size: 12px; overflow-wrap: anywhere; }
.event.ok { color: var(--pos); }
.event.err { color: var(--neg); }

/* ------------------------------------------------------------ overlays */

.toast-layer { position: fixed; right: 18px; bottom: calc(var(--status-h) + 16px); z-index: 60; display: grid; gap: 9px; justify-items: end; }
.toast {
  max-width: 420px; padding: 10px 14px; font-size: 12.5px;
  background: var(--panel-3); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius-s); box-shadow: var(--shadow);
  animation: toast-in 0.24s var(--ease);
}
.toast.err { border-left-color: var(--neg); }
@keyframes toast-in { from { opacity: 0; } to { opacity: 1; } }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(24, 27, 42, 0.34);
  backdrop-filter: blur(6px);
  animation: fade-in 0.2s var(--ease);
}
.modal {
  width: min(480px, 100%); display: grid; gap: 14px; padding: 22px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.24s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-note { color: var(--text-2); font-size: 12.5px; }
.form-modal { gap: 7px; }
.form-modal h2 { margin-bottom: 8px; }
.form-modal label { color: var(--text-2); font-size: 12px; margin-top: 5px; }
.form-modal .modal-note { margin-top: 8px; }
.field-hint { color: var(--text-3); font-size: 11.5px; }
.inline-form { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.inline-form input { width: 110px; text-align: right; }
.btn-row { display: inline-flex; gap: 7px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 11px; margin-top: 5px; }

/* ------------------------------------------------------------ small screens */

@media (max-width: 1180px) {
  .trade-grid { grid-template-columns: 1fr; }
  .pair-head { flex-wrap: wrap; }
  .pair-actions { flex-basis: 100%; flex-wrap: wrap; }
  .pair-stats { margin-left: 0; }
}
@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 11px; }
  .brand-name, .who { display: none; }
  .nav a { padding: 0 11px; }
  .app-main { padding: 12px 10px calc(var(--status-h) + 20px); }
  .chart-row { grid-template-columns: 1fr; }
  .chart-stack { min-height: 420px; grid-template-rows: minmax(220px, 1.5fr) auto minmax(140px, 0.9fr); }
  .chart-wrap { min-height: 0; }
  .books { border-left: 0; border-top: 1px solid var(--line-soft); grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .book + .book { border-top: 0; border-left: 1px solid var(--line-soft); }
  .feed-meta span:not(.feed-mode) { display: none; }
  .search { width: 100%; }
  tr.detail > td { padding-left: 0 !important; }
  table.board th { position: static; }
  .board-wrap { overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) {
  /* Landing page (body.is-landing) keeps its illustrative motion even when the
     OS asks to reduce animation; the signed-in terminal still respects it. */
  body:not(.is-landing) * { animation: none !important; transition: none !important; }
}

/* ------------------------------------------------------------ hedges / fees */
.sub-head { padding: 13px 16px 5px; color: var(--text-2); font-size: 12px; border-top: 1px solid var(--line); }
.inline-form.fees { gap: 9px 16px; }
.inline-form.fees label { display: inline-flex; align-items: center; gap: 6px; }
.inline-form.fees input { width: 66px; }
table.data .sub.pos { color: var(--pos); }

/* ----------------------------------------------------- balance donut chart */
.balance-chart {
  display: flex; align-items: center; justify-content: center; gap: 34px; flex-wrap: wrap;
  padding: 18px 20px 22px; border-bottom: 1px solid var(--line-soft);
}
.donut { width: 180px; flex: 0 0 auto; }
.donut svg { width: 180px; height: 180px; display: block; }
.donut-cap { fill: var(--text-2); font-size: 12px; }
.donut-total { fill: var(--text); font-family: var(--font-num); font-size: 22px; font-weight: 700; }
/* stroke grow: the mask ring sweeps away clockwise from the top */
.donut-mask-c { animation: donut-reveal 1.1s var(--ease) forwards; }
@keyframes donut-reveal { to { stroke-dashoffset: var(--donut-c); } }
@media (prefers-reduced-motion: reduce) {
  .donut-mask-c { animation: none; }
}
.balance-legend {
  list-style: none; margin: 0; padding: 0; flex: 0 1 280px;
  display: grid; gap: 10px; min-width: 220px;
}
.balance-legend li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.lg-name { color: var(--text); min-width: 90px; }
.lg-val { color: var(--text-2); margin-left: auto; }
.lg-pct { color: var(--accent-line); font-weight: 650; min-width: 52px; text-align: right; }

@media (max-width: 760px) {
  .balance-chart { gap: 18px; justify-content: center; }
}

/* -------------------------------- market & trading polish (purely cosmetic) */
/* Group the market filter controls into one inset toolbar card. */
.page-market .toolbar {
  margin: 14px 16px 6px; padding: 12px 14px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius-s);
}
.page-market .board-wrap { padding: 6px 8px 8px; }

/* (pair switcher is folded inline into the header, no inset card needed) */
@media (max-width: 860px) {
  .page-market .toolbar { margin: 12px 10px 4px; }
  .page-market .board-wrap { padding: 4px; }
}

/* --------------------------------------------- trading multi-tab workspace */
/* Body-level persistent workspace: hidden on other routes, never unmounted. */
.trade-tabs {
  position: fixed; z-index: 15;
  top: 22px; left: calc(var(--sidebar-w) + 24px); right: 24px;
  bottom: calc(var(--status-h) + 26px);
  display: flex; flex-direction: column;
}
body[data-collapsed="true"] .trade-tabs { left: calc(var(--sidebar-collapsed-w) + 24px); }
@keyframes tt-workspace-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.trade-tabs:not([hidden]) { animation: tt-workspace-in 0.3s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  .trade-tabs:not([hidden]) { animation: none; }
  .vd-menu, .chart-ind-menu { animation: none; }
  .vd-caret, .vd-trigger, .vd-option { transition: none; }
}

.tt-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 0 2px 10px;
  overflow-x: auto; scrollbar-width: none;
}
.tt-strip::-webkit-scrollbar { display: none; }

.tt-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 8px 0 13px;
  font: inherit; font-size: 12.5px; font-weight: 550;
  color: var(--text-2); background: var(--panel-2);
  border: 1px solid var(--line); border-radius: var(--radius-pill);
  cursor: pointer; user-select: none;
  transition: color 0.2s var(--ease), background 0.2s var(--ease),
    border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.tt-tab:hover { color: var(--text); border-color: var(--line); box-shadow: 0 1px 3px rgba(24, 27, 42, 0.07); }
.tt-tab.active {
  color: var(--accent-ink); background: var(--accent);
  border-color: var(--accent);
}
.tt-tab-name { white-space: nowrap; letter-spacing: 0.01em; }

.tt-tab-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 14px; line-height: 1; color: currentColor;
  opacity: 0.65; transition: opacity 0.18s var(--ease), background 0.18s var(--ease);
}
.tt-tab-close:hover { opacity: 1; background: rgba(24, 27, 42, 0.12); }
.tt-tab.active .tt-tab-close:hover { background: rgba(255, 255, 255, 0.28); }

.tt-viewport {
  position: relative;
  flex: 1 1 auto; min-height: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.tt-pane { position: absolute; inset: 0; }
.tt-frame { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.tt-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center;
}

/* Embedded trading page (inside a tab): drop the surrounding frame. */
body.is-embed .sidebar,
body.is-embed .topbar,
body.is-embed .statusbar { display: none !important; }
body.is-embed .app-main {
  margin-left: 0; padding: 0; min-height: 100vh;
}

/* ------------------------------------------------------------- mobile */
/* Phone adaptation, fully scoped under the breakpoint; desktop is untouched. */
.nav-burger, .nav-backdrop { display: none; }

@media (max-width: 760px) {
  :root { --topbar-h: 46px; }

  .nav-burger {
    display: grid; place-items: center;
    position: fixed; top: 10px; left: 10px; z-index: 45;
    width: 42px; height: 42px; border-radius: 10px;
    background: var(--panel); border: 1px solid var(--line); color: var(--text);
    box-shadow: var(--shadow);
  }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(10, 12, 18, 0.45);
    opacity: 0; pointer-events: none; transition: opacity 0.25s var(--ease);
  }
  body[data-nav="open"] .nav-backdrop { opacity: 1; pointer-events: auto; }

  .sidebar-inner {
    transform: translateX(-100%); z-index: 40;
    transition: transform 0.28s var(--ease);
  }
  body[data-nav="open"] .sidebar-inner { transform: translateX(0); }
  .sb-collapse { display: none; }

  .app-main { margin-left: 0; padding: 64px 14px calc(var(--status-h) + 20px); }
  .topbar { margin-left: 0; }

  /* trading: collapse the two-column workspace into one. */
  .trade-grid { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .chart-stack {
    min-height: 420px;
    grid-template-rows: minmax(220px, 1.5fr) auto minmax(140px, 0.9fr);
  }
  .books {
    border-left: 0; border-top: 1px solid var(--line-soft);
    grid-template-rows: none; grid-template-columns: 1fr 1fr;
  }
  .book + .book { border-top: 0; border-left: 1px solid var(--line-soft); }

  /* persistent tab workspace fills the small viewport. */
  .trade-tabs { left: 12px; right: 12px; top: 10px; }

  /* wide tables stay usable: panels scroll horizontally instead of crushing. */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* touch targets + avoid iOS focus zoom. */
  .btn { min-height: 40px; }
  input, select, textarea { font-size: 16px; }
}

/* ============================================================================
   Hedge World v2 — 墨 (dark, default) / 纸 (light).
   Overrides the tokens above; components below only re-shape what tokens
   cannot (square corners, mono numbers, numbered nav, page titles).
   ========================================================================== */

:root {
  /* 纸 · paper (light) */
  --bg: #ffffff;
  --bg-glow-1: transparent;
  --bg-glow-2: transparent;
  --rail: #f3f3f3;
  --panel: #ffffff;
  --panel-2: #f5f5f5;
  --panel-3: #eeeeee;
  --line: #e2e2e2;
  --line-soft: #ececec;
  --text: #15130F;
  --text-2: #4A443A;
  --text-3: #6E6656;
  --accent: #15130F;
  --accent-2: #2E2A23;
  --accent-soft: rgba(21, 19, 15, 0.08);
  --accent-line: #15130F;
  --accent-ink: #ffffff;
  --gradient: #15130F;
  --brand: #C2281F;
  --pos: #0B6E41;
  --neg: #B8322A;
  --warn: #875600;
  --chart-entry: #15130F;
  --chart-exit: #C2281F;

  --font-ui: "Noto Sans SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI",
    "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --font-display: "Archivo", "Bahnschrift", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;

  --radius: 2px;
  --radius-s: 2px;
  --radius-pill: 2px;
  --shadow: none;
  --shadow-lg: 0 24px 60px rgba(21, 19, 15, 0.25);
  --glow: 0 0 0 2px rgba(21, 19, 15, 0.25);
}

[data-theme="dark"] {
  /* 墨 · ink (dark) */
  --bg: #0F0E0C;
  --rail: #0B0A09;
  --panel: #13120F;
  --panel-2: #1A1915;
  --panel-3: #24221D;
  --line: #2C2923;
  --line-soft: #211F1A;
  --text: #EFE8D8;
  --text-2: #B5AD9C;
  --text-3: #8C8473;
  --accent: #EFE8D8;
  --accent-2: #FFFFFF;
  --accent-soft: rgba(239, 232, 216, 0.10);
  --accent-line: #EFE8D8;
  --accent-ink: #0F0E0C;
  --gradient: #EFE8D8;
  --brand: #F0533E;
  --pos: #4ADE9B;
  --neg: #FF6F61;
  --warn: #E8B04B;
  --chart-entry: #EFE8D8;
  --chart-exit: #F0533E;
  --shadow: none;
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.6);
  --glow: 0 0 0 2px rgba(239, 232, 216, 0.35);
}

body { background: var(--bg); }
a:hover { color: var(--text); }
::selection { background: color-mix(in srgb, var(--brand) 35%, transparent); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: padding-box; }
.num, .big { font-family: var(--font-num); font-variant-numeric: tabular-nums; }

/* -- rail ------------------------------------------------------------------ */
.sidebar-inner { background: var(--rail); border-right-color: var(--line-soft); }
.brand-mark { border-radius: 0; background: var(--brand); box-shadow: none; padding: 5px; }
.brand-mark svg polyline { stroke: var(--bg); }
.brand-mark svg circle { fill: var(--bg); }
.brand-name {
  font-family: var(--font-display); font-stretch: 62%; font-weight: 900;
  font-size: 22px; letter-spacing: 0.01em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.sb-header .brand { min-width: 0; }
.fs-list { counter-reset: nav; gap: 2px; }
.menu-list-item { counter-increment: nav; }
.nav-link { border-radius: 0; font-size: 14px; font-weight: 500; }
.nav-link:hover { transform: none; background: var(--panel-2); }
.nav-link::before { width: 2px; height: 100%; border-radius: 0; background: var(--brand); top: 0; transform: scaleY(0); }
.menu-list-item.current .nav-link::before { transform: scaleY(1); }
.menu-list-item.current .nav-link { background: var(--panel-2); color: var(--text); font-weight: 600; }
.nav-link-text::before {
  content: counter(nav, decimal-leading-zero);
  margin-right: 12px; font-family: var(--font-num); font-size: 11px; font-weight: 400; color: var(--text-3);
}
.sb-icon { display: none; }
body[data-collapsed="true"] .sb-icon, .nav-burger .sb-icon { display: grid; }
@media (max-width: 760px) { .statusbar { left: 0; } }
.sb-footer { border-top-color: var(--line-soft); }
.sb-user { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sb-avatar { border-radius: 0 !important; font-family: var(--font-num); }
body[data-collapsed="true"] .sb-user .theme-seg { display: none; }

/* 墨 / 纸 switch (replaces the lever) */
.theme-seg { display: inline-flex; border: 1px solid var(--line); flex-shrink: 0; }
.theme-seg button {
  appearance: none; cursor: pointer; border: 0; height: 26px; padding: 0 9px;
  font: 500 11px/1 var(--font-num); color: var(--text-3); background: transparent;
}
.theme-seg button + button { border-left: 1px solid var(--line); }
.theme-seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.panel > .theme-row { margin: 0 16px 16px; }
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); color: var(--text-2); font-size: 12.5px; }

/* -- status line ----------------------------------------------------------- */
.statusbar {
  background: var(--rail); backdrop-filter: none; border-top-color: var(--line-soft);
  font-family: var(--font-num); font-size: 11px; letter-spacing: 0.04em;
}
.venue-link span { text-transform: uppercase; }
.dot.up { box-shadow: none; }
.topbar { background: var(--panel); backdrop-filter: none; }

/* -- page header (added by the router) ------------------------------------ */
.page-head {
  display: flex; align-items: baseline; gap: 14px;
  margin: 2px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.page-head .page-no { font-family: var(--font-num); font-size: 12px; color: var(--brand); }
.page-head h1 { font-family: var(--font-serif); font-weight: 900; font-size: 38px; line-height: 1; letter-spacing: 0; }
.page-positions .panel-head > h1,
.page-portfolio .panel-head > h1 { display: none; }
.panel-head h1, .panel-head h2 { font-family: var(--font-serif); font-weight: 900; }
.panel-head h2 { font-size: 18px; }

/* -- building blocks ------------------------------------------------------- */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: none; }
.panel-head { border-bottom-color: var(--line-soft); }
.btn { border-radius: var(--radius-s); background: transparent; }
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: none; font-weight: 700; }
.btn.primary:hover { background: var(--accent-2); box-shadow: none; }
.chip.on { box-shadow: none; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg { background: transparent; }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.tabs button.on { border-bottom-color: var(--accent); font-weight: 700; }
input, select { background: var(--bg); border-radius: var(--radius-s); }
input:focus, select:focus { border-color: var(--accent); }
.tag { border-radius: 0; font-family: var(--font-num); }
.side { border-radius: 0; }
.toast { border-left-color: var(--brand); }
.modal-backdrop { background: rgba(10, 9, 8, 0.6); }

/* -- tables ---------------------------------------------------------------- */
table.data th { font-family: var(--font-num); font-weight: 500; font-size: 11px; letter-spacing: 0.04em; }
table.data td { border-bottom-color: var(--line-soft); }
table.board tr.row:hover > td, table.board tr.row.open > td { background: var(--panel-2); }
.cov-dots i { border-radius: 0; }
.cov-dots i.on { background: var(--text-2); }
.expander b { font-family: var(--font-num); }
.pair-id h1 { font-family: var(--font-display); font-stretch: 62%; font-weight: 900; font-size: 40px; letter-spacing: 0.01em; line-height: 0.9; }
.page-market .toolbar { background: transparent; border-color: var(--line-soft); }

/* settings · exchange key cards: flat tiles instead of photo cards */
.cc-card { border-radius: 0; background: var(--panel-2); border: 1px solid var(--line); }
.cc-card::after { background: linear-gradient(to top, var(--panel-2) 0, transparent 70%); }
.cc-img svg { filter: grayscale(1) brightness(0.55) contrast(1.1); opacity: 0.35; }
.cc-card.active .cc-img svg { filter: grayscale(0.4) brightness(0.8); opacity: 0.55; }
.cc-content { color: var(--text); }
.status-pill { border-radius: 0; font-family: var(--font-num); }
.status-pill.on { background: transparent; color: var(--pos); border: 1px solid var(--pos); }
.status-pill.off { background: transparent; color: var(--warn); border: 1px solid var(--warn); }
.cc-fp .dim, .cc-date { color: var(--text-3); }
.cc-fp .inst { color: var(--text); }
.cc-actions .btn { background: var(--bg); border-color: var(--line); color: var(--text); }
.cc-actions .btn:hover { background: var(--panel-3); }
.cc-actions .btn.danger { background: transparent; border-color: var(--neg); color: var(--neg); }
.cc-v-title { color: var(--text-2); }

/* trading workspace tabs: square, underline the active one */
.tt-tab { font-family: var(--font-num); font-size: 12px; background: transparent; }
.tt-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tt-viewport { border-radius: var(--radius); }

/* ============================================================================
   Public landing v2 — terminal edition. Always dark, scoped to .lp.
   ========================================================================== */

body.is-landing { background: #0A0908; }
body.is-landing .app-main { margin-left: 0; padding: 0; min-height: 100vh; background: #0A0908; }

.lp, .lp-overlay-root {
  --lp-bg: #0A0908; --lp-panel: #12110E; --lp-panel-2: #0E0D0B;
  --lp-line: #2C2923; --lp-line-soft: #211F1A; --lp-bone: #EFE8D8;
  --lp-text-2: #B5AD9C; --lp-text-3: #8C8473;
  --lp-pos: #4ADE9B; --lp-neg: #FF6F61; --lp-warn: #E8B04B; --lp-brand: #F0533E;
  --lp-pad: clamp(20px, 4vw, 56px);
  --lp-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --lp-display: "Archivo", "Bahnschrift", "Arial Narrow", "Roboto Condensed", sans-serif;
  --lp-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
.lp {
  min-height: 100vh; overflow: hidden; color: var(--lp-bone); font-family: var(--lp-sans); font-size: 14px;
  background-color: var(--lp-bg);
  background-image: radial-gradient(#25221C 1px, transparent 1px); background-size: 24px 24px;
}
.lp h1, .lp h2, .lp h3 { margin: 0; }
.lp .pos { color: var(--lp-pos); } .lp .neg { color: var(--lp-neg); } .lp .dim { color: var(--lp-text-3); }
.lp-mono { font-family: var(--lp-mono); }
.lp-wordmark { font-family: var(--lp-display); font-stretch: 62%; font-weight: 900; text-transform: uppercase; letter-spacing: 0.01em; white-space: nowrap; }
.lp button { font: inherit; color: inherit; }

/* nav */
.lp-nav {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px var(--lp-pad); border-bottom: 1px solid var(--lp-line-soft); background: rgba(10, 9, 8, 0.85);
}
.lp-logo { display: inline-flex; align-items: center; gap: 10px; }
.lp-logo .lp-wordmark { font-size: 24px; }
.lp-mark { width: 28px; height: 28px; display: grid; place-items: center; background: var(--lp-brand); color: var(--lp-bg); }
.lp-mark svg { width: 18px; height: 18px; }
.lp-navlinks { display: flex; gap: 6px; }
.lp-navlink {
  appearance: none; background: none; border: 0; cursor: pointer; padding: 8px 10px;
  font-family: var(--lp-mono) !important; font-size: 12px; letter-spacing: 0.08em; color: var(--lp-text-2) !important;
}
.lp-navlink:hover { color: var(--lp-bone) !important; }
.lp-nav-right { display: flex; align-items: center; gap: 18px; }
.lp-health { display: inline-flex; align-items: center; gap: 8px; font: 11px var(--lp-mono); color: var(--lp-text-2); letter-spacing: 0.06em; }
.lp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lp-pos); display: inline-block; }
.lp-health.is-down { color: var(--lp-neg); }
.lp-health.is-down .lp-dot { background: transparent; border: 2px solid var(--lp-neg); box-sizing: border-box; }

/* buttons */
.lp-btn {
  appearance: none; cursor: pointer; border: 0; display: inline-flex; align-items: center; gap: 14px;
  height: 56px; padding: 0 28px; background: var(--lp-bone); color: var(--lp-bg) !important;
  font-size: 16px !important; font-weight: 800 !important; transition: background 0.12s ease-out;
}
.lp-btn:hover { background: #fff; }
.lp-btn:focus-visible, .lp-btn-ghost:focus-visible, .lp-navlink:focus-visible { outline: 2px solid var(--lp-bone); outline-offset: 3px; }
.lp-btn-sm { height: 40px; padding: 0 18px; font-size: 14px !important; font-weight: 700 !important; gap: 10px; }
.lp-btn-lg { height: 60px; padding: 0 32px; font-size: 17px !important; }
.lp-btn-ghost {
  appearance: none; cursor: pointer; background: none; height: 56px; padding: 0 22px;
  border: 1px solid #3A362E; font-family: var(--lp-mono) !important; font-size: 13px !important; letter-spacing: 0.06em;
}
.lp-btn-ghost:hover { border-color: var(--lp-bone); }

/* tape */
.lp-tape {
  display: flex; align-items: center; height: 40px; overflow: hidden;
  border-bottom: 1px solid var(--lp-line-soft); background: var(--lp-panel-2); font: 12px var(--lp-mono);
}
.lp-tape-tag {
  flex: none; height: 100%; display: flex; align-items: center; padding: 0 14px; position: relative; z-index: 1;
  background: var(--lp-brand); color: var(--lp-bg); font-weight: 600; letter-spacing: 0.08em;
}
.lp-tape-track { display: flex; gap: 36px; padding-left: 24px; white-space: nowrap; animation: lp-tape 40s linear infinite; }
@keyframes lp-tape { to { transform: translateX(-50%); } }

/* hero */
.lp-hero {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 48px;
  overflow: hidden; min-height: 640px; padding: 72px var(--lp-pad) 64px; box-sizing: border-box;
}
.lp-bull {
  position: absolute; right: -80px; top: -40px; width: 760px; height: 760px; object-fit: contain;
  opacity: 0.2; pointer-events: none;
}
.lp-hero-copy { position: relative; flex: 1 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 26px; }
.lp-kicker { font: 12px var(--lp-mono); letter-spacing: 0.16em; color: var(--lp-pos); }
.lp-hero h1 { font-weight: 900; font-size: clamp(52px, 6.4vw, 92px); line-height: 1.02; letter-spacing: -0.02em; }
.lp-hl { color: var(--lp-pos); }
.lp-caret { color: var(--lp-brand); animation: lp-blink 1s steps(1) infinite; }
@keyframes lp-blink { 50% { opacity: 0; } }
.lp-lede { margin: 0; max-width: 540px; font-size: 18px; line-height: 1.75; color: var(--lp-text-2); }
.lp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }

/* live card */
.lp-card {
  position: relative; flex: 1 1 460px; min-width: 0; margin: 0;
  background: rgba(18, 17, 14, 0.92); border: 1px solid var(--lp-line);
  box-shadow: 0 0 0 1px var(--lp-bg), 0 40px 80px rgba(0, 0, 0, 0.5);
}
.lp-card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--lp-line-soft); font: 11px var(--lp-mono); color: var(--lp-text-3); }
.lp-card-pair { display: flex; align-items: baseline; gap: 12px; }
.lp-card-pair b { color: var(--lp-bone); font-size: 13px; }
.lp-live { display: inline-flex; align-items: center; gap: 6px; }
.lp-live .lp-dot { width: 6px; height: 6px; }
.lp-metrics { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.2fr 0.9fr; align-items: end; border-bottom: 1px solid var(--lp-line-soft); font-family: var(--lp-mono); }
.lp-metric { padding: 10px 14px; min-width: 0; }
.lp-metric + .lp-metric { border-left: 1px solid var(--lp-line-soft); }
.lp-metric-k { font-size: 10px; color: var(--lp-text-3); white-space: nowrap; }
.lp-metric-v { font-size: 17px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lp-metric-v.dim { color: var(--lp-text-2) !important; }
.lp-metric-hero .lp-metric-v { font-family: var(--lp-display); font-stretch: 75%; font-size: 40px; font-weight: 800; line-height: 1; }
.lp-dir { font: 13px var(--lp-mono); margin-left: 6px; }
.lp-chart { display: block; width: 100%; height: auto; }
.lp-card-foot { display: grid; grid-template-columns: 1fr 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--lp-line-soft); font: 12px var(--lp-mono); }
.lp-card-btn { height: 34px; display: inline-flex; align-items: center; padding: 0 14px; background: var(--lp-bone); color: var(--lp-bg); font: 700 13px var(--lp-sans); }
.lp-pulse { animation: lp-pulse 1.6s ease-in-out infinite; }
@keyframes lp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* kpis */
.lp-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); border-top: 1px solid var(--lp-line-soft); border-bottom: 1px solid var(--lp-line-soft); background: var(--lp-panel-2); }
.lp-kpi { padding: 22px 24px; display: flex; flex-direction: column; gap: 6px; }
.lp-kpi:first-child { padding-left: var(--lp-pad); }
.lp-kpi + .lp-kpi { border-left: 1px solid var(--lp-line-soft); }
.lp-kpi-v { font-family: var(--lp-display); font-stretch: 70%; font-weight: 900; font-size: 52px; line-height: 0.9; }
.lp-kpi-v small { font-size: 22px; color: var(--lp-text-3); }
.lp-kpi-k { font: 11px var(--lp-mono); color: var(--lp-text-3); letter-spacing: 0.06em; }

/* sections */
.lp-sec { padding: 80px var(--lp-pad); border-top: 1px solid var(--lp-line-soft); display: flex; flex-direction: column; gap: 40px; }
.lp-kpis + .lp-sec { border-top: 0; }
.lp-sec-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 20px; }
.lp-sec-title { display: flex; flex-direction: column; gap: 12px; }
.lp-sec-no { font: 12px var(--lp-mono); color: var(--lp-brand); letter-spacing: 0.12em; }
.lp-sec h2 { font-weight: 900; font-size: 44px; line-height: 1.1; }
.lp-sec-desc { margin: 0; max-width: 440px; font-size: 15px; line-height: 1.75; color: var(--lp-text-2); }
.lp-k { font: 11px var(--lp-mono); color: var(--lp-text-3); letter-spacing: 0.14em; }

/* network */
.lp-net { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); align-items: center; }
.lp-net-col { display: flex; flex-direction: column; gap: 14px; }
.lp-net-row { display: flex; align-items: center; }
.lp-venue { flex: none; width: 170px; padding: 12px 14px; border: 1px solid var(--lp-line); background: var(--lp-panel); font: 12px var(--lp-mono); display: flex; flex-direction: column; gap: 2px; }
.lp-venue b { font-size: 14px; }
.lp-venue.is-quote { border-style: dashed; border-color: #3A362E; }
.lp-wire { flex: 1; height: 1px; background: var(--lp-line); position: relative; }
.lp-wire.dashed { background: none; border-top: 1px dashed #3A362E; }
.lp-pkt { position: absolute; top: -2px; left: 0; width: 5px; height: 5px; background: var(--lp-pos); animation: lp-pkt 2.2s linear infinite; }
.lp-pkt.rev { left: auto; right: 0; animation-name: lp-pkt-rev; }
.lp-pkt.is-warn { background: var(--lp-warn); }
.lp-pkt.is-quote { background: var(--lp-text-3); }
@keyframes lp-pkt { from { left: 0; } to { left: 100%; } }
@keyframes lp-pkt-rev { from { right: 0; } to { right: 100%; } }
.lp-engine { border: 1px solid var(--lp-bone); background: var(--lp-panel); padding: 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.lp-engine-name { font-size: 44px; line-height: 0.9; }
.lp-engine-parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; width: 100%; font: 11px var(--lp-mono); color: var(--lp-text-2); }
.lp-engine-parts span { border: 1px solid var(--lp-line); padding: 6px; }

/* pipeline */
.lp-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); border-top: 1px solid var(--lp-bone); }
.lp-steps li { position: relative; padding: 22px 22px 0 0; display: flex; flex-direction: column; gap: 10px; }
.lp-steps li::before { content: ""; position: absolute; top: -6px; left: 0; width: 11px; height: 11px; background: var(--lp-bone); }
.lp-steps li.is-go::before { background: var(--lp-pos); }
.lp-steps li.is-warn::before { background: var(--lp-warn); }
.lp-step-no { font: 12px var(--lp-mono); color: var(--lp-text-3); }
.lp-steps li.is-go .lp-step-no { color: var(--lp-pos); }
.lp-steps li.is-warn .lp-step-no { color: var(--lp-warn); }
.lp-steps h3 { font-size: 22px; font-weight: 900; }
.lp-steps p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--lp-text-2); }

/* event log */
.lp-split { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 48px; }
.lp-split-copy { flex: 1 1 340px; display: flex; flex-direction: column; gap: 16px; }
.lp-log { flex: 2 1 620px; min-width: 0; margin: 0; border: 1px solid var(--lp-line); background: var(--lp-panel-2); font: 13px var(--lp-mono); }
.lp-log-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--lp-line-soft); font-size: 11px; color: var(--lp-text-3); }
.lp-log-body { padding: 16px; display: flex; flex-direction: column; gap: 7px; line-height: 1.5; overflow-x: auto; white-space: nowrap; }
.lp-log-line { display: flex; gap: 16px; }
.lp-log-tag { color: var(--lp-bone); }
.lp-log-tag.go { color: var(--lp-pos); }
.lp-log-tag.dim { color: var(--lp-text-2); }
.lp-log .lp-caret { color: var(--lp-bone); }

/* spec */
.lp-spec { background: var(--lp-panel-2); gap: 28px; padding-top: 72px; padding-bottom: 72px; }
.lp-spec-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); column-gap: 40px; font: 13px/1.6 var(--lp-mono); }
.lp-spec-grid div { padding: 14px 0; border-top: 1px solid var(--lp-line); }
.lp-spec-grid dt { font-size: 11px; color: var(--lp-text-3); }
.lp-spec-grid dd { margin: 4px 0 0; }

/* finale + footer */
.lp-final { padding: 96px var(--lp-pad); border-top: 1px solid var(--lp-line-soft); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 32px; }
.lp-final h2 { font-weight: 900; font-size: clamp(44px, 6vw, 84px); line-height: 1.05; }
.lp-foot { padding: 18px var(--lp-pad); border-top: 1px solid var(--lp-line-soft); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; font-size: 12px; line-height: 1.7; color: var(--lp-text-3); }
.lp-foot .lp-mono { font-size: 11px; }

/* login ticket */
.lp-auth { position: fixed; inset: 0; z-index: 80; display: grid; grid-template-columns: minmax(0, 460px); place-content: center; padding: 16px; visibility: hidden; opacity: 0; transition: opacity 0.18s ease-out, visibility 0.18s; }
.lp-overlay-root[data-auth="open"] .lp-auth { visibility: visible; opacity: 1; }
.lp-auth-backdrop { position: absolute; inset: 0; background: rgba(10, 9, 8, 0.72); backdrop-filter: blur(8px); }
.lp-ticket {
  position: relative; width: 100%; min-width: 0; box-sizing: border-box; background: var(--lp-panel); border: 1px solid var(--lp-line);
  color: var(--lp-bone); font-family: var(--lp-sans); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: translateY(8px); transition: transform 0.18s ease-out;
}
.lp-overlay-root[data-auth="open"] .lp-ticket { transform: none; }
.lp-ticket-main { padding: 28px 32px; display: flex; flex-direction: column; gap: 8px; }
.lp-ticket-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.lp-ticket-top > div { display: flex; flex-direction: column; gap: 6px; }
.lp-ticket-k { font: 600 11px var(--lp-mono); letter-spacing: 0.14em; color: var(--lp-brand); }
.lp-ticket-name { font-size: clamp(30px, 9vw, 44px); line-height: 0.9; overflow: hidden; text-overflow: ellipsis; }
.lp-ticket-top > div { min-width: 0; }
.lp-ticket-close { appearance: none; width: 44px; height: 44px; margin: -8px -12px 0 0; background: none; border: 0; color: var(--lp-bone); cursor: pointer; display: grid; place-items: center; }
.lp-ticket-close svg { width: 20px; height: 20px; }
.lp-ticket h2 { margin: 0 0 8px; font-size: 26px; font-weight: 900; }
.lp-ticket label { margin-top: 10px; font: 11px var(--lp-mono); letter-spacing: 0.12em; color: var(--lp-text-2); }
.lp-ticket input {
  height: 44px; padding: 0; background: transparent; border: 0; border-bottom: 2px solid var(--lp-line);
  border-radius: 0; color: var(--lp-bone); font: 18px var(--lp-mono); box-shadow: none;
}
.lp-ticket input:focus { outline: none; border-bottom-color: var(--lp-bone); box-shadow: none; }
.lp-ticket input[aria-invalid="true"] { border-bottom-color: var(--lp-neg); }
.lp-ticket input::placeholder { color: #5E584D; }
.lp-auth-error { min-height: 20px; margin: 8px 0 0; font-size: 13px; color: var(--lp-neg); }
.lp-auth-submit {
  appearance: none; cursor: pointer; border: 0; margin-top: 6px; height: 56px; padding: 0 22px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--lp-bone); color: var(--lp-bg); font: 700 16px var(--lp-sans);
}
.lp-auth-submit:hover { background: #fff; }
.lp-auth-submit:disabled { opacity: 0.7; cursor: progress; }
.lp-ticket-perf { position: relative; height: 0; margin: 0 18px; border-top: 2px dashed #3A362E; }
.lp-ticket-perf::before, .lp-ticket-perf::after { content: ""; position: absolute; top: -15px; width: 28px; height: 28px; border-radius: 50%; background: #0D0C0A; }
.lp-ticket-perf::before { left: -33px; } .lp-ticket-perf::after { right: -33px; }
.lp-ticket-stub { display: flex; justify-content: space-between; gap: 16px; padding: 16px 32px 20px; font: 11px/1.6 var(--lp-mono); color: var(--lp-text-3); }
.lp-ticket-stub span:last-child { text-align: right; }

/* responsive */
@media (max-width: 1000px) {
  .lp-net { grid-template-columns: 1fr; gap: 20px; }
  .lp-net-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
  .lp-net-row .lp-wire { display: none; }
  .lp-venue { width: auto; flex: 1; }
  .lp-engine { order: -1; }
}
@media (max-width: 760px) {
  .lp-navlinks, .lp-health span { display: none; }
  .lp-hero { padding-top: 40px; min-height: 0; }
  .lp-bull { width: 420px; height: 420px; right: -120px; top: 0; }
  .lp-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lp-metric-hero { grid-column: 1 / -1; }
  .lp-metric:nth-child(4) { border-left: 0; }
  .lp-metric:nth-child(n+2) { border-top: 1px solid var(--lp-line-soft); }
  .lp-kpi, .lp-kpi:first-child { padding: 18px 20px; }
  .lp-kpi-v { font-size: 40px; }
  .lp-sec { padding-top: 56px; padding-bottom: 56px; }
  .lp-sec h2 { font-size: 32px; }
  .lp-final { padding-top: 64px; padding-bottom: 64px; }
  .lp-btn { width: 100%; justify-content: space-between; }
  .lp-btn-sm { width: auto; }
  .lp-btn-ghost { width: 100%; }
  .lp-ticket-main { padding: 24px 22px; }
  .lp-ticket-stub { padding: 14px 22px 18px; }
}

