:root {
  --ink: #172b34;
  --ink-soft: #314750;
  --navy: #102d3a;
  --navy-deep: #0d2633;
  --canvas: #f3f6f8;
  --surface: #ffffff;
  --surface-muted: #f7fafb;
  --line: #dce5e8;
  --line-strong: #c8d5d9;
  --muted: #677c85;
  --teal: #0f7c82;
  --teal-hover: #0b686e;
  --teal-soft: #e1f1f2;
  --green: #238269;
  --green-soft: #e3f2ed;
  --amber: #d69a35;
  --amber-soft: #fbf1df;
  --red: #c94f55;
  --red-hover: #ad3f45;
  --red-soft: #f9e8e9;
  --red-text: #8c3439;
  --red-text-alt: #94373c;
  --green-text: #176b56;
  --amber-text: #7b5a1f;
  --mint: #65c5ae;
  --hairline: #edf1f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 45, 58, .04), 0 8px 24px rgba(16, 45, 58, .035);
}

:root[data-theme="dark"] {
  --ink: #e7eef0;
  --ink-soft: #c2ced2;
  --canvas: #0d2028;
  --surface: #132c36;
  --surface-muted: #17323c;
  --line: #294753;
  --line-strong: #375964;
  --muted: #8aa2a9;
  --teal-soft: #163b3d;
  --green-soft: #123329;
  --amber-soft: #3a2f16;
  --red-soft: #3a1e20;
  --red-text: #f0a3a7;
  --red-text-alt: #f2a9ad;
  --green-text: #6fd4b3;
  --amber-text: #e8c27f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 8px 24px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Bahnschrift, "Aptos", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
body.nav-open { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button, input, select { transition: border-color .16s ease, background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .1s ease; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: progress; opacity: .56; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(214, 154, 53, .42);
  outline-offset: 2px;
}
.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;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.08;
  letter-spacing: -.035em;
  font-weight: 680;
}
h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -.018em;
  font-weight: 650;
}
code { font-family: "Cascadia Code", Consolas, monospace; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(480px, 1.15fr);
  color: white;
  background: var(--navy-deep);
  overflow: hidden;
}
.login-signal {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10vw;
  background: #12313e;
}
.login-signal::after {
  content: "TradingView → Risk gate → Bybit Futures";
  position: absolute;
  left: 10vw;
  bottom: 42px;
  color: #8da7b0;
  font-size: 12px;
}
.login-signal i { display: block; width: 18px; border-radius: 4px; background: #45a2a5; }
.login-signal i:nth-child(1) { height: 70px; }
.login-signal i:nth-child(2) { height: 150px; }
.login-signal i:nth-child(3) { height: 105px; background: var(--amber); }
.login-signal i:nth-child(4) { height: 210px; }
.login-signal i:nth-child(5) { height: 135px; }
.login-panel {
  align-self: center;
  width: min(470px, calc(100% - 48px));
  margin: 32px auto;
  padding: 42px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .18);
}
.login-brand { margin-bottom: 52px; color: var(--navy-deep); }
.login-panel h1 { max-width: 400px; font-size: clamp(36px, 5vw, 54px); }
.login-intro { max-width: 390px; margin: 20px 0 30px; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 17px; }
.login-form label, .form-grid label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 560; }
.login-form input, .form-grid input, .form-grid select, .connection-panel select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
}
.login-form input:hover, .form-grid input:hover, .form-grid select:hover, .connection-panel select:hover { border-color: #9db2b9; }
.login-form input:focus, .form-grid input:focus, .form-grid select:focus, .connection-panel select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 124, 130, .1);
}
.login-form button {
  min-height: 46px;
  color: white;
  background: var(--teal);
  border: 1px solid var(--teal);
  border-radius: 8px;
  font-weight: 650;
}
.login-form button:hover:not(:disabled) { background: var(--teal-hover); border-color: var(--teal-hover); }
.demo-note { margin: 20px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.demo-note code { color: var(--ink); }
.form-error {
  margin: 0;
  padding: 11px 13px;
  color: var(--red-text);
  background: var(--red-soft);
  border-left: 3px solid var(--red);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px 22px;
  color: #edf7f8;
  background: var(--navy-deep);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
  font-size: 20px;
  font-weight: 680;
  letter-spacing: -.025em;
}
.brand-mark {
  width: 31px;
  height: 31px;
  display: flex;
  align-items: end;
  gap: 3px;
  flex: 0 0 31px;
  padding: 7px;
  background: var(--teal);
  border-radius: 8px;
}
.brand-mark i { display: block; width: 4px; background: white; border-radius: 2px 2px 0 0; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 12px; }
nav { margin-top: 58px; display: grid; gap: 6px; }
.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 12px;
  color: #a9bec5;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 9px;
}
.nav-copy { display: flex; align-items: center; gap: 11px; min-width: 0; }
.nav-copy i {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex: 0 0 22px;
  color: #82a0aa;
  font-size: 15px;
  font-style: normal;
}
.nav-link b { color: #78949e; font-size: 10px; font-weight: 600; }
.nav-link:hover { color: white; background: #143745; }
.nav-link.active {
  color: white;
  background: #17404c;
  border-color: #265460;
  box-shadow: inset 3px 0 0 var(--teal);
}
.nav-link.active .nav-copy i { color: #71c4c7; }
.sidebar-foot {
  margin-top: auto;
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 14px 12px;
  background: #12323f;
  border: 1px solid #234754;
  border-radius: 10px;
}
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { margin-top: 3px; color: #91aab2; font-size: 10px; }
.mode-dot { width: 9px; height: 9px; flex: 0 0 9px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(101, 197, 174, .12); }
.sidebar-overlay { display: none; }

main { min-width: 0; width: 100%; max-width: 1580px; padding: 34px clamp(24px, 3.7vw, 56px) 32px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.page-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.menu-button {
  display: none;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.top-actions { display: flex; align-items: center; gap: 10px; }
.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-light { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: inline; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 5px 8px 5px 14px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.user-chip span { max-width: 160px; overflow: hidden; font-size: 11px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .icon-button { width: 44px; height: 44px; flex: 0 0 44px; font-size: 0; }
.context, .section-head p { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.emergency-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 166px;
  min-height: 44px;
  padding: 8px 13px;
  color: #8b3439;
  background: var(--red-soft);
  border: 1px solid #e8bfc2;
  border-radius: 9px;
  text-align: left;
}
.emergency-button:hover:not(:disabled) { color: #77282d; background: #f6dfe1; border-color: #dda9ad; }
.emergency-button strong, .emergency-button small { display: block; }
.emergency-button strong { font-size: 12px; }
.emergency-button small { margin-top: 1px; font-size: 10px; opacity: .78; }
.emergency-light { width: 10px; height: 10px; flex: 0 0 10px; border: 2px solid var(--red); border-radius: 50%; }
.emergency-button.active { color: white; background: var(--red); border-color: var(--red); }
.emergency-button.active:hover { background: var(--red-hover); }
.emergency-button.active .emergency-light { background: white; border-color: white; box-shadow: 0 0 0 4px rgba(255, 255, 255, .16); }

.execution-rail {
  margin-top: 30px;
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(500px, 1.15fr);
  gap: 40px;
  align-items: center;
  padding: 24px 26px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.rail-copy p { margin-bottom: 6px; color: var(--muted); font-size: 11px; }
.rail-copy h2 { max-width: 500px; font-size: clamp(18px, 1.8vw, 24px); line-height: 1.25; }
.execution-rail ol {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.execution-rail ol::before { content: ""; position: absolute; top: 17px; left: 18px; right: 18px; height: 2px; background: var(--line); }
.execution-rail li { position: relative; display: flex; align-items: center; gap: 9px; min-width: 0; }
.execution-rail li > span {
  z-index: 1;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  color: var(--muted);
  background: var(--surface);
  border: 2px solid var(--line-strong);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.execution-rail li.ready > span { color: white; background: var(--green); border-color: var(--green); }
.execution-rail li.waiting > span { color: #7c641f; background: var(--amber-soft); border-color: #e4bb6e; }
.execution-rail li.failed > span { color: white; background: var(--red); border-color: var(--red); }
.execution-rail strong, .execution-rail small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.execution-rail strong { font-size: 12px; }
.execution-rail small { margin-top: 2px; color: var(--muted); font-size: 10px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.metrics article {
  min-width: 0;
  padding: 20px 21px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.metrics p { margin-bottom: 11px; color: var(--muted); font-size: 12px; }
.metrics strong { display: block; overflow: hidden; font-size: clamp(22px, 2.25vw, 29px); font-variant-numeric: tabular-nums; letter-spacing: -.025em; text-overflow: ellipsis; white-space: nowrap; }
.metrics small { display: block; margin-top: 7px; color: #7b8e95; font-size: 11px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.content-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .75fr); gap: 16px; margin-top: 16px; }
.lower-grid { grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr); }
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.strategies-panel { margin-top: 16px; }
.section-head {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 21px;
}
.section-head-actions { display: flex; align-items: center; gap: 12px; }
.primary-button, .secondary-button, .danger-button, .sync-button {
  min-height: 44px;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 650;
}
.primary-button { color: white; background: var(--teal); border: 1px solid var(--teal); }
.primary-button:hover:not(:disabled) { background: var(--teal-hover); border-color: var(--teal-hover); }
.secondary-button, .sync-button { color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); }
.secondary-button:hover:not(:disabled), .sync-button:hover:not(:disabled) { background: var(--surface-muted); border-color: #9fb3ba; }
.danger-button { color: var(--red); background: var(--surface); border: 1px solid #e1b4b7; }
.danger-button:hover:not(:disabled) { color: white; background: var(--red); border-color: var(--red); }
.text-button {
  min-height: 44px;
  padding: 7px 9px;
  color: var(--teal);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 650;
}
.text-button:hover:not(:disabled) { color: var(--teal-hover); background: var(--teal-soft); }
.danger-text { color: var(--red); }
.danger-text:hover:not(:disabled) { color: var(--red-hover); background: var(--red-soft); }

.strategy-list { display: grid; gap: 10px; padding: 0 14px 14px; }
.strategy-row {
  display: grid;
  grid-template-columns: minmax(170px, .85fr) minmax(300px, 1.4fr) 120px auto;
  gap: 20px;
  align-items: center;
  min-height: 82px;
  padding: 15px 16px;
  background: var(--surface-muted);
  border: 1px solid #e5ecee;
  border-radius: 10px;
}
.strategy-name-line { display: flex; align-items: center; gap: 9px; min-width: 0; }
.strategy-name-line strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strategy-identity > code { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.status-pill, .count-badge, .live-pill { padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 650; white-space: nowrap; }
.status-pill.active, .live-pill.online { color: var(--green-text); background: var(--green-soft); }
.status-pill.paused { color: var(--amber-text); background: var(--amber-soft); }
.count-badge { color: var(--teal); background: var(--teal-soft); }
.live-pill.offline { color: var(--red-text-alt); background: var(--red-soft); }
.strategy-limits { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; min-width: 0; }
.strategy-limits span {
  padding: 5px 8px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 10px;
  white-space: nowrap;
}
.strategy-limits .symbol-list { max-width: 190px; overflow: hidden; color: var(--ink-soft); text-overflow: ellipsis; }
.strategy-token small, .strategy-token code { display: block; }
.strategy-token small { color: var(--muted); font-size: 9px; }
.strategy-token code { margin-top: 5px; color: var(--ink-soft); font-size: 10px; }
.strategy-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }

.table-wrap { max-width: 100%; overflow-x: auto; border-top: 1px solid var(--hairline); }
table { width: 100%; min-width: 700px; border-collapse: collapse; white-space: nowrap; }
th {
  padding: 12px 17px;
  color: var(--muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 650;
  text-align: left;
}
td { padding: 16px 17px; border-bottom: 1px solid var(--hairline); font-size: 12px; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfc; }
.side-label, .signal-action {
  display: inline-grid;
  place-items: center;
  min-width: 50px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 700;
}
.side-label.long, .signal-action.buy { color: var(--green-text); background: var(--green-soft); }
.side-label.short, .signal-action.sell { color: var(--red-text-alt); background: var(--red-soft); }
.signal-action.close { color: var(--amber-text); background: var(--amber-soft); }
.empty-state { display: grid; justify-items: center; padding: 52px 24px; color: var(--ink-soft); text-align: center; }
.empty-state.compact { padding: 34px 22px 40px; }
.empty-state[hidden] { display: none; }
.empty-state p { max-width: 390px; margin: 7px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.empty-glyph {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 10px;
  font-size: 18px;
}

.risk-panel dl { display: grid; gap: 8px; margin: 0; padding: 0 18px; }
.risk-panel dl div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  padding: 11px 12px;
  background: var(--surface-muted);
  border-radius: 8px;
}
.risk-panel dt { color: var(--muted); font-size: 11px; }
.risk-panel dd { margin: 0; font-size: 11px; font-weight: 650; text-align: right; }
.risk-note {
  margin: 15px 18px 18px;
  padding: 12px 13px;
  color: #72551f;
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.5;
}
.risk-note.live-warning { color: var(--green-text); background: var(--green-soft); border-left-color: var(--green); }

.signal-list { display: grid; gap: 8px; padding: 0 14px 14px; }
.signal-item {
  display: grid;
  grid-template-columns: 52px minmax(100px, 1fr) minmax(120px, auto);
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  background: var(--surface-muted);
  border: 1px solid #e7edef;
  border-radius: 9px;
}
.signal-meta strong, .signal-meta small, .signal-status strong, .signal-status small { display: block; }
.signal-meta strong { font-size: 12px; }
.signal-meta small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.signal-status { text-align: right; }
.signal-status strong { font-size: 10px; }
.signal-status small { max-width: 210px; margin-top: 4px; color: var(--muted); font-size: 9px; white-space: normal; }

.connection-panel { padding-bottom: 20px; }
.connection-panel > label, .connection-panel > select, .copy-field, .connection-help { margin-left: 20px; margin-right: 20px; }
.connection-panel > label { display: block; margin-top: 18px; margin-bottom: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 600; }
.connection-panel > select { width: calc(100% - 40px); }
.broker-details { display: grid; gap: 8px; margin: 0 20px; }
.broker-details div { display: flex; justify-content: space-between; gap: 15px; padding: 11px 12px; background: var(--surface-muted); border-radius: 8px; }
.broker-details dt { color: var(--muted); font-size: 11px; }
.broker-details dd { max-width: 62%; margin: 0; font-size: 11px; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
.broker-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 20px 0; }
.broker-actions button { width: 100%; }
.copy-field { display: flex; min-width: 0; background: var(--navy-deep); border-radius: 8px; overflow: hidden; }
.copy-field code { min-width: 0; flex: 1; padding: 12px; overflow: hidden; color: #dcebed; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.copy-field button { padding: 0 13px; color: white; background: var(--teal); border: 0; font-size: 10px; font-weight: 650; }
.copy-field button:hover { background: var(--teal-hover); }
.connection-help { margin-top: 15px; margin-bottom: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 22px 2px 0; color: var(--muted); font-size: 10px; }
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  max-width: min(380px, calc(100% - 32px));
  padding: 13px 16px;
  color: white;
  background: var(--navy-deep);
  border-left: 4px solid var(--mint);
  border-radius: 9px;
  box-shadow: 0 12px 32px rgba(13, 38, 51, .18);
  transform: translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: transform .18s ease, opacity .18s ease;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-left-color: var(--red); }

.control-dialog {
  width: min(620px, calc(100% - 30px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(4, 23, 30, .24);
}
.control-dialog::backdrop { background: rgba(6, 27, 35, .62); backdrop-filter: blur(2px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 19px 22px; border-bottom: 1px solid var(--line); }
.dialog-head p { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  color: var(--muted);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 21px;
  line-height: 1;
}
.icon-button:hover { color: var(--ink); background: #eef3f4; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; padding: 22px; }
.form-grid .full-field { grid-column: 1 / -1; }
.form-grid small { color: var(--muted); font-size: 10px; font-weight: 400; }
.control-dialog .form-error { margin: 0 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; padding: 17px 22px; border-top: 1px solid var(--line); }
.split-actions { display: grid; grid-template-columns: auto 1fr auto auto; }
.credential-note {
  margin: 0;
  padding: 12px;
  color: var(--green-text);
  background: var(--green-soft);
  border-left: 3px solid var(--green);
  border-radius: 7px;
  font-size: 11px;
  line-height: 1.45;
}
.credential-note.error { color: var(--red-text); background: var(--red-soft); border-left-color: var(--red); }
.token-dialog { padding-bottom: 22px; }
.token-dialog > p { margin: 20px 22px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.secret-field { display: flex; margin: 0 22px; background: var(--navy-deep); border-radius: 8px; overflow: hidden; }
.secret-field code { min-width: 0; flex: 1; padding: 14px; overflow: auto; color: white; font-size: 10px; white-space: nowrap; }
.secret-field button { flex: 0 0 auto; padding: 0 14px; color: white; background: var(--teal); border: 0; font-size: 11px; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding-inline: 13px; }
  .sidebar .brand { justify-content: center; }
  .sidebar .brand > span:last-child, .nav-copy > span, .sidebar-foot div { display: none; }
  .nav-link { justify-content: center; padding-inline: 8px; }
  .nav-link b { display: none; }
  .nav-copy { gap: 0; }
  .execution-rail { grid-template-columns: 1fr; gap: 22px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strategy-row { grid-template-columns: minmax(160px, .8fr) minmax(260px, 1.2fr) auto; }
  .strategy-token { display: none; }
}

@media (max-width: 900px) {
  .content-grid, .lower-grid { grid-template-columns: 1fr; }
  .strategy-row { grid-template-columns: minmax(0, 1fr) auto; }
  .strategy-limits { grid-column: 1 / -1; grid-row: 2; }
  .strategy-actions { grid-column: 2; grid-row: 1; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(84vw, 300px);
    height: 100dvh;
    padding: 24px 18px 20px;
    transform: translateX(-105%);
    transition: transform .2s ease;
    box-shadow: 18px 0 45px rgba(8, 30, 40, .22);
  }
  .nav-open .sidebar { transform: translateX(0); }
  .sidebar .brand { justify-content: flex-start; }
  .sidebar .brand > span:last-child, .nav-copy > span, .sidebar-foot div { display: block; }
  nav { margin-top: 42px; }
  .nav-link { justify-content: space-between; padding-inline: 12px; }
  .nav-link b { display: block; }
  .nav-copy { gap: 11px; }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    background: rgba(7, 27, 36, .48);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
  }
  .nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .menu-button { display: grid; place-items: center; }
  main { padding: 24px 16px 30px; }
  .topbar { align-items: flex-start; }
  .execution-rail { margin-top: 24px; padding: 21px; }
  .execution-rail ol { gap: 8px; }
  .execution-rail li { display: block; }
  .execution-rail li div { margin-top: 6px; }
  .execution-rail small { white-space: normal; }
  .metrics article { padding: 18px; }
  .section-head { padding-inline: 18px; }
  .signal-list { padding-inline: 12px; }
  table { min-width: 680px; }
  .login-view { grid-template-columns: 1fr; }
  .login-signal { display: none; }
  .login-panel { margin-block: 26px; }
}

@media (max-width: 520px) {
  h1 { font-size: 26px; }
  .topbar { display: grid; gap: 16px; }
  .top-actions { width: 100%; }
  .user-chip { min-width: 0; flex: 1; align-items: start; justify-items: start; }
  .user-chip span { max-width: 160px; }
  .positions-panel .section-head { flex-wrap: wrap; }
  .section-head-actions { width: 100%; justify-content: space-between; }
  .emergency-button { min-width: 0; flex: 0 0 auto; }
  .emergency-button small { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .execution-rail ol { grid-template-columns: 1fr; gap: 12px; }
  .execution-rail ol::before { top: 18px; bottom: 18px; left: 16px; width: 2px; height: auto; right: auto; }
  .execution-rail li { display: flex; }
  .execution-rail li div { margin-top: 0; }
  .strategy-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .strategy-actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .strategy-limits { grid-column: 1; grid-row: auto; }
  .signal-item { grid-template-columns: 52px minmax(0, 1fr); }
  .signal-status { grid-column: 2; text-align: left; }
  .broker-actions { grid-template-columns: 1fr; }
  footer { display: grid; gap: 5px; }
  .form-grid { grid-template-columns: 1fr; padding: 19px; }
  .form-grid .full-field { grid-column: 1; }
  .dialog-actions { flex-wrap: wrap; padding: 15px 19px; }
  .split-actions { grid-template-columns: 1fr 1fr; }
  .split-actions span { display: none; }
  .login-panel { width: calc(100% - 24px); padding: 30px 22px; }
  .login-panel h1 { font-size: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
