:root {
  --bg: #07070a;
  --surface: #0a0a0f;
  --surface-2: #15151d;
  --panel: #101018;
  --panel-raised: #151620;
  --ink: #f6f7fb;
  --muted: #9da1ad;
  --line: #292a35;
  --primary: #ff4f87;
  --primary-strong: #ff7a35;
  --primary-soft: rgba(255, 79, 135, 0.14);
  --success: #36d88a;
  --success-soft: rgba(54, 216, 138, 0.14);
  --danger: #ff4568;
  --danger-soft: rgba(255, 69, 104, 0.15);
  --warning: #ffbc4b;
  --warning-soft: rgba(255, 188, 75, 0.15);
  --info: #6fc7ff;
  --info-soft: rgba(111, 199, 255, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  --glow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 44px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, #101019 0, var(--bg) 22rem),
    linear-gradient(135deg, rgba(255, 79, 135, 0.08), rgba(255, 122, 53, 0.05) 38%, transparent 72%),
    var(--bg);
  color: var(--ink);
  font-family: "Satoshi", "Geist", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid rgba(255, 122, 53, 0.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;
}

.app-shell {
  width: min(1180px, calc(100% - 18px));
  margin: 0 auto;
  padding: 12px 0 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 16px;
}

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

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.15;
  letter-spacing: 0;
  text-wrap: balance;
}

h3 {
  font-size: 15px;
  line-height: 1.2;
}

.brand p,
.section-head p,
.field span,
.switch-row small,
.meta,
.label {
  color: var(--muted);
}

.brand p {
  margin-top: 2px;
  font-size: 13px;
}

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

.button,
.tab,
.icon-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition:
    background 180ms var(--ease-out),
    border-color 180ms var(--ease-out),
    color 180ms var(--ease-out),
    transform 120ms var(--ease-out);
}

.button:active,
.tab:active,
.icon-button:active,
.pair-card button:active {
  transform: scale(0.98);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.button-primary {
  border-color: rgba(255, 122, 53, 0.64);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: 0 10px 24px rgba(255, 79, 135, 0.22);
}

.button-ghost:hover,
.tab:hover,
.icon-button:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: var(--surface-2);
}

.button-primary:hover {
  filter: brightness(1.08);
}

.button-danger {
  border-color: rgba(255, 69, 104, 0.7);
  background: linear-gradient(135deg, #ff4568, #c92247);
  color: white;
}

.select-wrap select,
.field input,
.field select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b0b11;
  color: var(--ink);
}

.select-wrap select {
  padding: 0 10px;
  font-weight: 800;
}

.connection-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 79, 135, 0.34), rgba(255, 188, 75, 0.2), var(--line));
  box-shadow: var(--glow);
}

.connection-strip > div {
  min-width: 0;
  padding: 9px 10px;
  background: rgba(16, 16, 24, 0.92);
}

