:root {
  color-scheme: dark;
  --bg: #02040a;
  --panel: rgba(5, 12, 20, .86);
  --panel-solid: #07101a;
  --panel-2: #0a1622;
  --line: rgba(111, 214, 229, .15);
  --line-hot: rgba(0, 255, 220, .43);
  --text: #cfe9ff;
  --text-strong: #eefcff;
  --muted: #6f8ba2;
  --primary: #00ffdc;
  --cyan: #65e7ff;
  --violet: #8b75ff;
  --amber: #ffc862;
  --red: #ff5f78;
  --shadow: rgba(0, 0, 0, .72);
  --grid: rgba(42, 214, 204, .045);
  --scan: rgba(0, 0, 0, .15);
  --display: Bahnschrift, "DIN Alternate", "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: rgba(255, 255, 255, .88);
  --panel-solid: #ffffff;
  --panel-2: #eef3f8;
  --line: rgba(35, 65, 92, .14);
  --line-hot: rgba(57, 74, 226, .48);
  --text: #253248;
  --text-strong: #111827;
  --muted: #69788d;
  --primary: #3d4fe4;
  --cyan: #087f8c;
  --violet: #6d28d9;
  --amber: #a86000;
  --red: #c92c4c;
  --shadow: rgba(37, 51, 82, .14);
  --grid: rgba(57, 74, 226, .045);
  --scan: rgba(71, 89, 119, .035);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0;
  cursor: crosshair;
  transition: color .28s ease, background-color .28s ease;
}
button, input { font: inherit; letter-spacing: 0; }
button, a, [tabindex] { cursor: pointer; }

.ambient-canvas, .grid-floor, .scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
.ambient-canvas { z-index: -3; width: 100%; height: 100%; }
.grid-floor {
  z-index: -2;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, #000 12%, #000 88%, transparent);
  animation: gridScroll 18s linear infinite;
}
.scanline {
  z-index: 40;
  background:
    linear-gradient(to bottom, transparent 0, transparent 48%, rgba(101, 231, 255, .045) 50%, transparent 52%),
    repeating-linear-gradient(0deg, transparent 0, transparent 3px, var(--scan) 4px);
  background-size: 100% 180px, 100% 4px;
  opacity: .7;
  animation: scan 7s linear infinite;
}
@keyframes gridScroll { to { background-position: 0 42px, 42px 0; } }
@keyframes scan { to { background-position: 0 180px, 0 0; } }

.cursor-sight {
  position: fixed;
  z-index: 60;
  width: 22px;
  height: 22px;
  border: 1px solid var(--primary);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-50%, -50%, 0) rotate(45deg);
  box-shadow: 0 0 16px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: width .16s ease, height .16s ease, border-color .16s ease, opacity .16s ease;
}
.cursor-sight::before, .cursor-sight::after, .cursor-sight i::before, .cursor-sight i::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border-color: var(--primary);
  border-style: solid;
}
.cursor-sight::before { inset: -3px auto auto -3px; border-width: 1px 0 0 1px; }
.cursor-sight::after { inset: -3px -3px auto auto; border-width: 1px 1px 0 0; }
.cursor-sight i::before { inset: auto auto -3px -3px; border-width: 0 0 1px 1px; }
.cursor-sight i::after { inset: auto -3px -3px auto; border-width: 0 1px 1px 0; }
.cursor-sight.visible { opacity: .78; }
.cursor-sight.locked { width: 34px; height: 34px; border-color: var(--violet); }

.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 92%, transparent);
  backdrop-filter: blur(18px);
}
.rail::after, .topbar::after, .data-section::before {
  content: "";
  position: absolute;
  pointer-events: none;
  border-color: var(--line-hot);
}
.rail::after { right: -1px; top: 18px; width: 1px; height: 74px; box-shadow: 0 0 18px var(--primary); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid var(--primary);
  color: var(--primary);
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  box-shadow: inset 0 0 20px color-mix(in srgb, var(--primary) 10%, transparent), 0 0 20px color-mix(in srgb, var(--primary) 8%, transparent);
}
.brand-mark::before, .brand-mark::after { content: ""; position: absolute; width: 7px; height: 7px; border-color: var(--cyan); border-style: solid; }
.brand-mark::before { left: -4px; top: -4px; border-width: 1px 0 0 1px; }
.brand-mark::after { right: -4px; bottom: -4px; border-width: 0 1px 1px 0; }
.brand-name { font-family: var(--display); font-size: 11px; line-height: 1.45; font-weight: 700; color: var(--text); }
.runtime-state { display: flex; align-items: center; gap: 10px; margin: 32px 0 22px; padding: 12px 0; border-block: 1px solid var(--line); }
.runtime-state div { display: grid; gap: 3px; min-width: 0; }
.runtime-state strong { color: var(--primary); font-family: var(--display); font-size: 11px; }
.runtime-state small { color: var(--muted); font-size: 9px; overflow-wrap: anywhere; }
.pulse { width: 8px; height: 8px; flex: 0 0 auto; background: var(--primary); box-shadow: 0 0 14px var(--primary); animation: pulse 1.8s infinite; }
.pulse.stale { background: var(--red); box-shadow: 0 0 14px var(--red); }
@keyframes pulse { 50% { opacity: .3; transform: scale(.72); } }
nav { display: grid; gap: 3px; }
nav a { display: flex; gap: 14px; padding: 11px 10px; color: var(--muted); text-decoration: none; border-left: 2px solid transparent; transition: color .16s ease, background .16s ease, border-color .16s ease; }
nav a span { color: color-mix(in srgb, var(--muted) 58%, transparent); }
nav a:hover, nav a.active { color: var(--text-strong); background: color-mix(in srgb, var(--primary) 6%, transparent); border-left-color: var(--primary); }
.rail-meta { margin-top: auto; display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 10px; }
.rail-meta span { color: var(--muted); }
.rail-meta strong { color: var(--text); }

