:root {
  color-scheme: light;
  --bg: #eef2f3;
  --panel: #ffffff;
  --text: #172026;
  --muted: #62767d;
  --line: #ccd5d8;
  --accent: #116149;
  --danger: #dc2626;
  --warn: #b54708;
  --ok: #15803d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
button, input, select { font: inherit; }
button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 11px;
  font-weight: 650;
  cursor: pointer;
}
button:hover { border-color: #6d8a92; }
button:disabled { opacity: .45; cursor: not-allowed; }
h1, h2, h3, p { margin: 0; letter-spacing: 0; }
p, .muted { color: var(--muted); }

.login-page {
  align-items: center;
  background: #eef2f3;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(23, 32, 38, 0.12);
  display: grid;
  gap: 14px;
  max-width: 380px;
  padding: 22px;
  width: 100%;
}
.login-brand {
  align-items: center;
  display: flex;
  gap: 10px;
}
.login-brand small {
  color: var(--muted);
  display: block;
  margin-top: 2px;
}
.login-message {
  color: var(--warn);
  min-height: 20px;
}
.login-progress {
  display: grid;
  gap: 8px;
}
.login-progress-meta {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.login-progress-meta span,
.login-progress-meta strong {
  color: var(--muted);
  font-size: 12px;
}
.login-progress-track {
  background: #dce5e8;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}
.login-progress-track span {
  background: var(--accent);
  display: block;
  height: 100%;
  transition: width 180ms ease;
  width: 0%;
}
.login-card label {
  color: var(--muted);
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
}
.login-card input {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 40px;
  padding: 9px 11px;
}
.login-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.app {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  background: #172026;
  color: #f5f8f9;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}
.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.brand-icon {
  align-items: center;
  background: #d7fff0;
  border-radius: 6px;
  color: #0c4937;
  display: inline-flex;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  width: 36px;
}
.brand small { color: #a8b8bd; display: block; margin-top: 2px; }
.mode {
  border-radius: 6px;
  font-weight: 800;
  padding: 8px 10px;
  text-align: center;
}
.mode.dry { background: #fff2bf; color: #6d5200; }
.mode.live { background: #dcfce7; color: #14532d; }
.side-stats {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr auto;
  padding: 10px 0;
}
.side-stats span, .sidebar .muted { color: #a8b8bd; }
.logout-button {
  white-space: nowrap;
}
.ok { color: var(--ok); }
.error { color: var(--danger); }
.warn { color: var(--warn); }

.workspace {
  min-width: 0;
  padding: 12px;
}
.toolbar {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.search {
  border: 1px solid var(--line);
  border-radius: 6px;
  flex: 1;
  min-height: 38px;
  min-width: 220px;
  padding: 8px 10px;
}
.tab {
  background: #ffffff;
  color: #56686e;
}
.tab.active {
  background: #172026;
  border-color: #172026;
  color: #ffffff;
}
.status-grid {
  display: grid;
  gap: 7px;
}
.status {
  background: #213039;
  border: 1px solid #385058;
  border-radius: 6px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 0;
  padding: 8px 9px;
}
.status span {
  color: #a8b8bd;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status strong {
  font-size: 13px;
  justify-self: end;
}
.status span:last-child {
  grid-column: 1 / -1;
  margin-top: 3px;
}
.workspace-pane { display: none; }
.workspace-pane.active { display: block; }
.hidden { display: none; }

.market-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.section-title {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.section-title h2 { font-size: 18px; }
.table-wrap { overflow: visible; max-height: none; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1600px;
  font-size: 10px;
}
th, td {
  padding: 3px 2px;
  border: 1px solid #d8dee8;
  text-align: center;
  white-space: nowrap;
}
th { background: #eef2f6; color: #344054; text-align: center; }
.market-header th { background: #ffffff; color: #000000; font-weight: 500; }
tr:hover { background: #f8fafc; }
.game-start td { border-top: 2px solid #98a2b3; }
.game-block-start th { border-top: 3px solid #667085; }
.game-block-start th:first-child,
.game-start td:first-child { border-left: 3px solid #667085; }
.game-block-start th:last-child,
.game-start td:last-child,
.game-block-end td:last-child { border-right: 3px solid #667085; }
.game-block-end td { border-bottom: 3px solid #667085; }
.game-block-end td:first-child { border-left: 1px solid #d8dee8; }
.game-block-end .platform-cell { border-left: 1px solid #d8dee8; }
.price-cell.last-outcome-no,
.market-header th.last-outcome-no { border-right: 3px solid #667085; }
.game-cell {
  min-width: 76px;
  max-width: 86px;
  font-weight: 650;
  vertical-align: middle;
  text-align: center;
  white-space: normal;
}
.team-name {
  line-height: 1.08;
  overflow-wrap: anywhere;
}
.versus {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.1;
  margin: 2px 0;
  text-transform: uppercase;
}
.game-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 500; }
.platform-cell {
  min-width: 70px;
  max-width: 78px;
  white-space: normal;
}
.platform-link {
  color: #0b5cad;
  display: block;
  font-weight: 700;
  font-size: 10px;
  line-height: 1.08;
  text-decoration: none;
}
.platform-link:hover { text-decoration: underline; }
.market-status {
  border-radius: 999px;
  display: inline-block;
  font-size: 8px;
  font-weight: 800;
  line-height: 1;
  margin-top: 3px;
  padding: 2px 4px;
  text-transform: uppercase;
}
.market-status.active { background: #dcfce7; color: #166534; }
.market-status.closed { background: #fee2e2; color: #991b1b; }
.market-status.missing { background: #f1f5f9; color: #64748b; }
.market-status.other { background: #fef3c7; color: #92400e; }
.price-cell { text-align: center; min-width: 36px; max-width: 44px; }
.market-header th { min-width: 36px; }
.market-header th[rowspan] { min-width: 68px; }
.price-action {
  height: 20px;
  min-height: 20px;
  min-width: 32px;
  padding: 0 2px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #0b5cad;
  font: inherit;
  font-weight: 650;
}

.price-view-only {
  color: var(--muted);
  display: inline-block;
  font-variant-numeric: tabular-nums;
  min-width: 42px;
  text-align: right;
}

.price-action:hover { border-color: #9cc2ef; background: #eef6ff; }

.positions-page {
  display: grid;
  gap: 12px;
}
.opportunity-section {
  display: grid;
  gap: 12px;
}
.opportunity-section .positions-header {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.opportunity-section .positions-header p {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}
.opportunity-section .positions-header strong {
  color: var(--text);
  font-size: 20px;
}
.opportunity-section .positions-header span {
  color: var(--muted);
  font-size: 13px;
}
.opportunity-filters {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(120px, 1fr));
  margin-top: 10px;
}
.opportunity-filters label {
  color: var(--muted);
  display: grid;
  font-size: 11px;
  font-weight: 800;
  gap: 4px;
  text-transform: uppercase;
}
.opportunity-filters select {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 34px;
  padding: 6px 8px;
  text-transform: none;
}
.opportunity-list {
  display: grid;
  gap: 10px;
}
.opportunity-row {
  align-items: stretch;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(210px, 1.05fr) minmax(330px, 1.55fr) minmax(420px, 1.8fr) minmax(160px, .8fr);
  padding: 14px;
}
.opportunity-main {
  border-right: 1px solid #e7ecef;
  display: grid;
  gap: 8px;
  min-width: 0;
  padding-right: 12px;
}
.opportunity-main strong,
.opportunity-title-action {
  font-size: 18px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.opportunity-title-action {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  min-height: 0;
  padding: 0;
  text-align: left;
}
.opportunity-title-action:hover {
  color: #0b5cad;
  text-decoration: underline;
}
.opportunity-kicker {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.opportunity-kicker span,
.opportunity-kicker b {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
}
.opportunity-kicker span {
  background: #eef7f4;
  color: #116149;
}
.opportunity-kicker b {
  background: #eef2f6;
  color: #344054;
}
.opportunity-outcome {
  color: #0b5cad;
  font-size: 13px;
  font-weight: 800;
}
.opportunity-updated,
.opportunity-source {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.opportunity-source {
  background: #f8fafc;
  border: 1px solid #e3e8eb;
  border-radius: 6px;
  padding: 7px;
}
.opportunity-legs span,
.opportunity-metrics span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.opportunity-legs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}
.opportunity-legs div,
.opportunity-metrics div {
  background: #f9fbfc;
  border: 1px solid #e3e8eb;
  border-radius: 6px;
  display: grid;
  gap: 4px;
  padding: 9px;
}
.opportunity-leg:first-child {
  border-left: 3px solid #3478ff;
}
.opportunity-leg:nth-child(2) {
  border-left: 3px solid #ff3b35;
}
.opportunity-leg code {
  color: #5a6b72;
  font-size: 10px;
  overflow-wrap: anywhere;
  white-space: normal;
}
.opportunity-leg em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}
.opportunity-legs b,
.opportunity-legs small,
.opportunity-platform-link {
  font-size: 12px;
}
.opportunity-platform-link {
  color: #0b5cad;
  font-weight: 800;
  text-decoration: none;
}
.opportunity-platform-link:hover { text-decoration: underline; }
.opportunity-metrics {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(74px, 1fr));
}
.opportunity-metrics b {
  color: #0b5cad;
  font-size: 13px;
}
.opportunity-metrics .primary-metric {
  background: #eef6ff;
  border-color: #b9d7ff;
}
.opportunity-metrics .primary-metric b {
  color: #075aa8;
  font-size: 16px;
}
.risk-flags {
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}
.risk-flags span {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  color: #9a3412;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 6px;
}
.positions-header {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}
.position-list { overflow-x: auto; }
.positions-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 1100px;
  overflow: hidden;
}
.positions-controls {
  display: flex;
  gap: 10px;
  padding: 12px;
}
.position-filter {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 10px;
  min-width: 180px;
  text-align: left;
}
.positions-platform-summary {
  border-top: 1px solid #edf0f2;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 12px;
}
.platform-summary-item {
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
}
.platform-summary-item strong { font-size: 13px; }
.platform-summary-item span { color: var(--muted); font-size: 12px; }
.platform-summary-item b { font-size: 15px; }
.positions-table { display: grid; }
.position-header-row,
.position-row {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 118px minmax(280px, 2fr) 90px 110px 140px 110px 110px 220px;
  padding: 14px 20px;
}
.position-header-row {
  color: var(--muted);
  font-size: 13px;
}
.position-row { border-top: 1px solid #edf0f2; }
.position-platform-row {
  background: #f6f8fb;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 8px 20px;
}
.position-platform-row span {
  background: #e6e8ef;
  border-radius: 999px;
  color: var(--text);
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
}
.position-platform {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 850;
  justify-self: start;
  padding: 5px 8px;
}
.position-platform.predict { background: #eaf2ff; color: #0b5cad; }
.position-platform.limitless { background: #fff4dc; color: #8a5b00; }
.position-platform.polymarket { background: #e9f7ef; color: #14713c; }
.position-platform.opinion { background: #f0ecff; color: #4f2ea8; }
.position-platform.unknown { background: #eef0f4; color: #4b5563; }
.position-title {
  font-size: 15px;
  font-weight: 750;
  margin-bottom: 10px;
}
.position-title-link {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: #b7c2d1;
  text-underline-offset: 3px;
}
.position-title-link:hover { color: var(--accent); }
.position-side {
  font-size: 14px;
  font-weight: 800;
}
.position-side.yes { color: #3478ff; }
.position-side.no { color: #ff3b35; }
.gain { color: #2563eb; }
.loss { color: #ff3b35; }
.gain span,
.loss span,
.gain small,
.loss small { display: block; }
.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}
.trade-empty,
.empty {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}
form { display: grid; gap: 10px; }
label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
input, select {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  background: white;
  color: var(--text);
}
.check {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--text);
}
.check input { width: auto; height: auto; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.segmented label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--text);
}
.segmented input { width: auto; height: auto; }
.order-estimate {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  font-size: 12px;
}
.order-estimate span { color: var(--muted); }
.result {
  background: #213039;
  border: 1px solid #385058;
  border-radius: 6px;
  color: #d7e0e3;
  font-size: 12px;
  max-height: 240px;
  min-height: 0;
  overflow: auto;
  padding: 9px;
  width: 100%;
  word-break: break-word;
}
.result pre {
  margin: 8px 0 0;
  padding: 8px;
  border-radius: 6px;
  background: #111827;
  color: #f8fafc;
  max-height: 135px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.result-title { font-weight: 800; margin-bottom: 4px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 38, 0.45);
}
.modal {
  width: min(620px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
  padding: 16px;
}
.modal.arbitrage-modal {
  width: min(940px, calc(100vw - 36px));
}
.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.arbitrage-order-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
}
.arbitrage-order-leg {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}
.arbitrage-order-leg.yes { border-left: 3px solid #3478ff; }
.arbitrage-order-leg.no { border-left: 3px solid #ff3b35; }
.arbitrage-leg-title {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}
.arbitrage-leg-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.arbitrage-leg-title strong {
  color: #0b5cad;
  font-size: 13px;
}
.arbitrage-order-leg dl {
  display: grid;
  gap: 6px;
  margin: 0;
}
.arbitrage-order-leg dl div {
  display: grid;
  gap: 8px;
  grid-template-columns: 68px minmax(0, 1fr);
}
.arbitrage-order-leg dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.arbitrage-order-leg dd {
  font-size: 12px;
  margin: 0;
  overflow-wrap: anywhere;
}
.arbitrage-leg-inputs {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}
.arbitrage-total {
  margin-top: 10px;
}
.icon-button {
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}
.modal-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .toolbar, .positions-header { align-items: stretch; flex-direction: column; }
  .table-wrap { overflow: auto; }
  .position-card { grid-template-columns: 1fr; min-width: 0; }
  .opportunity-row { grid-template-columns: 1fr; }
  .opportunity-main { border-right: 0; border-bottom: 1px solid #e7ecef; padding: 0 0 12px; }
  .opportunity-filters { grid-template-columns: 1fr; }
  .opportunity-legs { grid-template-columns: 1fr; }
  .opportunity-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arbitrage-order-grid { grid-template-columns: 1fr; }
  .arbitrage-leg-inputs { grid-template-columns: 1fr; }
  .risk-flags { justify-content: flex-start; }
}
