:root {
  --bg: #1f2220;
  --sidebar: #282b29;
  --panel: #2b2e2c;
  --panel-soft: #333634;
  --text: #ededed;
  --muted: #9ea39f;
  --line: #3c403d;
  --blue: #2b9bdc;
  --green: #32b36b;
  --yellow: #d6a72d;
  --red: #e15b5b;
  --purple: #8b77e8;
  --orange: #df8d33;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  padding-bottom: 36px;
}

button, input, select { font: inherit; }

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #262927;
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover { background: #343836; }
button.primary { background: #1677b9; border-color: #1677b9; color: #fff; }
button.primary:hover { background: #1a6aa8; border-color: #1a6aa8; }
button.secondary {
  background: #1e2a32;
  border-color: #356987;
  color: #b8ddf5;
}
button.secondary:hover { background: #243541; border-color: #3f7ea8; }
button.danger { background: #3a2727; border-color: #6d3434; color: #ffb7b7; }
button.danger:hover { background: #452f2f; border-color: #7a3d3d; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.is-busy {
  opacity: .72;
  cursor: wait;
  position: relative;
}
button.is-busy::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 210px;
  background: var(--sidebar);
  border-right: 1px solid #202321;
  padding: 18px 12px;
  transition: width .18s ease;
  z-index: 10;
}
.sidebar.collapsed { width: 76px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  white-space: nowrap;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, #1e9cf0, #2b65ff);
  font-weight: 700;
}
.brand-copy { min-width: 0; }
.brand-text { font-size: 18px; font-weight: 700; }
.brand-subtitle { color: var(--muted); font-size: 11px; }
.nav { display: grid; gap: 4px; }
.nav-section {
  margin: 14px 10px 4px;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.sidebar.collapsed .nav-section { display: none; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #d5d9d6;
  text-align: left;
  padding: 11px 10px;
}
.nav-item.active, .nav-item:hover { background: #202321; }
.nav-icon {
  width: 28px;
  min-width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #75c9ff;
  background: #16344a;
  font-weight: 700;
  font-size: 12px;
}
.sidebar.collapsed .brand-copy,
.sidebar.collapsed .nav-label { display: none; }
.collapse-btn {
  position: absolute;
  bottom: 16px;
  left: 14px;
  width: 48px;
  padding: 8px 0;
}
.sidebar.collapsed .collapse-btn { width: 48px; }

.shell {
  margin-left: 210px;
  padding: 0 36px 40px;
  min-height: 100vh;
  transition: margin-left .18s ease;
}
.sidebar.collapsed + .shell { margin-left: 76px; }

.topbar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.topbar h1 { margin: 0; font-size: 20px; font-weight: 650; }
.topbar p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
  display: inline-grid;
  grid-template-columns: auto 8px;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #242725;
  color: #c8ccc9;
  font-size: 12px;
}
.notification-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: #242725;
}
.notification-icon {
  width: 17px;
  height: 17px;
  display: inline-grid;
  place-items: center;
  color: #d7dbd8;
}
.notification-icon svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}
.notification-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 11px;
}
.notification-panel {
  position: fixed;
  top: 60px;
  right: 36px;
  width: min(420px, calc(100vw - 96px));
  max-height: 70vh;
  overflow: auto;
  z-index: 30;
  background: #242725;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
}
.notification-panel-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: #2b2e2c;
  border-bottom: 1px solid var(--line);
}
.notification-list { display: grid; gap: 8px; padding: 12px; }
.notification-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #202321;
}
.notification-item strong { display: block; margin-bottom: 4px; }
.notification-meta { color: var(--muted); font-size: 12px; }
.notification-error { border-color: #6d3434; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px rgba(50,179,107,.12); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 0 3px rgba(214,167,45,.12); }
.dot-red { background: var(--red); box-shadow: 0 0 0 3px rgba(225,91,91,.12); }

.page { display: none; }
.page.active { display: block; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
  margin: 4px 0 28px;
}
.metric-card, .panel {
  background: var(--panel);
  border: 1px solid #2e322f;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(255,255,255,.02) inset;
}
.metric-card {
  padding: 20px;
  border-left: 4px solid var(--blue);
}
.accent-green { border-left-color: var(--green); }
.accent-purple { border-left-color: var(--purple); }
.accent-orange { border-left-color: var(--orange); }
.metric-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.metric-value { font-size: 24px; font-weight: 700; margin-top: 8px; }
.metric-hint { color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-runtime-running {
  color: var(--green) !important;
  font-weight: 700;
}
.bot-runtime-stopped {
  color: var(--red) !important;
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.panel {
  padding: 22px;
  background: var(--panel);
  border: 1px solid #2e322f;
  border-radius: 6px;
  min-width: 0;
}
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.panel h2 { margin: 0 0 16px; font-size: 16px; color: #d8dcd9; }
.panel p { margin: 0; color: var(--muted); font-size: 12px; }
.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.segmented { display: flex; gap: 4px; background: #222523; padding: 4px; border-radius: 6px; }
.segmented button { padding: 6px 10px; border: 0; background: transparent; color: var(--muted); }
.segmented button.active { background: #38403a; color: #fff; }

#equityCanvas {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.perf-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.perf-stat-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
}
.perf-stat-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 6px;
}
.perf-stat-card b {
  display: block;
  font-size: 18px;
  color: #eef1ee;
}
.perf-stat-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.page-layout,
.dashboard-layout,
.settings-layout,
.control-layout {
  width: 100%;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #d8dcd9;
}
.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  max-width: 42rem;
}
.panel-title-row,
.control-section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 16px;
}
.panel-title-row h2,
.control-section-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: #d8dcd9;
}
.panel-title-row p,
.control-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  max-width: 42rem;
}