main { position: relative; min-width: 0; padding: 0 34px 56px; }
.topbar {
  position: relative;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}
.topbar::after { left: 0; bottom: -1px; width: 128px; height: 1px; box-shadow: 0 0 15px var(--primary); }
.topbar-tools { display: flex; align-items: center; gap: 18px; }
.kicker, .section-heading span { color: var(--primary); font-size: 9px; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 720; letter-spacing: 0; }
h1 {
  margin-top: 6px;
  color: var(--text-strong);
  font-size: clamp(20px, 2vw, 30px);
  text-shadow: 0 0 24px color-mix(in srgb, var(--cyan) 18%, transparent);
}
h2 { margin-top: 4px; color: var(--text-strong); font-size: 15px; }
.clock { display: grid; justify-items: end; }
.clock strong { color: var(--cyan); font-size: 19px; font-variant-numeric: tabular-nums; }
.clock span { color: var(--muted); font-size: 9px; margin-top: 3px; }
.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 6%, transparent);
  border: 1px solid var(--line-hot);
  border-radius: 50%;
  transition: transform .22s ease, color .22s ease, box-shadow .22s ease;
}
.icon-button:hover { transform: rotate(8deg); color: var(--violet); box-shadow: 0 0 20px color-mix(in srgb, var(--violet) 22%, transparent); }
.sun-icon, .moon-icon { position: absolute; font-size: 19px; transition: transform .3s ease, opacity .3s ease; }
.sun-icon { opacity: 0; transform: rotate(-90deg) scale(.4); }
:root[data-theme="light"] .moon-icon { opacity: 0; transform: rotate(90deg) scale(.4); }
:root[data-theme="light"] .sun-icon { opacity: 1; transform: rotate(0) scale(1); }

.metrics { display: grid; grid-template-columns: repeat(5, minmax(132px, 1fr)); border-bottom: 1px solid var(--line); }
.metrics article { position: relative; min-height: 112px; padding: 24px 20px 20px 0; overflow: hidden; background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 38%, transparent), transparent); }
.metrics article + article { padding-left: 20px; border-left: 1px solid var(--line); }
.metrics span { display: block; color: var(--muted); font-size: 10px; }
.metrics strong { display: block; margin-top: 12px; color: var(--text-strong); font-family: var(--display); font-size: 23px; font-variant-numeric: tabular-nums; }
.metric-line { position: absolute; left: 0; bottom: 0; width: 64%; height: 2px; background: var(--primary); box-shadow: 0 0 10px color-mix(in srgb, var(--primary) 60%, transparent); }
.metric-line.amber { background: var(--amber); }.metric-line.cyan { background: var(--cyan); }.metric-line.violet { background: var(--violet); }

.signal-band, .data-section { position: relative; padding: 28px 0 34px; border-bottom: 1px solid var(--line); }
.data-section::before { left: 0; top: 27px; width: 12px; height: 12px; border-width: 1px 0 0 1px; border-style: solid; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; padding-left: 18px; }
.section-heading > span { color: var(--muted); }
#exposureChart { display: block; width: 100%; height: 118px; border-block: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 46%, transparent); }