.connection-strip .label {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

.connection-strip strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  position: sticky;
  z-index: 10;
  top: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(12, 12, 18, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: var(--glow);
}

.tab {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tab.is-active {
  border-color: rgba(255, 122, 53, 0.58);
  background: linear-gradient(135deg, rgba(255, 79, 135, 0.22), rgba(255, 122, 53, 0.18));
  color: white;
}

.tab.is-active::after {
  display: block;
  width: 16px;
  height: 2px;
  margin: 3px auto 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
  content: "";
}

.page {
  display: none;
}

.page.is-active {
  display: block;
}

.section-head,
.panel-head,
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head {
  margin: 12px 0 8px;
}

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

.section-head p {
  margin-top: 3px;
  max-width: 68ch;
  font-size: 14px;
}

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

.stat-card,
.panel,
.pair-card,
.trade-card,
.settings-grid {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  box-shadow: var(--glow);
}

.stat-card {
  min-height: 70px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  position: absolute;
  inset: 0;
  height: 2px;
  content: "";
  background: linear-gradient(90deg, var(--primary), var(--primary-strong), var(--warning));
  opacity: 0.88;
}

.stat-equity::before,
.stat-win::before,
.stat-winrate::before {
  background: linear-gradient(90deg, var(--success), var(--info));
}

.stat-loss::before,
.stat-failsafe::before {
  background: linear-gradient(90deg, var(--danger), var(--warning));
}

.stat-risk::before {
  background: linear-gradient(90deg, var(--warning), var(--primary-strong));
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card small {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 8px;
  margin-top: 8px;
}

.pair-performance-panel {
  margin-top: 8px;
}

.pair-performance-panel .panel-head p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.pair-performance-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.performance-row {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(82px, 0.55fr) minmax(112px, 0.7fr) minmax(58px, auto);
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.performance-row.pnl-positive {
  border-color: rgba(54, 216, 138, 0.16);
  background: linear-gradient(90deg, rgba(54, 216, 138, 0.07), rgba(255, 255, 255, 0.02) 38%);
}

.performance-row.pnl-negative {
  border-color: rgba(255, 69, 104, 0.18);
  background: linear-gradient(90deg, rgba(255, 69, 104, 0.075), rgba(255, 255, 255, 0.02) 38%);
}

.performance-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
}

.performance-main strong,
.performance-main small,
.performance-pnl strong,
.performance-pnl small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-main strong {
  font-size: 13px;
}

.performance-main small,
.performance-pnl small,
.performance-meta {
  color: var(--muted);
  font-size: 11px;
}

.performance-main .status-pill {
  min-height: 18px;
  padding: 0 6px;
  font-size: 10px;
}

.performance-pnl {
  min-width: 0;
  text-align: right;
}

.performance-pnl strong {
  font-size: 13px;
}

.performance-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  min-width: 0;
  padding: 10px;
}

.panel-head {
  align-items: center;
  margin-bottom: 10px;
}

.count-pill,
.status-pill,
.side-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.count-pill {
  min-width: 28px;
  padding: 0 9px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.compact-list,
.trade-list {
  display: grid;
  gap: 6px;
}

.empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  text-align: center;
}

.list-row,
.factor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.list-row strong,
.trade-card strong,
.pair-main strong {
  display: block;
}

.meta {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pair-grid {
  display: block;
}

.pair-top,
.pair-actions,
.trade-top,
.trade-actions,
.mini-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pair-main {
  min-width: 0;
}

.pair-main strong {
  font-size: 18px;
}

.pair-main small {
  color: var(--muted);
}

.pair-actions,
.trade-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.pair-actions .button,
.trade-actions .button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  padding: 0 9px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pnl-positive {
  color: #7cffbd;
}

.pnl-negative {
  color: #ff9baa;
}

.pnl-flat {
  color: var(--ink);
}

.status-active,
.status-ready,
.status-profit {
  background: var(--success-soft);
  color: #7cffbd;
}

.status-paused,
.status-manual {
  background: var(--warning-soft);
  color: #ffd089;
}

.status-locked,
.status-loss,
.status-error {
  background: var(--danger-soft);
  color: #ff9baa;
}

.status-cooldown,
.status-notrade {
  background: var(--info-soft);
  color: #9bdcff;
}

.side-pill {
  padding: 0 8px;
}

.side-long {
  background: var(--success-soft);
  color: #7cffbd;
}

.side-short {
  background: var(--danger-soft);
  color: #ff9baa;
}

.trade-card {
  padding: 12px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(21, 22, 32, 0.82), rgba(13, 13, 19, 0.92));
  box-shadow: var(--glow);
  overscroll-behavior-x: contain;
  scrollbar-color: rgba(255, 122, 53, 0.36) rgba(255, 255, 255, 0.04);
  scrollbar-width: thin;
}

.table-wrap::-webkit-scrollbar {
  height: 6px;
}

.table-wrap::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

.table-wrap::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 122, 53, 0.42);
}

.data-table {
  display: grid;
  min-width: 820px;
}

.pair-table {
  min-width: 1040px;
}

