:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --surface: #12161b;
  --surface-2: #181d23;
  --line: #29313a;
  --text: #f4f7f8;
  --muted: #8d99a6;
  --teal: #2dd4bf;
  --teal-soft: rgba(45, 212, 191, .12);
  --gold: #f2b84b;
  --red: #fb7185;
  --green: #4ade80;
  --sidebar: 224px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input { font: inherit; letter-spacing: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.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; }
.eyebrow { margin: 0 0 6px; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: 1.6px; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column; border-right: 1px solid var(--line); background: #0d1014; padding: 22px 14px; z-index: 10; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand-copy { min-width: 0; flex: 1; }
.brand small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; white-space: nowrap; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; flex: none; border: 1px solid rgba(45, 212, 191, .55); background: var(--teal-soft); transform: rotate(45deg); border-radius: 4px; }
.brand-mark span { color: var(--teal); font-weight: 800; transform: rotate(-45deg); }
.bot-selector { width: 100%; height: 27px; border: 1px solid transparent; border-radius: 4px; background: #0d1014; color: var(--text); padding: 0 22px 0 4px; font-size: 17px; font-weight: 750; outline: none; cursor: pointer; letter-spacing: 0; }
.bot-selector:hover { border-color: var(--line); background: var(--surface); }
.bot-selector:focus-visible { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45,212,191,.08); }
.bot-selector option { background: var(--surface); color: var(--text); font-size: 14px; }
.mobile-bot-switch { display: none; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 5px; color: var(--muted); font-size: 13px; font-weight: 600; }
.nav-link svg { width: 17px; }
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.active { color: var(--text); background: var(--surface-2); box-shadow: inset 2px 0 var(--teal); }
.sidebar-footer { margin-top: auto; display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 16px; }
.system-chip { display: flex; align-items: center; gap: 9px; padding: 0 8px; }
.system-chip strong, .system-chip small { display: block; }
.system-chip strong { font-size: 12px; }
.system-chip small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--gold); box-shadow: 0 0 0 4px rgba(242, 184, 75, .1); }
.dot.online { background: var(--green); box-shadow: 0 0 0 4px rgba(74, 222, 128, .1); }
.dot.error { background: var(--red); box-shadow: 0 0 0 4px rgba(251, 113, 133, .1); }
.icon-text-button { width: 100%; height: 38px; border: 0; border-radius: 5px; display: flex; align-items: center; gap: 10px; padding: 0 10px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-text-button:hover { color: var(--text); background: var(--surface); }
.icon-text-button svg { width: 16px; }

.main-content { margin-left: var(--sidebar); min-height: 100vh; padding: 0 28px 42px; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.topbar h1 { margin: 0; font-size: 23px; letter-spacing: 0; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.freshness { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.user-menu { display: flex; align-items: center; gap: 9px; }
.user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: 12px; }
.user-menu small { color: var(--muted); font-size: 10px; margin-top: 2px; text-transform: capitalize; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #46515d; background: var(--surface-2); border-radius: 50%; font-weight: 700; font-size: 13px; }

.view { display: none; }
.view.active-view { display: block; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric, .surface { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; }
.metric { min-height: 124px; padding: 17px; }
.metric-head { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; }
.metric-head svg { width: 17px; color: #6f7d89; }
.metric > strong { display: block; font-size: 24px; margin: 17px 0 7px; font-variant-numeric: tabular-nums; }
.metric > small { color: var(--muted); font-size: 11px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr); gap: 12px; margin-top: 12px; }
.surface { overflow: hidden; }
.section-head { min-height: 68px; padding: 14px 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font-size: 15px; }
.text-link { color: var(--teal); font-size: 12px; font-weight: 600; }
.delta, .count-badge { border: 1px solid var(--line); background: var(--surface-2); border-radius: 4px; padding: 5px 8px; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-wrap { position: relative; height: 280px; padding: 16px 18px 10px; }
#equityChart { width: 100%; height: 100%; overflow: visible; }
.chart-line { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-area { fill: url(#chartFill); }
.chart-point { fill: var(--teal); stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.empty-chart { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.strategy-summary { padding: 10px 17px 17px; display: grid; gap: 8px; }
.strategy-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; min-height: 57px; padding: 8px 0; border-bottom: 1px solid rgba(41,49,58,.7); }
.strategy-row:last-child { border-bottom: 0; }
.strategy-row strong, .strategy-row small { display: block; }
.strategy-row strong { font-size: 13px; }
.strategy-row small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.strategy-stat { text-align: right; font-size: 11px; color: var(--muted); }

.positions-preview, .full-surface { margin-top: 12px; }
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { color: #73808c; font-size: 10px; font-weight: 700; text-align: left; text-transform: uppercase; padding: 11px 16px; border-bottom: 1px solid var(--line); }
td { padding: 13px 16px; border-bottom: 1px solid rgba(41,49,58,.68); color: #dce2e6; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
.symbol-cell strong, .symbol-cell small { display: block; }
.symbol-cell small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.side-pill, .status-pill { display: inline-flex; align-items: center; justify-content: center; min-width: 54px; padding: 4px 7px; border-radius: 3px; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.side-pill.long { color: var(--green); background: rgba(74,222,128,.1); }
.side-pill.short { color: var(--red); background: rgba(251,113,133,.1); }
.status-pill { color: var(--gold); background: rgba(242,184,75,.1); }
.empty-state { min-height: 180px; display: none; place-items: center; align-content: center; gap: 7px; color: var(--muted); }
.empty-state.show { display: grid; }
.empty-state svg { width: 22px; color: var(--teal); }
.empty-state strong { color: var(--text); font-size: 13px; }
.empty-state span { font-size: 11px; }

.strategy-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.strategy-card { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 19px; }
.strategy-card-head { display: flex; align-items: center; justify-content: space-between; }
.strategy-card h2 { margin: 12px 0 5px; font-size: 18px; }
.strategy-card > p { margin: 0; color: var(--muted); font-size: 11px; }
.strategy-data { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 20px; border: 1px solid var(--line); border-radius: 5px; }
.strategy-data div { padding: 12px; border-right: 1px solid var(--line); }
.strategy-data div:last-child { border-right: 0; }
.strategy-data strong, .strategy-data small { display: block; }
.strategy-data small { color: var(--muted); font-size: 9px; text-transform: uppercase; margin-bottom: 6px; }
.strategy-data strong { font-size: 14px; }
.architecture { margin-top: 12px; }
.infra-grid { display: grid; grid-template-columns: repeat(3, 1fr); }
.infra-grid > div { min-height: 95px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-content: center; column-gap: 10px; padding: 16px; border-right: 1px solid var(--line); }
.infra-grid > div:last-child { border-right: 0; }
.infra-grid .dot { grid-row: 1 / 3; align-self: center; }
.infra-grid strong { font-size: 12px; }
.infra-grid small { color: var(--muted); font-size: 10px; margin-top: 4px; }

.login-page { min-height: 100vh; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 1.2fr) minmax(420px, .8fr); }
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; padding: clamp(42px, 8vw, 130px); overflow: hidden; background: #0c1115; border-right: 1px solid var(--line); }
.login-brand::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(45,212,191,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(45,212,191,.045) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom right, black, transparent 70%); pointer-events: none; }
.login-brand .brand-mark { width: 48px; height: 48px; margin: 0 0 32px 7px; }
.login-brand h1 { margin: 0; font-size: clamp(48px, 7vw, 88px); font-weight: 750; letter-spacing: 0; }
.login-intro { max-width: 490px; margin: 16px 0 0; color: var(--muted); font-size: 15px; line-height: 1.65; }
.market-pulse { height: 76px; display: flex; align-items: end; gap: 8px; margin-top: 42px; opacity: .8; }
.market-pulse span { width: 5px; background: var(--teal); border-radius: 1px 1px 0 0; }
.market-pulse span:nth-child(1) { height: 18px; }.market-pulse span:nth-child(2) { height: 34px; }.market-pulse span:nth-child(3) { height: 28px; }.market-pulse span:nth-child(4) { height: 56px; }.market-pulse span:nth-child(5) { height: 43px; }.market-pulse span:nth-child(6) { height: 67px; background: var(--gold); }.market-pulse span:nth-child(7) { height: 52px; }.market-pulse span:nth-child(8) { height: 72px; }
.login-panel { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.login-form-wrap { width: min(100%, 390px); }
.login-form-wrap h2 { margin: 0; font-size: 27px; }
.login-form-wrap > .muted { margin: 8px 0 26px; font-size: 13px; }
.login-form-wrap form { display: grid; }
.login-form-wrap label { color: #b8c1c8; font-size: 11px; font-weight: 650; margin: 14px 0 7px; }
.login-form-wrap input { width: 100%; height: 45px; border: 1px solid #343d46; border-radius: 5px; background: #101419; color: var(--text); padding: 0 13px; outline: none; }
.login-form-wrap input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45,212,191,.08); }
.primary-button { height: 45px; border: 0; border-radius: 5px; margin-top: 22px; background: var(--teal); color: #061210; font-weight: 800; cursor: pointer; }
.primary-button:hover { background: #5eead4; }
.form-alert { border: 1px solid rgba(251,113,133,.35); background: rgba(251,113,133,.08); color: #fda4af; padding: 11px 12px; border-radius: 5px; font-size: 12px; margin: 14px 0 0; }
.secure-note { display: flex; justify-content: center; align-items: center; gap: 7px; color: #697681; font-size: 10px; margin-top: 22px; }
.secure-note span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.mobile-brand { display: none; }

@media (max-width: 1050px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  :root { --sidebar: 0px; }
  .sidebar { inset: auto 0 0; width: 100%; height: 62px; display: block; padding: 7px 10px; border: 0; border-top: 1px solid var(--line); }
  .sidebar .brand, .sidebar-footer { display: none; }
  .sidebar nav { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
  .nav-link { height: 48px; flex-direction: column; justify-content: center; gap: 3px; padding: 0; font-size: 9px; }
  .nav-link.active { box-shadow: inset 0 -2px var(--teal); }
  .nav-link svg { width: 16px; height: 16px; }
  .main-content { margin-left: 0; padding: 0 14px 88px; }
  .topbar { min-height: 76px; margin-bottom: 16px; }
  .topbar h1 { font-size: 18px; }
  .topbar-title { display: flex; align-items: center; gap: 12px; }
  .mobile-bot-switch { display: block; width: 112px; }
  .mobile-bot-switch .bot-selector { height: 34px; border-color: var(--line); background: var(--surface); font-size: 13px; }
  .topbar-title > .eyebrow { display: none; }
  .freshness { display: none; }
  .user-menu > div:not(.avatar) { display: none; }
  .metrics-grid { gap: 8px; }
  .metric { min-height: 108px; padding: 13px; }
  .metric > strong { font-size: 19px; margin-top: 14px; }
  .section-head { padding: 12px 14px; }
  .chart-wrap { height: 225px; }
  .strategy-cards { grid-template-columns: 1fr; }
  .infra-grid { grid-template-columns: 1fr; }
  .infra-grid > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; padding: 24px; }
  .mobile-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 48px; font-size: 20px; }
}

@media (max-width: 430px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .metric { min-height: 98px; }
  .metric > strong { margin: 10px 0 5px; }
  .strategy-data { grid-template-columns: 1fr; }
  .strategy-data div { border-right: 0; border-bottom: 1px solid var(--line); }
  .strategy-data div:last-child { border-bottom: 0; }
}