.table-wrap { width: 100%; overflow-x: auto; background: color-mix(in srgb, var(--panel) 68%, transparent); border-top: 1px solid var(--line); backdrop-filter: blur(12px); }
table { width: 100%; min-width: 900px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { padding: 10px 12px; color: var(--muted); font-size: 9px; font-weight: 500; text-align: left; border-bottom: 1px solid var(--line-hot); }
td { height: 56px; padding: 9px 12px; color: var(--text); border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { transition: background .16s ease, box-shadow .16s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); box-shadow: inset 2px 0 var(--primary); }
td strong { display: block; max-width: 260px; overflow: hidden; color: var(--text-strong); font-weight: 600; text-overflow: ellipsis; }
td small { display: block; max-width: 260px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; }
.status, .side { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border: 1px solid var(--line-hot); color: var(--primary); font-size: 9px; text-transform: uppercase; }
.status.error, .side.sell { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.side.settle { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 55%, transparent); }
.side.hold { color: var(--muted); border-color: var(--line); }
.positive { color: var(--primary) !important; }.negative { color: var(--red) !important; }.amber { color: var(--amber); }
.empty { display: none; min-height: 92px; place-items: center; color: var(--muted); border-bottom: 1px solid var(--line); font-size: 10px; background: color-mix(in srgb, var(--panel) 58%, transparent); }
.empty.visible { display: grid; }
.filters { display: flex; border: 1px solid var(--line); }
.filters button { min-height: 32px; padding: 0 13px; color: var(--muted); background: transparent; border: 0; }
.filters button + button { border-left: 1px solid var(--line); }
.filters button:hover, .filters button.selected { color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, transparent); }
.order-section tbody tr { cursor: pointer; }

dialog { width: min(620px, calc(100vw - 28px)); max-height: calc(100vh - 40px); overflow: auto; color: var(--text); background: var(--panel-solid); border: 1px solid var(--line-hot); border-radius: 0; box-shadow: 0 24px 100px var(--shadow), 0 0 36px color-mix(in srgb, var(--primary) 8%, transparent); }
dialog::backdrop { background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(5px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.dialog-head span { color: var(--primary); font-size: 9px; }
.dialog-head .icon-button { width: 34px; height: 34px; border-radius: 0; color: var(--muted); font-size: 22px; }
dl { display: grid; grid-template-columns: 150px minmax(0,1fr); margin: 0; padding-top: 16px; }
dt, dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
dt { color: var(--muted); } dd { color: var(--text-strong); }

.reveal { opacity: 0; transform: translateY(12px); animation: reveal .68s cubic-bezier(.2,.8,.2,1) forwards; }
.reveal:nth-of-type(2) { animation-delay: .08s; }.reveal:nth-of-type(3) { animation-delay: .16s; }.reveal:nth-of-type(4) { animation-delay: .24s; }.reveal:nth-of-type(5) { animation-delay: .32s; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1080px) {
  .shell { grid-template-columns: 76px minmax(0,1fr); }
  .rail { padding-inline: 12px; }
  .brand-name, .runtime-state div, nav a:not(.active)::after, nav a { font-size: 0; }
  .brand { justify-content: center; }.brand-mark { width: 44px; }
  nav a { justify-content: center; padding-inline: 0; }.rail-meta { display: none; }
  .runtime-state { justify-content: center; }
  .metrics { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .cursor-sight { display: none; }
  .shell { display: block; }
  .rail { position: static; width: 100%; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail::after { display: none; }
  .brand-mark { width: 40px; height: 36px; }.runtime-state { margin: 0 0 0 auto; padding: 0; border: 0; }
  nav, .rail-meta { display: none; }
  main { padding: 0 12px 38px; }
  .topbar { min-height: 88px; }.kicker { display: none; }
  h1 { max-width: 190px; font-size: 17px; line-height: 1.2; }
  .topbar-tools { gap: 10px; }.clock strong { font-size: 13px; }.icon-button { width: 36px; height: 36px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics article { min-height: 92px; padding: 18px 10px 16px 0; }
  .metrics article + article { padding-left: 12px; }
  .metrics strong { font-size: 18px; }
  .section-heading { align-items: start; padding-left: 14px; }
  .section-heading > span { display: none; }
  .order-heading { display: grid; }
  .filters { width: 100%; }
  .filters button { flex: 1; min-width: 0; padding-inline: 4px; }

  .table-wrap { overflow: visible; border-top: 0; background: transparent; backdrop-filter: none; }
  table { display: block; min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 10px; }
  tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 14px;
    padding: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: 0 12px 28px var(--shadow);
    backdrop-filter: blur(12px);
  }
  tbody tr::before { content: ""; position: absolute; left: 0; top: 0; width: 42%; height: 1px; background: var(--primary); box-shadow: 0 0 10px var(--primary); }
  tbody tr:hover { background: var(--panel); box-shadow: 0 12px 28px var(--shadow); }
  td {
    min-width: 0;
    height: auto;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
  }
  td::before { content: attr(data-label); display: block; margin-bottom: 5px; color: var(--muted); font-size: 8px; text-transform: uppercase; }
  td:first-child { grid-column: 1 / -1; padding-top: 2px; }
  td:nth-last-child(-n + 2) { border-bottom: 0; }
  td strong, td small { max-width: none; overflow: visible; white-space: normal; text-overflow: clip; overflow-wrap: anywhere; }
  td strong { line-height: 1.42; }
  td small { margin-top: 3px; line-height: 1.45; }
  dl { grid-template-columns: 96px minmax(0,1fr); }
}

@media (pointer: coarse), (prefers-reduced-motion: reduce) {
  .cursor-sight { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