.page-stack {
  grid-column: span 12;
  display: grid;
  gap: 16px;
}
.split-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  align-items: start;
}
.split-panel-grid > section {
  min-width: 0;
}
.split-panel-grid > section + section {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}
.split-panel-grid h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #d8dcd9;
}
.panel-scroll {
  max-height: min(520px, 58vh);
  overflow: auto;
  padding-right: 4px;
}
.panel-footer {
  margin-top: 16px;
}

.settings-panel {
  position: relative;
}
.settings-split {
  margin-top: 4px;
}
.settings-section {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100%;
}
.settings-section-head {
  margin-bottom: 14px;
}
.settings-section-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: #d8dcd9;
}
.settings-section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.settings-form {
  display: grid;
  gap: 14px;
}
.settings-field {
  display: grid;
  gap: 6px;
  margin: 0;
}
.settings-field > span {
  color: var(--muted);
  font-size: 12px;
}
.settings-footer {
  margin-top: auto;
  padding-top: 18px;
  display: grid;
  gap: 12px;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.settings-footer .notice {
  margin-top: 0;
}
.dashboard-notes h2 {
  margin: 0 0 12px;
  font-size: 16px;
}
.dashboard-notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.dashboard-notes-list li {
  margin: 0;
  padding: 10px 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #c8ccc9;
  font-size: 12px;
  line-height: 1.5;
}
.dashboard-ledger {
  grid-column: span 12;
  display: grid;
  gap: 0;
  background: var(--panel);
  border: 1px solid #2e322f;
  border-radius: 6px;
  padding: 18px 20px 20px;
}
.ledger-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 0 0 10px;
}
.ledger-heading h2 {
  margin: 0 0 4px;
  font-size: 17px;
}
.ledger-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}
.ledger-tabs {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  padding: 0 2px;
}
.ledger-tabs button {
  position: relative;
  border: 0;
  background: transparent;
  color: #c8ccc9;
  padding: 12px 0 13px;
  border-radius: 0;
  white-space: nowrap;
  font-size: 15px;
}
.ledger-tabs button:hover {
  color: #fff;
  background: transparent;
}
.ledger-tabs button.active {
  color: #fff;
}
.ledger-tabs button.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #d7dbd8;
}
.ledger-tab-body { padding-top: 10px; }
.ledger-pane { display: none; }
.ledger-pane.active { display: block; }
.table-title-row {
  margin-bottom: 12px;
  align-items: start;
}
.table-title-row h2 {
  margin-bottom: 4px;
}
.table-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #202321;
  color: #cfd4d1;
  font-size: 11px;
  white-space: nowrap;
}

.compact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.compact-list li {
  padding: 10px 12px;
  border-radius: 6px;
  background: #242725;
  color: #cdd1ce;
  border: 1px solid #303431;
  overflow-wrap: anywhere;
}
.system-kv-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.system-kv-list li > span {
  flex: 0 0 96px;
  color: var(--muted);
  font-size: 12px;
}
.system-kv-list li > strong {
  flex: 1 1 auto;
  color: #eef1ee;
  font-weight: 650;
  text-align: right;
  line-height: 1.45;
}