.table-row {
  display: grid;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 7px 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.trade-table .table-row {
  grid-template-columns: 1.15fr 0.95fr 0.7fr 0.8fr 1fr 0.75fr minmax(190px, auto);
}

.pair-table .table-row {
  grid-template-columns: 1.05fr 0.82fr 0.62fr 1.15fr 1.5fr 0.62fr 0.55fr minmax(236px, auto);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-head {
  min-height: 32px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.trade-row,
.pair-row {
  cursor: pointer;
  transition:
    background 160ms var(--ease-out),
    border-color 160ms var(--ease-out);
}

.trade-row.pnl-positive {
  background: linear-gradient(90deg, rgba(54, 216, 138, 0.08), transparent 34%);
}

.trade-row.pnl-negative {
  background: linear-gradient(90deg, rgba(255, 69, 104, 0.08), transparent 34%);
}

.trade-row:hover,
.pair-row:hover {
  background: rgba(255, 255, 255, 0.035);
}

.symbol-cell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 7px;
  align-items: center;
  min-width: 0;
}

.symbol-cell strong,
.symbol-cell small {
  grid-column: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.symbol-cell .result-dot {
  grid-row: 1 / span 2;
}

.symbol-cell small,
.trade-row small,
.pair-row small,
.sl-tp-cell small,
.pnl-cell small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.sl-tp-cell {
  display: grid;
  gap: 1px;
}

.pnl-cell strong {
  display: block;
  font-size: 13px;
}

.gate-cell {
  min-width: 0;
}

.gate-cell strong,
.gate-cell small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-cell strong {
  font-size: 12px;
}

.gate-cell small {
  color: var(--muted);
  font-size: 11px;
}

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

.mini-button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--ink);
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.mini-button:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

.mini-primary {
  border-color: rgba(255, 122, 53, 0.55);
  background: rgba(255, 122, 53, 0.14);
}

.mini-danger {
  border-color: rgba(255, 69, 104, 0.6);
  background: rgba(255, 69, 104, 0.14);
}

.trade-top {
  align-items: flex-start;
}

.trade-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.result-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--info);
  box-shadow: 0 0 0 4px rgba(111, 199, 255, 0.12);
}

.result-profit {
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(54, 216, 138, 0.13), 0 0 18px rgba(54, 216, 138, 0.28);
}

.result-loss {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 69, 104, 0.14), 0 0 18px rgba(255, 69, 104, 0.26);
}

.result-neutral {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 188, 75, 0.12);
}

.result-open {
  background: var(--info);
  box-shadow: 0 0 0 4px rgba(111, 199, 255, 0.12), 0 0 18px rgba(111, 199, 255, 0.22);
}

.trade-title strong {
  font-size: 17px;
}

.price-grid,
.analysis-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.price-cell,
.analysis-cell {
  min-width: 0;
  padding: 8px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.price-cell span,
.analysis-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.price-cell strong,
.analysis-cell strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.news-panel {
  margin-top: 10px;
}

.news-form {
  display: grid;
  grid-template-columns: 0.75fr 1fr 1fr 1.25fr auto;
  gap: 8px;
  align-items: end;
}

.field,
.switch-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
}

.field {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.field span {
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  padding: 0 10px;
}

.field select {
  width: 100%;
  padding: 0 10px;
}

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
}

.switch-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
}

.switch-row strong,
.switch-row small {
  display: block;
}

.switch-row small {
  margin-top: 2px;
}

.detail-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(82dvh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.detail-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 16, 24, 0.96);
  backdrop-filter: blur(12px);
}

.dialog-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  font-weight: 900;
}

#dialogBody {
  display: grid;
  gap: 12px;
  max-height: calc(min(82dvh, 760px) - 68px);
  overflow: auto;
  padding: 14px;
}

.trade-detail-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
}

.trade-detail-summary.pnl-positive {
  border-color: rgba(54, 216, 138, 0.34);
  background: linear-gradient(135deg, rgba(54, 216, 138, 0.12), rgba(255, 255, 255, 0.018));
}

.trade-detail-summary.pnl-negative {
  border-color: rgba(255, 69, 104, 0.36);
  background: linear-gradient(135deg, rgba(255, 69, 104, 0.12), rgba(255, 255, 255, 0.018));
}

.trade-detail-main {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
}

