:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --surface-3: #eef4ff;
  --line: #dfe7f2;
  --line-soft: rgba(38, 58, 87, 0.13);
  --text: #1f2937;
  --muted: #65758b;
  --soft: #334155;
  --teal: #2d63b8;
  --teal-ink: #ffffff;
  --green: #19a866;
  --red: #e5485a;
  --amber: #d98b16;
  --blue: #2d63b8;
  --shadow: 0 12px 28px rgba(31, 45, 68, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff 0, var(--bg) 260px);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100%;
  margin: 0 auto;
  padding: 0 12px 18px;
}

body.auth-required .app-shell {
  display: none;
}

body.auth-pending .app-shell,
body.auth-pending .auth-screen {
  display: none;
}

body.auth-ready .auth-screen {
  display: none;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) 18px 24px;
  place-items: center;
}

.auth-card {
  width: min(368px, 100%);
  padding: 24px 24px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-top: 2px;
  font-size: 24px;
}

.auth-card .eyebrow {
  margin-bottom: 8px;
  line-height: 1.2;
}

.auth-card .dashboard-login-form {
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.auth-card .dashboard-login-form input {
  font-size: 14px;
}

.auth-card .dashboard-login-form button {
  width: 100%;
  margin-top: 10px;
}

.auth-card .login-error:empty {
  display: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 52px;
  margin: 0 -12px 8px;
  padding: calc(3px + env(safe-area-inset-top)) 22px 3px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(38, 58, 87, 0.06);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  min-width: 0;
  gap: 9px;
}

.brand-mark {
  display: grid;
  position: relative;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #cfe0f7;
  border-radius: 10px;
  color: var(--blue);
  background: #f4f8ff;
  box-shadow: none;
}

.brand-mark::before {
  display: none;
}

.brand-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 27px;
  height: 27px;
  color: var(--blue);
}

.brand-logo-circuit,
.brand-logo-signal {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-logo-circuit {
  stroke-width: 2.4;
  opacity: 0.82;
}

.brand-logo-signal {
  stroke-width: 2.2;
  opacity: 0.5;
}

.brand-logo-node {
  fill: currentColor;
}

.brand-logo-text {
  fill: currentColor;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  font-weight: 880;
  letter-spacing: 0;
}

.brand-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 1px;
  color: var(--blue);
  font-size: 9px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--text);
  letter-spacing: 0;
}

h1 {
  overflow: hidden;
  font-size: 18px;
  font-weight: 780;
  line-height: 1.08;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 20px;
  font-weight: 760;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.icon-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid #d8e4f4;
  border-radius: 10px;
  color: var(--blue);
  background: #ffffff;
  cursor: pointer;
}

.icon-button {
  width: 34px;
}

.text-button {
  gap: 7px;
  padding: 0 11px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 760;
  text-decoration: none;
}

.text-button.ghost {
  background: #ffffff;
  border-color: #d8e4f4;
}

.icon-button svg,
.text-button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.icon-button:active,
.text-button:active {
  transform: translateY(1px);
}

.icon-button.is-loading svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.page-tabs {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin: 0;
  padding: 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  scrollbar-width: thin;
}

.page-tabs button {
  flex: 0 0 auto;
  min-width: 82px;
  min-height: 45px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: #5c6f89;
  background: transparent;
  font-size: 14px;
  font-weight: 780;
  cursor: pointer;
  white-space: nowrap;
}

.page-tabs button.active {
  color: var(--blue);
  background: var(--surface-3);
}

.page-view[hidden] {
  display: none !important;
}

.hero-panel,
.history-hero,
.panel,
.bot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(680px, 1.28fr);
  gap: 18px;
  margin-bottom: 8px;
  padding: 18px;
}

.history-hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(680px, 1.28fr);
  gap: 18px;
  margin-bottom: 8px;
  padding: 18px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hero-copy h2 {
  font-size: 28px;
}

.hero-copy p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 108px;
  padding: 16px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.metric-label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.metric strong.metric-value-long {
  font-size: 27px;
}

.metric strong.metric-value-xlong {
  font-size: 24px;
  line-height: 1.08;
}

.metric small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
}

.backtest-summary-strip {
  grid-template-columns: minmax(0, 0.78fr) minmax(0, 0.86fr) minmax(0, 1.45fr) minmax(0, 0.95fr) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.backtest-summary-strip .metric {
  min-width: 0;
  min-height: 108px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.backtest-summary-strip .metric strong {
  min-width: 0;
  overflow: hidden;
  font-size: 26px;
  text-overflow: clip;
  white-space: nowrap;
}

.backtest-summary-strip .metric + .metric {
  border-left: 1px solid #e5edf7;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 14px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.control-select,
.control-input {
  min-height: 36px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  color: var(--soft);
  font: inherit;
  font-size: 13px;
  font-weight: 760;
}

.control-select {
  min-width: 118px;
  padding: 0 34px 0 11px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 17px) 15px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 15px / 6px 6px no-repeat,
    #ffffff;
  appearance: none;
}

.control-input {
  width: min(240px, 100%);
  padding: 0 12px;
  background: #ffffff;
}

.control-input::placeholder {
  color: #97a6b8;
}

.control-select:focus,
.control-input:focus {
  outline: 2px solid rgba(45, 99, 184, 0.18);
  border-color: rgba(45, 99, 184, 0.5);
}

.control-select option {
  color: #111;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 3px;
  padding: 4px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: #f8fbff;
}

.history-segmented {
  grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
  min-width: min(100%, 430px);
}

.segmented button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 780;
  cursor: pointer;
}

.segmented button.active {
  color: var(--blue);
  background: var(--surface-3);
}

.toolbar-hint,
.panel-note {
  color: var(--muted);
  font-size: 13px;
}

.insight-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(360px, 0.98fr);
  gap: 14px;
  margin: 0 0 14px;
  align-items: stretch;
}