.field-label { display: block; color: var(--muted); margin: 14px 0 6px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #202321;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--blue);
}
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.notice {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #242725;
  color: var(--muted);
  border: 1px solid var(--line);
  line-height: 1.5;
  min-height: 44px;
}
.action-feedback.info {
  background: #242725;
  border-color: var(--line);
  color: #c8ccc9;
}
.action-feedback.pending {
  background: #1f2a35;
  border-color: #2f6ea8;
  color: #b8dcff;
}
.action-feedback.success {
  background: #1b2d22;
  border-color: #2f7a4f;
  color: #9ef0b8;
}
.action-feedback.error {
  background: #2f1f1f;
  border-color: #8a3a3a;
  color: #ffb7b7;
}
.action-toast {
  position: fixed;
  right: 24px;
  bottom: 56px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1f2421;
  color: #e8ece9;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transition: opacity .2s ease, transform .2s ease;
}
.action-toast.hidden {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}
.action-toast.success { border-color: #2f7a4f; background: #1b2d22; color: #9ef0b8; }
.action-toast.error { border-color: #8a3a3a; background: #2f1f1f; color: #ffb7b7; }
.action-toast.pending { border-color: #2f6ea8; background: #1f2a35; color: #b8dcff; }
.control-layout > .panel {
  grid-column: span 12;
  width: 100%;
}
.control-panel-footer {
  margin-top: 16px;
}
.section-head > div,
.control-section-head > div {
  min-width: 0;
}
.runtime-panel::before,
.live-auth-panel::before,
.control-account-panel::before,
.entry-control-panel::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--blue);
  border-radius: 6px 0 0 6px;
}
.live-auth-panel::before { background: var(--orange); }
.control-account-panel::before { background: var(--green); }
.entry-control-panel::before { background: var(--purple); }
.runtime-panel,
.live-auth-panel,
.control-account-panel,
.entry-control-panel {
  position: relative;
  overflow: visible;
}
.live-gate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 10px;
  flex: 0 1 320px;
  min-width: 0;
}
.live-auth-body {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 20px 24px;
  align-items: start;
}
.live-auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  align-items: center;
  flex: 1 1 340px;
  min-width: 0;
}
.live-auth-actions-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
#runtimeActions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
}
.control-status-strip-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.control-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.control-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}
.runtime-action-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.runtime-mode-note {
  width: 100%;
  max-width: 100%;
}
.runtime-mode-note .small-muted {
  margin: 0;
  line-height: 1.5;
}
.control-status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}
.control-status-strip div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #242725;
}
.control-status-strip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}
.control-status-strip b {
  font-size: 13px;
  color: #dfe3e0;
  display: block;
  word-break: break-word;
  white-space: normal;
  line-height: 1.35;
}
.control-account-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
  padding-top: 2px;
}
.control-account-kv .kv {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  border-bottom: 0;
  padding: 12px 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.control-account-kv .kv b {
  width: 100%;
  max-width: 100%;
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.35;
  font-size: 13px;
}
.control-account-kv .kv.kv-uid b {
  font-size: 12px;
  word-break: break-all;
}
.control-account-kv .kv.kv-note {
  grid-column: 1 / -1;
}
.kv-list { display: grid; gap: 10px; }
.kv { display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.kv.kv-note {
  grid-column: 1 / -1;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.kv.kv-note b {
  max-width: 100%;
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  line-height: 1.45;
  font-weight: 500;
  color: #c8d0cb;
}
.kv span:first-child { color: var(--muted); }
.kv b {
  text-align: right;
  min-width: 0;
  max-width: 68%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-grid, .model-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.symbol-card, .model-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}
.symbol-card strong, .model-card strong { display: block; margin-bottom: 10px; }
.small-muted { color: var(--muted); font-size: 12px; }
.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  background: #202321;
  color: #cfd4d1;
  border: 1px solid var(--line);
  font-size: 12px;
}
.control-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.threshold-row {
  display: grid;
  grid-template-columns: 1fr 110px;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.param-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #242725;
}
.param-grid div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #cdd1ce;
  font-size: 12px;
}
.param-grid span {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}
.param-grid b {
  font-weight: 600;
  text-align: right;
}

.data-table {
  overflow-x: auto;
}
.data-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #242725;
}
.data-table td {
  color: #d8dcd9;
  font-size: 13px;
}
.empty-state {
  padding: 18px;
  border-radius: 6px;
  background: #242725;
  color: var(--muted);
  border: 1px solid var(--line);
}

.entry-table { display: grid; gap: 10px; }
.entry-row {
  display: grid;
  grid-template-columns: 140px repeat(3, 112px) 160px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}
.entry-row .symbol { font-weight: 700; }
.check-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d9ddda;
}
.switch-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #d9ddda;
}
.switch-cell input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch-ui {
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: #1e211f;
  border: 1px solid var(--line);
  position: relative;
  transition: background .16s ease, border-color .16s ease;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #8f9691;
  transition: transform .16s ease, background .16s ease;
}
.switch-cell input:checked + .switch-ui {
  background: rgba(50,179,107,.18);
  border-color: rgba(50,179,107,.7);
}
.switch-cell input:checked + .switch-ui::after {
  transform: translateX(18px);
  background: var(--green);
}
.switch-label {
  color: #cfd4d1;
  font-size: 12px;
}