.trade-detail-main strong,
.trade-detail-main small,
.trade-detail-pnl strong,
.trade-detail-pnl small {
  display: block;
}

.trade-detail-main strong,
.trade-detail-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trade-detail-main small,
.trade-detail-pnl small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.trade-detail-pnl {
  flex: 0 0 auto;
  text-align: right;
}

.trade-detail-pnl strong {
  font-size: 20px;
  line-height: 1;
}

.detail-actionbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.detail-actionbar .button {
  width: 100%;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  padding: 12px;
}

.detail-block h3 {
  margin-bottom: 10px;
}

.factor-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
  margin-top: 6px;
}

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

.factor-chip {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.factor-chip strong,
.factor-chip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factor-chip strong {
  font-size: 12px;
}

.factor-chip span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.factor-long {
  border-color: rgba(54, 216, 138, 0.22);
  background: rgba(54, 216, 138, 0.055);
}

.factor-short {
  border-color: rgba(255, 69, 104, 0.24);
  background: rgba(255, 69, 104, 0.055);
}

.factor-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--danger);
}

.factor-dot.pass {
  background: var(--success);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #15151d;
  color: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms var(--ease-out),
    transform 180ms var(--ease-out);
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-bottom: 86px;
  }

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

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

  .connection-strip,
  .dashboard-grid,
  .pair-performance-list,
  .settings-grid,
  .news-form,
  .price-grid,
  .analysis-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .tabs {
    position: fixed;
    inset: auto 8px calc(8px + env(safe-area-inset-bottom));
    margin: 0;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.54);
  }

  .tab {
    min-height: 42px;
    font-size: 12px;
  }

  .trade-table {
    min-width: 100%;
  }

  .trade-table .table-row {
    grid-template-columns: 1.12fr 0.92fr 0.68fr 0.82fr;
    min-height: 46px;
  }

  .trade-table .table-row > :nth-child(n + 5) {
    display: none;
  }

  .trade-table .table-head {
    position: sticky;
    top: 0;
    z-index: 1;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .connection-strip,
  .settings-grid,
  .news-form,
  .price-grid,
  .analysis-grid,
  .mini-metrics {
    grid-template-columns: 1fr;
  }

  .connection-strip {
    grid-template-columns: 1fr 1fr;
  }

  .connection-strip > div {
    padding: 8px;
  }

  .connection-strip > div:last-child {
    grid-column: 1 / -1;
  }

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

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

  .pair-performance-list {
    grid-template-columns: 1fr;
  }

  .performance-row {
    grid-template-columns: minmax(0, 1fr) minmax(78px, auto) minmax(54px, auto);
  }

  .performance-meta {
    grid-column: 1 / -1;
  }

  .section-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .section-head,
  .panel-head,
  .trade-top {
    align-items: stretch;
    flex-direction: column;
  }

  .section-actions {
    justify-content: stretch;
  }

  .button {
    width: 100%;
  }

  .tab {
    min-height: 38px;
    padding: 0 3px;
    font-size: 10px;
  }

  .top-actions .button,
  .top-actions .select-wrap,
  .top-actions select {
    flex: 1 1 0;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    padding: 4px;
  }

  .tab {
    padding: 0 3px;
  }

  .trade-table .table-row {
    grid-template-columns: minmax(96px, 1.08fr) minmax(74px, 0.92fr) minmax(54px, 0.68fr) minmax(64px, 0.82fr);
    gap: 6px;
    padding: 7px 8px;
  }

  .factor-summary {
    grid-template-columns: 1fr;
  }

  .trade-row small {
    font-size: 10px;
  }

  .side-pill {
    min-height: 22px;
    padding: 0 7px;
    font-size: 11px;
  }

  .detail-dialog {
    width: 100%;
    max-height: calc(92dvh - env(safe-area-inset-bottom));
    margin: auto 0 0;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 14px 14px 0 0;
  }

  #dialogBody {
    max-height: calc(92dvh - 68px - env(safe-area-inset-bottom));
    padding: 12px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .trade-detail-summary {
    align-items: flex-start;
  }

  .trade-detail-pnl strong {
    font-size: 18px;
  }

  .detail-actionbar {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
