:root {
  color-scheme: dark;
  --bg: #05090b;
  --panel: #070d10;
  --panel-2: #091215;
  --line: #16262b;
  --line-bright: #24474c;
  --text: #dfeeee;
  --muted: #5f7b80;
  --teal: #2fd6c4;
  --teal-dim: #0c4c47;
  --red: #ff4d6a;
  --gold: #ffd36b;
  --purple: #c58bff;
  font-family: "SFMono-Regular", "Cascadia Code", "Roboto Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
.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; }

.login-page { display: grid; place-items: center; }
.login-shell { width: 100%; display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-form { width: min(320px, 100%); display: flex; flex-direction: column; gap: 12px; }
.login-avatar { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; margin: 0 auto 12px; filter: grayscale(1) contrast(1.1); }
.login-form input { width: 100%; border: 1px solid rgba(255,255,255,.42); background: transparent; color: white; padding: 13px 12px; outline: 0; border-radius: 0; }
.login-form input:focus { border-color: white; }
.login-form.is-invalid input { border-color: var(--red); }
.login-submit { border: 0; border-radius: 4px; background: white; color: #050a0c; padding: 14px 0; font-size: 12px; font-weight: 800; letter-spacing: .14em; cursor: pointer; }
.login-submit:disabled { opacity: .6; cursor: wait; }
.login-error { min-height: 18px; margin: 0; color: var(--red); text-align: center; font-size: 11px; }
.login-mode { margin: 10px 0 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.login-mode span, .secure-dot::before, .paper-lock span { width: 6px; height: 6px; display: inline-block; background: var(--teal); border-radius: 50%; box-shadow: 0 0 12px rgba(47,214,196,.7); }

.hub-header, .trading-header { height: 48px; border-bottom: 1px solid var(--line); background: #05080a; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; position: sticky; top: 0; z-index: 20; }
.owner-lockup { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; letter-spacing: .06em; }
.owner-lockup img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; filter: grayscale(1); }
.header-actions { display: flex; align-items: center; gap: 14px; }
.secure-dot { color: var(--teal); font-size: 9px; letter-spacing: .12em; display: flex; align-items: center; gap: 7px; }
.text-button, .outline-button { background: transparent; color: var(--muted); border: 0; cursor: pointer; font-size: 9px; letter-spacing: .12em; }
.text-button:hover { color: white; }
.outline-button { border: 1px solid var(--line-bright); color: var(--text); padding: 7px 10px; }
.outline-button:hover { border-color: var(--teal); color: var(--teal); }
.outline-button:disabled { opacity: .45; cursor: wait; }

.hub-main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 96px 0; }
.hub-intro { max-width: 650px; margin-bottom: 64px; }
.eyebrow { color: var(--teal); font-size: 10px; letter-spacing: .16em; }
.hub-intro h1 { margin: 12px 0; font-size: clamp(36px, 6vw, 72px); line-height: .96; letter-spacing: -.05em; }
.hub-intro > p:last-child { color: var(--muted); line-height: 1.7; }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.hub-card { min-height: 260px; border: 1px solid var(--line); background: var(--panel); padding: 20px; display: flex; flex-direction: column; transition: border-color .2s, transform .2s; }
.hub-card.is-live:hover { border-color: var(--teal); transform: translateY(-2px); }
.hub-card.is-coming { opacity: .48; }
.hub-card-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.hub-card h2 { margin: auto 0 10px; font-size: 28px; }
.hub-card p { color: var(--muted); max-width: 45ch; line-height: 1.6; font-size: 12px; }
.hub-card-link { margin-top: 20px; color: var(--teal); font-size: 10px; letter-spacing: .1em; }
.status-pill { border: 1px solid var(--line-bright); color: var(--muted); padding: 3px 6px; font-size: 8px; letter-spacing: .1em; }
.status-pill.paper { color: var(--teal); border-color: var(--teal-dim); }

.trading-header { gap: 16px; }
.paper-lock { color: var(--teal); border: 1px solid var(--teal-dim); padding: 6px 9px; display: flex; align-items: center; gap: 7px; font-size: 9px; letter-spacing: .12em; }
#clock { min-width: 124px; text-align: right; font-size: 12px; font-weight: 700; }
.market-state { color: var(--gold); font-size: 9px; letter-spacing: .1em; }
.market-state.is-open { color: var(--teal); }

.trading-layout { min-height: calc(100vh - 48px); padding: 10px; display: grid; grid-template-columns: 300px minmax(0, 1fr); grid-template-rows: minmax(520px, calc(100vh - 284px)) 216px; gap: 10px; }
.portfolio-panel, .market-panel, .data-panel { border: 1px solid var(--line); background: var(--panel); min-width: 0; }
.portfolio-panel { grid-row: 1 / 3; overflow: hidden; display: flex; flex-direction: column; padding: 10px; }
.panel-heading { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; letter-spacing: .1em; }
.portfolio-value { margin-top: 8px; color: white; font-size: 28px; }
.portfolio-pl { font-size: 10px; margin: 4px 0 10px; }
.positive { color: var(--teal) !important; }
.negative { color: var(--red) !important; }
.position-list { min-height: 0; overflow: auto; border-top: 1px solid var(--line); }
.position-row { width: 100%; background: transparent; color: inherit; border: 0; border-bottom: 1px solid #101b1f; text-align: left; padding: 9px 7px; cursor: pointer; }
.position-row:hover, .position-row.is-selected { background: #0b2226; }
.position-row.is-selected { box-shadow: inset 2px 0 var(--teal); }
.position-top, .position-middle { display: flex; justify-content: space-between; gap: 8px; }
.position-top strong { color: white; font-size: 11px; }
.position-top span { font-size: 10px; }
.position-middle { margin-top: 3px; color: var(--muted); font-size: 9px; }
.position-bottom { margin-top: 4px; font-size: 9px; }

.market-panel { display: flex; flex-direction: column; overflow: hidden; }
.chart-toolbar { min-height: 40px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid var(--line); font-size: 10px; }
.chart-toolbar strong { color: var(--teal); margin-right: 8px; }
.chart-toolbar #selected-name, .toolbar-meta span { color: var(--muted); }
.toolbar-meta { display: flex; align-items: center; gap: 16px; }
.toolbar-meta strong { color: white; font-size: 13px; }
.gem { color: var(--teal); }
.chart-stage { position: relative; flex: 1; min-height: 0; background: radial-gradient(circle at 60% 100%, rgba(47,214,196,.08), transparent 50%), #050a0c; }
#market-chart { width: 100%; height: 100%; display: block; }
.model-card, .protection-card { position: absolute; left: 12px; width: 226px; border: 1px solid var(--line-bright); background: rgba(4,14,16,.93); padding: 9px; font-size: 9px; }
.model-card { top: 12px; }
.protection-card { top: 88px; }
.model-card > div, .protection-card > div { display: flex; justify-content: space-between; align-items: center; }
.model-card strong, .protection-card strong { color: var(--teal); }
.model-card p { color: var(--muted); line-height: 1.5; margin: 8px 0 0; }
.protection-card dl { margin: 8px 0 0; }
.protection-card dl div { display: flex; justify-content: space-between; margin-top: 4px; }
.protection-card dt { color: var(--muted); }
.protection-card dd { margin: 0; color: var(--text); }
.chart-message { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--muted); font-size: 10px; letter-spacing: .12em; pointer-events: none; }

.bottom-grid { display: grid; grid-template-columns: .9fr 1.1fr 1.25fr; gap: 10px; min-width: 0; }
.data-panel { padding: 10px; overflow: hidden; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin-top: 12px; background: var(--line); }
.metric-grid > div { background: var(--panel-2); padding: 13px 10px; display: flex; flex-direction: column; gap: 7px; }
.metric-grid span { color: var(--muted); font-size: 8px; letter-spacing: .1em; }
.metric-grid strong { font-size: 15px; }
.orders-list, .activity-list { margin-top: 10px; max-height: 166px; overflow: auto; }
.order-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 8px; border-bottom: 1px solid #111d21; padding: 8px 0; font-size: 9px; }
.order-row strong { color: var(--teal); }
.order-row span { color: var(--muted); }
.activity-list { list-style: none; padding: 0; margin-bottom: 0; }
.activity-list li { display: grid; grid-template-columns: 68px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid #101a1d; color: var(--muted); font-size: 9px; }
.activity-list li.ok span { color: var(--text); }
.activity-list li.error span { color: var(--red); }
.empty-state { color: var(--muted); font-size: 10px; }
.global-error { position: fixed; right: 16px; bottom: 16px; max-width: 420px; background: #2a0d13; color: #ff9aae; border: 1px solid var(--red); padding: 12px 14px; font-size: 11px; z-index: 50; }

@media (max-width: 1000px) {
  .trading-layout { grid-template-columns: 250px minmax(600px, 1fr); overflow-x: auto; }
  .paper-lock { display: none; }
  .bottom-grid { grid-template-columns: repeat(3, minmax(240px, 1fr)); }
}

@media (max-width: 720px) {
  .hub-grid { grid-template-columns: 1fr; }
  .hub-main { padding-top: 56px; }
  .trading-header { position: static; flex-wrap: wrap; height: auto; padding: 8px 10px; }
  .trading-header .header-actions { width: 100%; justify-content: space-between; }
  .trading-layout { display: block; padding: 8px; overflow: visible; }
  .portfolio-panel { max-height: 420px; margin-bottom: 8px; }
  .market-panel { height: 520px; margin-bottom: 8px; }
  .bottom-grid { display: grid; grid-template-columns: 1fr; }
  #clock { min-width: 0; }
}