.risk-grid,
.diagnostic-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.risk-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.risk-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(420px, 1.08fr);
  gap: 14px;
  align-items: start;
}

.risk-page-grid .risk-grid,
.risk-page-grid .diagnostic-list {
  padding: 16px;
}

.risk-page-grid .diagnostic-list {
  grid-template-columns: 1fr;
}

.recommendation-panel {
  margin-bottom: 14px;
}

.risk-top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
  gap: 14px;
  align-items: stretch;
  margin-bottom: 8px;
}

.risk-top-grid .recommendation-panel {
  margin-bottom: 0;
}

.risk-top-grid .panel {
  display: flex;
  flex-direction: column;
}

.risk-top-grid .recommendation-list,
.risk-top-grid .desktop-list {
  flex: 1;
}

.recommendation-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.recommendation-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.recommendation-row.warning {
  border-color: rgba(239, 184, 74, 0.42);
  background: rgba(239, 184, 74, 0.055);
}

.recommendation-row.danger {
  border-color: rgba(255, 100, 112, 0.48);
  background: rgba(255, 100, 112, 0.055);
}

.recommendation-row.watch {
  border-color: rgba(122, 167, 255, 0.42);
  background: rgba(122, 167, 255, 0.055);
}

.recommendation-row strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.recommendation-row p {
  margin: 5px 0 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.5;
}

.risk-card,
.diagnostic-row {
  min-width: 0;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.risk-card {
  display: grid;
  gap: 12px;
  align-self: start;
  align-content: start;
  height: fit-content;
  padding: 13px;
}

.risk-card.no-contributors {
  gap: 10px;
}

.risk-card.warning,
.diagnostic-row.warning {
  border-color: rgba(239, 184, 74, 0.42);
  background: rgba(239, 184, 74, 0.055);
}

.risk-card.danger,
.diagnostic-row.danger {
  border-color: rgba(255, 100, 112, 0.48);
  background: rgba(255, 100, 112, 0.055);
}

.risk-card.watch,
.diagnostic-row.watch {
  border-color: rgba(122, 167, 255, 0.42);
  background: rgba(122, 167, 255, 0.055);
}

.risk-card-head,
.diagnostic-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.risk-card-head strong,
.diagnostic-main strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  font-weight: 780;
}

.risk-card-head span,
.diagnostic-main span,
.diagnostic-meta span,
.exposure-row span {
  color: var(--muted);
  font-size: 12px;
}

.risk-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--green);
  background: rgba(53, 208, 127, 0.12);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.risk-status.warning {
  color: var(--amber);
  background: rgba(239, 184, 74, 0.12);
}

.risk-status.danger {
  color: var(--red);
  background: rgba(255, 100, 112, 0.12);
}

.risk-status.watch {
  color: var(--blue);
  background: rgba(122, 167, 255, 0.12);
}

.risk-status.muted {
  color: var(--muted);
  background: #eef3f9;
}

.risk-meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.risk-meter span,
.diagnostic-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--amber));
}

.diagnostic-progress {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf5;
}

.risk-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.risk-stats div {
  min-width: 0;
  padding: 9px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #ffffff;
}

.risk-stats span,
.risk-stats small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.risk-stats strong {
  display: block;
  overflow-wrap: anywhere;
  margin: 5px 0 3px;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.exposure-row,
.diagnostic-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.exposure-row span,
.diagnostic-meta span {
  min-height: 25px;
  padding: 4px 8px;
  border: 1px solid #e5edf7;
  border-radius: 999px;
  background: #ffffff;
}

.risk-contributors {
  display: grid;
  gap: 7px;
  max-height: min(220px, 32vh);
  overflow-y: auto;
  padding-top: 2px;
}

.risk-contributors-head,
.risk-contributor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(110px, auto);
  gap: 10px;
  align-items: center;
}

.risk-contributors-head {
  padding: 2px 2px 0;
}

.risk-contributors-head strong {
  color: var(--soft);
  font-size: 12px;
  font-weight: 780;
}

.risk-contributors-head span {
  grid-column: 3;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.risk-contributor-row {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: #ffffff;
}

.risk-contributor-row strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 780;
}

.risk-contributor-row span,
.risk-contributor-amount span {
  color: var(--muted);
  font-size: 11px;
}

.risk-contributor-row > div:first-child > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.risk-contributor-amount {
  text-align: right;
}

.risk-contributor-amount strong {
  white-space: nowrap;
}

.diagnostic-row {
  display: grid;
  gap: 8px;
  padding: 11px 12px;
}

.diagnostic-row p {
  margin: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
}

.desktop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 17px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.panel-head.compact {
  min-height: 52px;
}

.panel-head .eyebrow {
  margin-bottom: 2px;
  font-size: 10px;
}