.pnl-up { color: var(--green); font-weight: 600; }
.pnl-down { color: var(--red); font-weight: 600; }
.pnl-flat { color: var(--muted, #8f9691); }

.health-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.health-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  background: #242725;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #cfd4d1;
}

canvas {
  display: block;
  width: 100%;
  background: #242725;
  border-radius: 6px;
}

.price-ticker {
  position: fixed;
  left: 210px;
  right: 0;
  bottom: 0;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 36px;
  background: #181b19;
  border-top: 1px solid #2f342f;
  z-index: 9;
  transition: left .18s ease;
}
.sidebar.collapsed ~ .price-ticker { left: 76px; }
.ticker-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
}
.ticker-symbol { color: var(--muted); font-size: 12px; }
.ticker-price { font-weight: 700; }
.price-up { color: #51d985; }
.price-down { color: #ff7474; }
.price-flat { color: #d7dbd8; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
  .live-gate-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entry-row { grid-template-columns: 1fr 1fr; }
  .perf-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-panel-grid {
    grid-template-columns: 1fr;
    gap: 20px 0;
  }
  .split-panel-grid > section + section {
    border-left: 0;
    padding-left: 0;
    padding-top: 20px;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 720px) {
  .sidebar { width: 76px; }
  .sidebar .brand-copy, .sidebar .nav-label { display: none; }
  .shell { margin-left: 76px; padding: 0 16px 46px; }
  .topbar { height: auto; padding: 18px 0; align-items: flex-start; flex-direction: column; }
  .metric-grid, .symbol-grid, .model-grid, .perf-stats-grid { grid-template-columns: 1fr; }
  .control-form-grid, .control-status-strip, .live-gate-grid { grid-template-columns: 1fr; }
  .live-gate-grid { flex: 1 1 auto; width: 100%; }
  .live-auth-body { grid-template-columns: 1fr; }
  .price-ticker { left: 76px; padding: 0 16px; overflow-x: auto; }
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  position: relative;
  overflow: hidden;
}
.login-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(43, 155, 220, .16), transparent 34%),
    radial-gradient(circle at 85% 10%, rgba(139, 119, 232, .14), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(50, 179, 107, .08), transparent 36%),
    var(--bg);
  z-index: 0;
}
.login-shell {
  width: min(420px, 100%);
  position: relative;
  z-index: 1;
}
.login-card {
  padding: 28px 28px 24px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.login-brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
}
.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.login-lead {
  margin: 0 0 20px;
  color: #c8ccc9;
  font-size: 13px;
  line-height: 1.6;
}
.login-form {
  display: grid;
  gap: 14px;
}
.login-form .field {
  display: grid;
  gap: 6px;
}
.login-form .field span {
  color: var(--muted);
  font-size: 12px;
}
.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #242725;
  color: var(--text);
  padding: 11px 12px;
}
.login-form input:focus {
  outline: none;
  border-color: #1677b9;
  box-shadow: 0 0 0 2px rgba(22, 119, 185, .18);
}
.login-submit {
  width: 100%;
  margin-top: 4px;
  padding: 11px 14px;
}

.account-menu-wrap {
  position: relative;
}
.account-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: #242725;
  border: 1px solid var(--line);
}
.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #1e9cf0, #2b65ff);
}
.account-avatar.large {
  width: 42px;
  height: 42px;
  font-size: 16px;
}
.account-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2b2e2c;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
  z-index: 30;
}
.account-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.account-panel-head strong {
  display: block;
  font-size: 15px;
}
.account-role {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}
.account-meta {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}
.account-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
}
.account-meta-row span {
  color: var(--muted);
}
.account-status-ok {
  color: var(--green);
}
.account-menu-link {
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #242725;
  color: #d8dcd9;
  text-align: left;
  font-weight: 600;
}
.account-menu-link:hover {
  background: #202321;
  border-color: #3a403c;
}
.account-logout-btn {
  width: 100%;
}

.system-panel h2 { margin: 0; }
.system-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.system-metric-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #2a2d2b 0%, #242725 100%);
  min-width: 0;
}
.system-metric-card.level-ok { border-color: rgba(50, 179, 107, .35); }
.system-metric-card.level-warn { border-color: rgba(214, 167, 45, .35); }
.system-metric-card.level-high { border-color: rgba(225, 91, 91, .35); }
.system-metric-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.system-metric-title {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.system-metric-value {
  font-size: 28px;
  font-weight: 700;
  color: #eef1ee;
}
.system-meter {
  height: 10px;
  border-radius: 999px;
  background: #1a1d1b;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.04);
}
.system-meter > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2f9bd7, #32b36b);
  transition: width .45s ease;
}
.system-metric-card.level-warn .system-meter > span {
  background: linear-gradient(90deg, #d19734, #e0b75f);
}
.system-metric-card.level-high .system-meter > span {
  background: linear-gradient(90deg, #dc5b55, #ff928a);
}
.system-metric-foot {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .system-metric-grid { grid-template-columns: 1fr; }
}
