:root {
  color-scheme: dark;
  --bg: #0b1013;
  --panel: #11181c;
  --panel-2: #161e23;
  --line: #263036;
  --text: #edf2f3;
  --muted: #899397;
  --green: #39d353;
  --red: #ff6267;
  --blue: #42a5ff;
  --orange: #ff713b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at 80% -10%, #16242d 0, transparent 35%), var(--bg);
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}
.shell { width: min(100%, 780px); margin: 0 auto; padding: 18px 14px 50px; }
.topbar, .section-label { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.topbar { position: sticky; top: 0; z-index: 4; padding: 12px 4px 18px; background: linear-gradient(var(--bg) 72%, transparent); letter-spacing: .12em; color: #c9ced0; }
.topbar > span:last-child { white-space: nowrap; letter-spacing: 0; }
.live { font-weight: 400; color: var(--muted); }
.live span { display: inline-block; width: 11px; height: 11px; margin: 0 4px; border-radius: 50%; background: #687177; }
.live.ok span { background: var(--green); box-shadow: 0 0 12px #39d353aa; }
.live.bad span { background: var(--red); }
.panel { margin: 0 0 16px; padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: linear-gradient(145deg, #131b1f, #10171a); box-shadow: 0 16px 50px #0005; }
.section-label { margin-bottom: 16px; color: var(--muted); letter-spacing: .14em; font-size: 14px; }
.section-label span:last-child { letter-spacing: 0; font-size: 12px; text-align: right; }
.equity-row { display: flex; align-items: baseline; gap: 12px; margin: 5px 0 18px; }
.equity-row strong { font-size: clamp(46px, 12vw, 72px); line-height: 1; font-weight: 500; }
.equity-row span { color: var(--muted); font-size: 18px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.metric-grid > div { min-width: 0; padding: 12px; border-radius: 12px; background: var(--panel-2); }
.metric-grid small { display: block; margin-bottom: 7px; color: var(--muted); letter-spacing: .12em; }
.metric-grid b { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 18px; font-weight: 500; white-space: nowrap; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
#equity-chart { display: block; width: 100%; height: 155px; margin-top: 12px; overflow: visible; }
.baseline { stroke: #697277; stroke-width: 2; stroke-dasharray: 10 10; opacity: .7; }
.equity-line { fill: none; stroke: var(--blue); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.chart-dot { fill: var(--blue); stroke: #d8ecff; stroke-width: 3; }
.position-card { padding: 18px 0; border-top: 1px solid var(--line); }
.position-card:first-child { border-top: 0; padding-top: 4px; }
.position-head, .position-values, .track-labels { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.position-title { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.position-title strong { font-family: system-ui, sans-serif; font-size: 24px; }
.side { padding: 3px 8px; border-radius: 6px; font-size: 12px; letter-spacing: .08em; }
.side.long { color: #63b2ff; background: #16324b; }
.side.short { color: var(--orange); background: #46251b; }
.muted, .position-age { color: var(--muted); }
.position-values { margin: 11px 0 13px; font-size: 16px; }
.position-values > span:nth-child(2) { flex: 1; text-align: center; }
.position-values strong { min-width: 68px; text-align: right; font-size: 22px; }
mark { padding: 2px 5px; border-radius: 5px; color: #b9ffc5; background: #204b2b; }
.track { position: relative; height: 15px; border-radius: 99px; background: linear-gradient(90deg, #ef666c 0%, #64706b 50%, #32c84a 100%); box-shadow: inset 0 1px 2px #0008; }
.track.unprotected { background: #6b3d42; }
.price-marker, .entry-marker { position: absolute; top: -7px; width: 5px; height: 29px; border-radius: 3px; transform: translateX(-50%); }
.price-marker { z-index: 2; width: 7px; background: #f1f5f6; box-shadow: 0 0 0 2px #1118; }
.entry-marker { background: var(--blue); }
.track-labels { margin-top: 8px; color: var(--muted); font-size: 12px; }
.track-labels > span:first-child { text-align: left; }
.track-labels > span:last-child { text-align: right; }
.protection { white-space: nowrap; }
.protection.ok { color: var(--green); }
.protection.bad { color: var(--red); }
.risk-grid > div { min-height: 74px; }
.closed-row { display: grid; grid-template-columns: 88px 1fr auto auto 70px; gap: 9px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13px; }
.closed-row:first-child { border-top: 0; }
.closed-row time, .closed-row > span:not(.side) { color: var(--muted); }
.closed-row > b { text-align: right; }
.desk-summary { margin-bottom: 14px; }
.desk-summary b { font-size: 15px; }
.agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.agent-card { min-width: 0; padding: 12px; border: 1px solid #222d32; border-radius: 12px; background: #0d1417; }
.agent-card > div { display: flex; justify-content: space-between; gap: 8px; }
.agent-card > div span, .agent-card p, .agent-card small { color: var(--muted); }
.agent-card p { min-height: 31px; margin: 8px 0; font-family: system-ui, sans-serif; font-size: 12px; line-height: 1.3; }
.agent-card small { font-size: 10px; }
.long-text { color: var(--blue); }
.short-text { color: var(--orange); }
.matrix-wrap { width: 100%; overflow-x: auto; scrollbar-width: thin; }
.matrix-row { display: grid; gap: 5px; align-items: center; min-width: 330px; margin: 5px 0; }
.matrix-row > strong { font-family: system-ui, sans-serif; font-size: 13px; }
.matrix-head { margin-bottom: 9px; color: var(--muted); font-size: 9px; text-align: center; }
.matrix-head > span:first-child { text-align: left; }
.matrix-cell { display: grid; min-width: 20px; height: 22px; place-items: center; border-radius: 5px; color: #edf2f3; font-size: 11px; }
.matrix-cell.long, .matrix-legend i.long { background: #2486e6; }
.matrix-cell.short, .matrix-legend i.short { background: #d55528; }
.matrix-cell.neutral, .matrix-legend i.neutral { background: #586267; }
.matrix-cell.judge { border: 1px solid #c7d0d4; opacity: 1 !important; }
.matrix-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; color: var(--muted); font-size: 10px; }
.matrix-legend span { display: flex; align-items: center; gap: 5px; }
.matrix-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.decision-row, .proposal-row, .cycle-row { padding: 12px 0; border-top: 1px solid var(--line); }
.decision-row:first-child, .proposal-row:first-child, .cycle-row:first-child { border-top: 0; }
.decision-row > div { display: flex; align-items: center; gap: 9px; }
.decision-row > div > strong { min-width: 56px; font-family: system-ui, sans-serif; font-size: 17px; }
.decision-row > div > b { margin-left: auto; color: var(--muted); }
.decision-row p { margin: 7px 0 0; color: #b6bec1; font-family: system-ui, sans-serif; font-size: 12px; line-height: 1.35; }
.decision { padding: 3px 7px; border-radius: 6px; color: #c8d0d3; background: #30383c; font-size: 10px; }
.decision.open { color: #b9ffc5; background: #204b2b; }
.proposal-row { display: grid; grid-template-columns: 92px 48px auto 1fr; gap: 7px 9px; align-items: center; font-size: 12px; }
.proposal-row time, .proposal-row > span:not(.side) { color: var(--muted); }
.proposal-row > b { grid-column: 2 / -1; }
.cycle-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 9px; align-items: center; font-size: 12px; }
.cycle-row time, .cycle-row span { color: var(--muted); }
.empty { color: var(--muted); text-align: center; }
.error { padding: 12px; border: 1px solid #7a3439; border-radius: 12px; color: #ffc6c9; background: #351b1e; }
footer { padding: 6px 10px; color: #737d81; text-align: center; font-size: 11px; line-height: 1.7; }

@media (max-width: 520px) {
  .shell { padding: 8px 10px 36px; }
  .topbar { font-size: 11px; }
  .panel { padding: 16px; border-radius: 18px; }
  .position-title strong { font-size: 21px; }
  .position-values { font-size: 13px; }
  .position-values strong { font-size: 19px; }
  .track-labels { font-size: 10px; gap: 5px; }
  .closed-row { grid-template-columns: 72px 1fr auto 62px; }
  .closed-row > span:not(.side) { display: none; }
  .agent-grid { grid-template-columns: 1fr; }
  .agent-card p { min-height: 0; }
  .proposal-row { grid-template-columns: 76px 44px auto; }
  .proposal-row > span:not(.side) { grid-column: 1 / -1; }
  .proposal-row > b { grid-column: 1 / -1; }
  .cycle-row { grid-template-columns: 76px 1fr; }
  .cycle-row > strong { grid-column: 2; }
}