.panel-head h2 {
  font-size: 18px;
  line-height: 1.15;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

.strategy-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.history-table {
  min-width: 0;
}

.backtest-table {
  min-width: 0;
}

.market-table {
  min-width: 0;
}

.robot-panel .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.robot-table {
  min-width: 1840px;
}

.strategy-table th,
.strategy-table td {
  padding: 10px 11px;
  border-bottom: 1px solid #e5edf7;
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-subvalue {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.signal-cell {
  display: grid;
  gap: 4px;
  min-width: 126px;
  align-items: start;
}

.signal-cell.compact {
  min-width: 112px;
}

.signal-cell .risk-status {
  justify-self: start;
}

.signal-cell .table-subvalue {
  margin-top: 0;
  line-height: 1.35;
}

.strategy-table th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 760;
  white-space: nowrap;
}

.strategy-table td {
  color: var(--soft);
  font-size: 13px;
}

.strategy-table tbody tr:last-child td {
  border-bottom: 0;
}

.strategy-table th:first-child,
.strategy-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 1px 0 0 #e5edf7;
}

.strategy-table th:first-child {
  z-index: 3;
  background: rgba(255, 255, 255, 0.98);
}

.strategy-name {
  display: grid;
  min-width: 0;
}

.strategy-name strong {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.strategy-table .strategy-name strong,
.strategy-table .table-subvalue {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(1),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(1) {
  width: 18%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(2),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(2),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(5),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(5) {
  width: 7%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(3),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(3),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(7),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(7),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(9),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(9) {
  width: 6%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(4),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(4),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(8),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(8) {
  width: 5%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(6),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(6) {
  width: 12%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(10),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(10) {
  width: 8%;
}

.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(11),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(11),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) th:nth-child(12),
.strategy-table:not(.market-table):not(.history-table):not(.backtest-table):not(.robot-table):not(.entry-table):not(.open-position-table) td:nth-child(12) {
  width: 10%;
}

.live-strategy-table th:nth-child(1),
.live-strategy-table td:nth-child(1) {
  width: 17%;
}

.live-strategy-table th:nth-child(2),
.live-strategy-table td:nth-child(2),
.live-strategy-table th:nth-child(5),
.live-strategy-table td:nth-child(5) {
  width: 6%;
}

.live-strategy-table th:nth-child(3),
.live-strategy-table td:nth-child(3),
.live-strategy-table th:nth-child(4),
.live-strategy-table td:nth-child(4),
.live-strategy-table th:nth-child(7),
.live-strategy-table td:nth-child(7),
.live-strategy-table th:nth-child(8),
.live-strategy-table td:nth-child(8),
.live-strategy-table th:nth-child(9),
.live-strategy-table td:nth-child(9) {
  width: 5%;
}

.live-strategy-table th:nth-child(6),
.live-strategy-table td:nth-child(6) {
  width: 18%;
}

.live-strategy-table th:nth-child(10),
.live-strategy-table td:nth-child(10) {
  width: 7%;
}

.strategy-panel .table-wrap {
  overflow-x: auto;
}

.live-strategy-table {
  width: max-content;
  min-width: 1450px;
  table-layout: auto;
}

.live-strategy-table th,
.live-strategy-table td {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.live-strategy-table .strategy-name,
.live-strategy-table .strategy-name strong,
.live-strategy-table .table-subvalue {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  overflow-wrap: normal;
}

.live-strategy-table th:nth-child(1),
.live-strategy-table td:nth-child(1) {
  min-width: 260px;
}

.live-strategy-table th:nth-child(2),
.live-strategy-table td:nth-child(2),
.live-strategy-table th:nth-child(5),
.live-strategy-table td:nth-child(5) {
  min-width: 86px;
}

.live-strategy-table th:nth-child(3),
.live-strategy-table td:nth-child(3),
.live-strategy-table th:nth-child(4),
.live-strategy-table td:nth-child(4),
.live-strategy-table th:nth-child(7),
.live-strategy-table td:nth-child(7),
.live-strategy-table th:nth-child(8),
.live-strategy-table td:nth-child(8),
.live-strategy-table th:nth-child(9),
.live-strategy-table td:nth-child(9) {
  min-width: 70px;
}

.live-strategy-table th:nth-child(6),
.live-strategy-table td:nth-child(6) {
  min-width: 245px;
}

.live-strategy-table th:nth-child(10),
.live-strategy-table td:nth-child(10) {
  min-width: 122px;
}

.live-strategy-table .signal-cell {
  min-width: 0;
  white-space: nowrap;
}

.live-strategy-table .signal-cell .table-subvalue {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  overflow-wrap: normal;
  line-height: 1.45;
}

.open-position-panel {
  margin-top: 0;
  margin-bottom: 8px;
}

.open-position-table th,
.open-position-table td {
  padding: 10px 11px;
  white-space: nowrap;
}

.open-position-table th:nth-child(1),
.open-position-table td:nth-child(1) {
  width: 23%;
}

.open-position-table th:nth-child(2),
.open-position-table td:nth-child(2),
.open-position-table th:nth-child(4),
.open-position-table td:nth-child(4),
.open-position-table th:nth-child(8),
.open-position-table td:nth-child(8) {
  width: 7%;
}

.open-position-table th:nth-child(3),
.open-position-table td:nth-child(3) {
  width: 11%;
}

.open-position-table th:nth-child(5),
.open-position-table td:nth-child(5),
.open-position-table th:nth-child(6),
.open-position-table td:nth-child(6),
.open-position-table th:nth-child(7),
.open-position-table td:nth-child(7),
.open-position-table th:nth-child(9),
.open-position-table td:nth-child(9),
.open-position-table th:nth-child(10),
.open-position-table td:nth-child(10) {
  width: 9%;
}

.open-position-table td:nth-child(5),
.open-position-table td:nth-child(6),
.open-position-table td:nth-child(7),
.open-position-table td:nth-child(10) {
  font-variant-numeric: tabular-nums;
}

.open-position-table td:nth-child(10) strong {
  display: block;
}

.robot-table th,
.robot-table td {
  padding: 8px 8px;
  white-space: nowrap;
}

.robot-table th:nth-child(1),
.robot-table td:nth-child(1) {
  width: 250px;
}

.robot-table th:nth-child(2),
.robot-table td:nth-child(2) {
  width: 78px;
}

.robot-table th:nth-child(3),
.robot-table td:nth-child(3),
.robot-table th:nth-child(4),
.robot-table td:nth-child(4) {
  width: 88px;
}

.robot-table th:nth-child(5),
.robot-table td:nth-child(5) {
  width: 120px;
}

.robot-table th:nth-child(6),
.robot-table td:nth-child(6),
.robot-table th:nth-child(10),
.robot-table td:nth-child(10) {
  width: 82px;
}

.robot-table th:nth-child(7),
.robot-table td:nth-child(7) {
  width: 72px;
}

.robot-table th:nth-child(8),
.robot-table td:nth-child(8) {
  width: 118px;
}

.robot-table th:nth-child(9),
.robot-table td:nth-child(9),
.robot-table th:nth-child(11),
.robot-table td:nth-child(11) {
  width: 130px;
}

.robot-table th:nth-child(12),
.robot-table td:nth-child(12) {
  width: 150px;
}

.robot-table th:nth-child(13),
.robot-table td:nth-child(13) {
  width: 96px;
}

.robot-table th:nth-child(14),
.robot-table td:nth-child(14) {
  width: 210px;
  text-align: right;
}

.robot-table th:first-child,
.robot-table td:first-child {
  min-width: 250px;
}

.robot-name-cell {
  overflow: visible !important;
  position: sticky !important;
  min-width: 0;
  max-width: 250px;
  z-index: 4 !important;
}

.robot-strategy-name {
  min-width: 0;
  gap: 3px;
}

.robot-leverage-cell {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 780;
  overflow: visible;
  text-overflow: clip;
}

.leverage-stack {
  display: grid;
  gap: 2px;
  align-items: center;
  min-width: 0;
  line-height: 1.15;
}

.leverage-stack strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.leverage-stack span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 720;
  white-space: nowrap;
}

.robot-strategy-name strong {
  font-size: 13px;
}

.robot-strategy-name strong,
.robot-meta-line {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
}

.robot-meta-line {
  margin-top: 2px;
  font-size: 11px;
}

.robot-exchange-cell,
.robot-chip-cell,
.robot-open-cell,
.robot-profit-cell {
  width: 1%;
}

.robot-open-cell,
.robot-profit-cell {
  font-variant-numeric: tabular-nums;
}

.robot-amount {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.actual-stake-cell {
  position: relative;
  min-width: 150px;
}

.holding-stake-cell {
  font-variant-numeric: tabular-nums;
}

.holding-stake {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.holding-stake.is-empty {
  color: var(--muted);
  font-weight: 750;
}

.actual-stake {
  position: relative;
  display: grid;
  gap: 2px;
  min-width: 0;
  white-space: nowrap;
  line-height: 1.2;
}

.actual-stake strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.actual-stake span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actual-stake em {
  justify-self: start;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 820;
}

.actual-stake.is-ok em {
  background: rgba(53, 208, 127, 0.13);
  color: var(--green);
}

.actual-stake.is-mismatch em {
  background: rgba(255, 92, 121, 0.14);
  color: var(--danger);
}

.actual-stake.is-observation em {
  background: rgba(244, 180, 65, 0.15);
  color: var(--amber);
}

.actual-stake.is-adjusted strong {
  font-size: 11px;
}

.actual-stake.is-adjusted em {
  background: rgba(244, 180, 65, 0.15);
  color: var(--amber);
}

.market-side {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 840;
  line-height: 1;
  white-space: nowrap;
}

.market-side.buy {
  border: 1px solid rgba(53, 208, 127, 0.42);
  color: var(--green);
  background: rgba(53, 208, 127, 0.12);
}

.market-side.sell {
  border: 1px solid rgba(255, 100, 112, 0.42);
  color: var(--red);
  background: rgba(255, 100, 112, 0.12);
}

.market-change {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 840;
  line-height: 1;
  white-space: nowrap;
}

.market-change.positive {
  border: 1px solid rgba(53, 208, 127, 0.42);
  color: var(--green);
  background: rgba(53, 208, 127, 0.12);
}

.market-change.negative {
  border: 1px solid rgba(255, 100, 112, 0.42);
  color: var(--red);
  background: rgba(255, 100, 112, 0.12);
}

.market-table th:nth-child(1),
.market-table td:nth-child(1) {
  width: 14%;
}

.market-table th:nth-child(2),
.market-table td:nth-child(2),
.market-table th:nth-child(4),
.market-table td:nth-child(4),
.market-table th:nth-child(5),
.market-table td:nth-child(5) {
  width: 10%;
}

.market-table th:nth-child(3),
.market-table td:nth-child(3) {
  width: 8%;
}

.market-table th:nth-child(6),
.market-table td:nth-child(6) {
  width: 16%;
}

.market-table th:nth-child(7),
.market-table td:nth-child(7) {
  width: 13%;
}

.market-table th:nth-child(8),
.market-table td:nth-child(8) {
  width: 19%;
  white-space: nowrap;
}

.entry-table th,
.entry-table td {
  white-space: nowrap;
}

.entry-table {
  min-width: 1580px;
}

.entry-table th:nth-child(1),
.entry-table td:nth-child(1) {
  width: 245px;
}

.entry-table th:nth-child(2),
.entry-table td:nth-child(2) {
  width: 110px;
}

.entry-table th:nth-child(3),
.entry-table td:nth-child(3) {
  width: 112px;
}

.entry-table th:nth-child(4),
.entry-table td:nth-child(4) {
  width: 230px;
  white-space: normal;
}

.entry-table th:nth-child(5),
.entry-table td:nth-child(5),
.entry-table th:nth-child(8),
.entry-table td:nth-child(8),
.entry-table th:nth-child(9),
.entry-table td:nth-child(9),
.entry-table th:nth-child(10),
.entry-table td:nth-child(10) {
  width: 105px;
}

.entry-table th:nth-child(6),
.entry-table td:nth-child(6),
.entry-table th:nth-child(7),
.entry-table td:nth-child(7) {
  width: 165px;
}

.entry-table th:nth-child(11),
.entry-table td:nth-child(11) {
  width: 190px;
}

.entry-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  border: 1px solid #dbe5f1;
  background: #f8fbff;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.entry-action.long {
  color: var(--green);
  border-color: rgba(53, 208, 127, 0.36);
  background: rgba(53, 208, 127, 0.11);
}

.entry-action.short {
  color: var(--red);
  border-color: rgba(255, 100, 112, 0.36);
  background: rgba(255, 100, 112, 0.1);
}

.entry-action.pending,
.entry-action.waiting {
  color: var(--amber);
  border-color: rgba(239, 184, 74, 0.35);
  background: rgba(239, 184, 74, 0.11);
}

.entry-reason {
  display: grid;
  gap: 3px;
  align-items: start;
  min-width: 0;
  line-height: 1.3;
}

.entry-reason strong {
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
}

.entry-reason span {
  color: var(--muted);
  font-size: 11px;
  white-space: normal;
}

.entry-reason.normal strong {
  color: var(--green);
}

.entry-reason.watch strong {
  color: var(--blue);
}

.entry-reason.warning strong {
  color: var(--amber);
}

.entry-reason.danger strong {
  color: var(--red);
}

.entry-reason.muted strong {
  color: var(--muted);
}

.entry-reason-stat {
  align-content: start;
}

.entry-reason-stat > span {
  display: block;
  margin-bottom: 4px;
}

.entry-card .normal {
  color: var(--green);
}

.entry-card .watch {
  color: var(--blue);
}

.entry-card .danger {
  color: var(--red);
}

.entry-card .muted {
  color: var(--muted);
}

.history-table th:nth-child(1),
.history-table td:nth-child(1),
.history-table th:nth-child(9),
.history-table td:nth-child(9) {
  width: 16%;
}

.history-table th:nth-child(2),
.history-table td:nth-child(2) {
  width: 13%;
}

.history-table th:nth-child(3),
.history-table td:nth-child(3),
.history-table th:nth-child(4),
.history-table td:nth-child(4) {
  width: 7%;
}

.history-table th:nth-child(5),
.history-table td:nth-child(5),
.history-table th:nth-child(6),
.history-table td:nth-child(6),
.history-table th:nth-child(8),
.history-table td:nth-child(8) {
  width: 10%;
}

.history-table th:nth-child(7),
.history-table td:nth-child(7) {
  width: 11%;
}

.side-stack {
  display: grid;
  gap: 14px;
}

.side-stack .risk-grid,
.side-stack .diagnostic-list {
  padding: 12px;
}

.side-stack .risk-grid {
  grid-template-columns: 1fr;
}

.side-stack .diagnostic-list {
  max-height: 360px;
  overflow-y: auto;
}

.side-stack .risk-card {
  gap: 10px;
}

.side-stack .risk-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.side-stack .diagnostic-row p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.desktop-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.list-row,
.trade-row,
.issue-row {
  display: grid;
  gap: 7px;
  padding: 11px 12px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.issue-row.warning {
  border-color: rgba(239, 184, 74, 0.42);
  background: rgba(239, 184, 74, 0.055);
}

.issue-row.danger {
  border-color: rgba(255, 100, 112, 0.48);
  background: rgba(255, 100, 112, 0.055);
}

.issue-row.watch {
  border-color: rgba(122, 167, 255, 0.42);
  background: rgba(122, 167, 255, 0.055);
}

.issue-empty {
  display: grid;
  gap: 7px;
  align-content: center;
  min-height: 96px;
  padding: 15px;
  border: 1px solid rgba(53, 208, 127, 0.25);
  border-radius: 8px;
  background: rgba(53, 208, 127, 0.055);
}

.issue-empty strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.issue-empty span {
  color: var(--muted);
  font-size: 12px;
}

.list-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.list-row strong,
.trade-row strong,
.issue-row strong {
  color: var(--soft);
  font-size: 13px;
}

.list-row span,
.trade-row span,
.issue-row span {
  color: var(--muted);
  font-size: 12px;
}

.state-chip,
.direction-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.state-chip.running {
  color: #ffffff;
  background: var(--green);
}

.state-chip.offline {
  color: #ffffff;
  background: var(--red);
}

.state-chip.idle {
  color: #ffffff;
  background: var(--amber);
}

.direction-pill {
  color: var(--soft);
  border: 1px solid #dbe5f1;
  background: #f8fbff;
}

.direction-pill.long {
  color: var(--green);
  border-color: rgba(53, 208, 127, 0.36);
  background: rgba(53, 208, 127, 0.11);
}

.direction-pill.short {
  color: var(--red);
  border-color: rgba(255, 100, 112, 0.36);
  background: rgba(255, 100, 112, 0.1);
}

.direction-pill.mixed {
  color: var(--teal);
  border-color: rgba(35, 198, 190, 0.38);
  background: rgba(35, 198, 190, 0.11);
}

.backtest-table th:nth-child(7),
.backtest-table td:nth-child(7) {
  width: 10%;
  min-width: 0;
  white-space: nowrap;
}

.backtest-table th:nth-child(1),
.backtest-table td:nth-child(1),
.backtest-table th:nth-child(15),
.backtest-table td:nth-child(15) {
  width: 12%;
}

.backtest-table th:nth-child(2),
.backtest-table td:nth-child(2),
.backtest-table th:nth-child(10),
.backtest-table td:nth-child(10),
.backtest-table th:nth-child(11),
.backtest-table td:nth-child(11) {
  width: 8%;
}

.backtest-table th:nth-child(3),
.backtest-table td:nth-child(3),
.backtest-table th:nth-child(4),
.backtest-table td:nth-child(4),
.backtest-table th:nth-child(9),
.backtest-table td:nth-child(9) {
  width: 6%;
}

.backtest-table th:nth-child(5),
.backtest-table td:nth-child(5) {
  width: 5.8%;
}

.backtest-table th:nth-child(6),
.backtest-table td:nth-child(6),
.backtest-table th:nth-child(8),
.backtest-table td:nth-child(8),
.backtest-table th:nth-child(12),
.backtest-table td:nth-child(12),
.backtest-table th:nth-child(13),
.backtest-table td:nth-child(13),
.backtest-table th:nth-child(14),
.backtest-table td:nth-child(14) {
  width: 4.8%;
}

.backtest-table th:nth-child(14),
.backtest-table td:nth-child(14) {
  white-space: nowrap;
}

.backtest-panel .table-wrap {
  overflow-x: auto;
}

.backtest-table {
  width: max-content;
  min-width: 2040px;
  table-layout: auto;
}

.backtest-table th,
.backtest-table td {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.backtest-table .strategy-name,
.backtest-table .strategy-name strong,
.backtest-table .table-subvalue {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  overflow-wrap: normal;
}

.backtest-table th:nth-child(1),
.backtest-table td:nth-child(1) {
  min-width: 230px;
}

.backtest-table th:nth-child(2),
.backtest-table td:nth-child(2) {
  min-width: 210px;
}

.backtest-table th:nth-child(3),
.backtest-table td:nth-child(3),
.backtest-table th:nth-child(4),
.backtest-table td:nth-child(4),
.backtest-table th:nth-child(6),
.backtest-table td:nth-child(6),
.backtest-table th:nth-child(8),
.backtest-table td:nth-child(8) {
  min-width: 82px;
}

.backtest-table th:nth-child(5),
.backtest-table td:nth-child(5) {
  min-width: 104px;
}

.backtest-table th:nth-child(7),
.backtest-table td:nth-child(7) {
  min-width: 190px;
}

.backtest-table th:nth-child(9),
.backtest-table td:nth-child(9),
.backtest-table th:nth-child(10),
.backtest-table td:nth-child(10),
.backtest-table th:nth-child(11),
.backtest-table td:nth-child(11) {
  min-width: 132px;
}

.backtest-table th:nth-child(12),
.backtest-table td:nth-child(12),
.backtest-table th:nth-child(13),
.backtest-table td:nth-child(13),
.backtest-table th:nth-child(14),
.backtest-table td:nth-child(14) {
  min-width: 105px;
}

.backtest-table th:nth-child(15),
.backtest-table td:nth-child(15) {
  min-width: 230px;
}

.backtest-leverage-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 780;
}

.positive {
  color: var(--green) !important;
}

.negative {
  color: var(--red) !important;
}

.muted-value {
  color: var(--muted) !important;
}

.bot-grid {
  display: none;
}

.history-card-grid {
  display: none;
}

.bot-card {
  padding: 15px;
}

.bot-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bot-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.bot-card h2 {
  overflow-wrap: anywhere;
  font-size: 17px;
}

.bot-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.bot-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.bot-stats div {
  min-height: 70px;
  padding: 10px;
  border: 1px solid #e5edf7;
  border-radius: 8px;
  background: var(--surface-2);
}

.bot-stats span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.bot-stats strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 17px;
  font-weight: 760;
}

.bot-stats .signal-stat {
  min-height: 82px;
}

.bot-stats .signal-stat strong {
  font-size: 13px;
}

.open-trades,
.issues {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.trade-row {
  grid-template-columns: 1fr auto;
}

.empty-note {
  color: var(--muted);
  font-size: 13px;
}

.login-hint {
  max-width: 720px;
  padding: 18px;
}

.login-hint h2 {
  margin-bottom: 10px;
}

.login-hint p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.hint-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hint-actions a,
.hint-actions button,
.action-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(45, 99, 184, 0.35);
  border-radius: 8px;
  color: var(--teal-ink);
  background: var(--teal);
  font-size: 14px;
  font-weight: 760;
  line-height: 40px;
  text-decoration: none;
  cursor: pointer;
}

.hint-actions button,
.action-button.secondary {
  color: var(--soft);
  background: #ffffff;
  border-color: #dbe5f1;
}

.dashboard-login-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 8px;
}

.dashboard-login-form label {
  display: grid;
  gap: 7px;
}

.dashboard-login-form span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.dashboard-login-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

.dashboard-login-form input:focus {
  outline: 2px solid rgba(45, 99, 184, 0.18);
  border-color: rgba(45, 99, 184, 0.5);
}

.dashboard-login-form button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(45, 99, 184, 0.45);
  border-radius: 8px;
  color: var(--teal-ink);
  background: var(--teal);
  font: inherit;
  font-weight: 760;
  cursor: pointer;
}

.dashboard-login-form button:disabled {
  opacity: 0.7;
  cursor: wait;
}

.login-error {
  min-height: 20px;
  margin-top: 10px;
  color: var(--red);
}

.action-button {
  min-height: 34px;
  border-radius: 7px;
  line-height: 34px;
  white-space: nowrap;
}

.action-button.stop {
  color: #1c0507;
  background: var(--red);
  border-color: rgba(255, 100, 112, 0.45);
}

.action-button.start {
  color: var(--teal-ink);
  background: var(--teal);
  border-color: rgba(45, 99, 184, 0.4);
}

.action-button.restart {
  color: #1b1304;
  background: var(--amber);
  border-color: rgba(255, 196, 87, 0.45);
}

.action-button.add {
  color: var(--teal-ink);
  background: var(--teal);
  border-color: rgba(45, 99, 184, 0.45);
}

.action-button:disabled {
  color: var(--muted);
  background: #eef3f9;
  border-color: #dbe5f1;
  cursor: not-allowed;
  opacity: 0.72;
}

.risk-input {
  width: 76px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid #c9d8eb;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 760;
}

.risk-input:focus {
  outline: 2px solid rgba(45, 99, 184, 0.18);
  border-color: rgba(45, 99, 184, 0.55);
}

.table-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.robot-table .risk-input {
  width: 58px;
  min-height: 28px;
  padding: 0 7px;
  border-radius: 7px;
  font-size: 12px;
}

.robot-table .state-chip,
.robot-table .direction-pill {
  min-height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.robot-table .table-actions {
  flex-wrap: nowrap;
  gap: 5px;
  min-width: 0;
  justify-content: flex-end;
}

.robot-table .action-button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 28px;
}

.exchange-table th,
.exchange-table td {
  padding: 9px 10px;
  white-space: nowrap;
}

.exchange-table th:nth-child(1),
.exchange-table td:nth-child(1) {
  width: 18%;
}

.exchange-table th:nth-child(2),
.exchange-table td:nth-child(2),
.exchange-table th:nth-child(3),
.exchange-table td:nth-child(3),
.exchange-table th:nth-child(7),
.exchange-table td:nth-child(7),
.exchange-table th:nth-child(8),
.exchange-table td:nth-child(8),
.exchange-table th:nth-child(10),
.exchange-table td:nth-child(10) {
  width: 7%;
}

.exchange-table th:nth-child(4),
.exchange-table td:nth-child(4),
.exchange-table th:nth-child(5),
.exchange-table td:nth-child(5),
.exchange-table th:nth-child(6),
.exchange-table td:nth-child(6) {
  width: 8%;
}

.exchange-table th:nth-child(9),
.exchange-table td:nth-child(9) {
  position: relative;
  width: 16%;
  overflow: visible;
}

.exchange-table th:nth-child(11),
.exchange-table td:nth-child(11) {
  width: 7%;
  text-align: right;
}

.exchange-table .table-actions {
  justify-content: flex-end;
}

.exchange-table .action-button {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 30px;
}

.exchange-panel,
.exchange-panel .table-wrap {
  overflow: visible;
}

.exchange-account-name strong,
.exchange-card h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exchange-balance {
  position: relative;
  display: inline-flex;
  width: 100%;
  max-width: 150px;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
  outline: none;
}

.exchange-balance strong {
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.exchange-balance span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exchange-balance-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 9px);
  z-index: 50;
  display: none;
  min-width: 220px;
  max-width: 360px;
  padding: 10px 12px;
  border: 1px solid #c9d8eb;
  border-radius: 8px;
  box-shadow: 0 14px 32px rgba(31, 45, 68, 0.16);
  background: #ffffff;
  color: var(--text);
  white-space: normal;
}

.exchange-balance-popover::after {
  position: absolute;
  left: 18px;
  top: -6px;
  width: 10px;
  height: 10px;
  border-top: 1px solid #c9d8eb;
  border-left: 1px solid #c9d8eb;
  background: #ffffff;
  content: "";
  transform: rotate(45deg);
}

.exchange-balance-popover b,
.exchange-balance-popover span {
  display: block;
  max-width: none;
  overflow: visible;
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  text-overflow: clip;
  white-space: normal;
}

.exchange-balance-popover b {
  margin-bottom: 4px;
  color: var(--teal);
}

.exchange-balance-popover span {
  color: var(--soft);
}

.exchange-balance-popover .exchange-balance-source {
  white-space: nowrap;
}

.exchange-balance-detail {
  display: grid;
  gap: 3px;
  margin: 2px 0 6px;
}

.exchange-balance-popover .exchange-balance-detail-row {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: baseline;
  column-gap: 20px;
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.exchange-balance-detail-row em {
  color: var(--muted);
  font-style: normal;
  letter-spacing: 0;
}

.exchange-balance-detail-row strong {
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.exchange-balance:hover .exchange-balance-popover,
.exchange-balance:focus .exchange-balance-popover,
.exchange-balance:focus-within .exchange-balance-popover {
  display: block;
}

.secret-mask {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid #dbe5f1;
  border-radius: 999px;
  color: var(--soft);
  background: #f8fbff;
  font-size: 12px;
  font-weight: 820;
  letter-spacing: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 90px rgba(31, 45, 68, 0.24);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid #e5edf7;
}

.modal-head .icon-button {
  color: var(--muted);
  background: #ffffff;
  border-color: #dbe5f1;
  font-size: 28px;
  line-height: 1;
}

.modal-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-form label {
  display: grid;
  gap: 7px;
}

.modal-form label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.modal-form input,
.modal-form select {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid #dbe5f1;
  border-radius: 8px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

.modal-form select {
  appearance: none;
}

.modal-form input:focus,
.modal-form select:focus {
  outline: 2px solid rgba(45, 99, 184, 0.18);
  border-color: rgba(45, 99, 184, 0.5);
}

.modal-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 1180px) {
  .hero-panel,
  .history-hero {
    grid-template-columns: 1fr;
  }

  .insight-layout {
    grid-template-columns: 1fr;
  }

  .desktop-layout {
    grid-template-columns: 1fr;
  }

  .risk-page-grid {
    grid-template-columns: 1fr;
  }

  .risk-top-grid {
    grid-template-columns: 1fr;
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .risk-grid {
    grid-template-columns: 1fr;
  }

  .desktop-layout {
    display: none;
  }

  .bot-grid,
  .history-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .history-panel,
  .market-panel,
  .backtest-panel,
  .robot-panel {
    display: none;
  }

  .hero-panel,
  .history-hero {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .hero-copy {
    display: none;
  }

  .insight-layout {
    margin-top: 12px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .backtest-summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .backtest-summary-strip .metric {
    min-height: 104px;
    border-left: 0;
    border-top: 1px solid #e5edf7;
  }

  .backtest-summary-strip .metric:nth-child(-n + 2) {
    border-top: 0;
  }

  .backtest-summary-strip .metric:nth-child(even) {
    border-left: 1px solid #e5edf7;
  }

  .side-stack {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 0 12px 12px;
  }

  .topbar {
    flex-wrap: wrap;
    min-height: 54px;
    margin: 0 -12px 8px;
    padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
    gap: 6px 9px;
  }

  .brand {
    flex: 1 1 auto;
    gap: 8px;
  }

  .brand-mark {
    flex-basis: 32px;
    width: 32px;
    height: 32px;
  }

  .brand-logo {
    width: 24px;
    height: 24px;
  }

  .eyebrow {
    font-size: 9px;
  }

  h1 {
    font-size: 17px;
  }

  .text-button span {
    display: none;
  }

  .text-button,
  .icon-button {
    width: 32px;
    min-height: 32px;
    padding: 0;
  }

  .page-tabs {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    gap: 7px;
    padding: 2px 0;
  }

  .page-tabs button {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
  }

  .dashboard-login-form {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    gap: 8px;
  }

  .backtest-summary-strip {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .backtest-summary-strip .metric,
  .backtest-summary-strip .metric:nth-child(even) {
    border-left: 0;
  }

  .backtest-summary-strip .metric:nth-child(n) {
    border-top: 1px solid #e5edf7;
  }

  .backtest-summary-strip .metric:first-child {
    border-top: 0;
  }

  .metric {
    min-height: 92px;
    padding: 13px;
  }

  .risk-grid,
  .diagnostic-list {
    padding: 12px;
  }

  .recommendation-row {
    grid-template-columns: 1fr;
  }

  .risk-stats {
    grid-template-columns: 1fr;
  }

  .risk-contributors-head,
  .risk-contributor-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .risk-contributors-head span,
  .risk-contributor-amount {
    grid-column: auto;
    text-align: left;
  }

  .metric-label {
    margin-bottom: 11px;
  }

  .metric strong {
    font-size: 24px;
  }

  .metric strong.metric-value-long {
    font-size: 22px;
  }

  .metric strong.metric-value-xlong {
    font-size: 20px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-controls {
    justify-content: stretch;
  }

  .control-select,
  .control-input {
    flex: 1 1 150px;
    min-width: 0;
    width: auto;
  }

  .segmented {
    width: 100%;
  }

  .toolbar-hint {
    display: none;
  }

  .bot-card {
    padding: 13px;
  }

  .bot-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .bot-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .risk-input {
    width: 100%;
    min-width: 72px;
  }

  .modal-actions .action-button {
    flex: 1 1 150px;
    text-align: center;
  }
}
