:root {
  color-scheme: dark;
  --ink: #0a0a0b;
  --panel: #151516;
  --panel-hover: #1a1a1c;
  --grid: #2b2c2e;
  --text: #f2f2f0;
  --muted: #8b8c90;
  --signal: #18d391;
  --buy: #14c77a;
  --sell: #ff4f59;
  --amber: #e5bd64;
  --cyan: #58b6e7;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden], .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
body { min-width: 320px; margin: 0; color: var(--text); background: var(--ink); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.matrix-shell { min-height: 100vh; padding: 0 clamp(14px, 2.4vw, 42px) 54px; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-6); border-bottom: 1px solid var(--grid); }
.brand-lockup { min-width: 0; display: flex; align-items: center; gap: clamp(26px, 3.2vw, 52px); }
.brand-name { flex: none; font-size: 14px; font-weight: 800; letter-spacing: -.03em; }
.workspace-nav { min-width: 0; height: 72px; display: flex; align-items: stretch; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.workspace-nav::-webkit-scrollbar { display: none; }
.workspace-nav a { position: relative; flex: none; display: flex; align-items: center; padding: 1px clamp(9px, 1.05vw, 15px) 0; color: #85868a; font: 700 10px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .015em; white-space: nowrap; transition: color 140ms ease-out, background-color 140ms ease-out; }
.workspace-nav a:hover { color: var(--text); background: rgba(255, 255, 255, .025); }
.workspace-nav a.is-active { color: var(--text); background: rgba(24, 211, 145, .055); }
.workspace-nav a.is-active::after { content: ""; position: absolute; right: 11px; bottom: -1px; left: 11px; height: 2px; background: var(--signal); }
.member-link { flex: none; min-height: 40px; display: inline-flex; align-items: center; padding: 0 15px; border: 1px solid var(--grid); border-radius: 10px; color: var(--text); font-size: 13px; font-weight: 750; transition: color 140ms ease-out, border-color 140ms ease-out, background-color 140ms ease-out; }
.member-link:hover { color: var(--signal); border-color: var(--signal); background: rgba(24, 211, 145, .045); }

main { min-width: 0; display: grid; gap: var(--space-6); }
.page-heading { max-width: 980px; padding: clamp(38px, 5vw, 68px) 0 var(--space-4); }
.surface-label { color: var(--signal); font: 750 9px/1 ui-monospace, monospace; letter-spacing: .1em; }
h1 { margin: 13px 0 12px; font-size: clamp(32px, 4vw, 56px); line-height: 1; letter-spacing: -.035em; }
.page-heading p { max-width: 72ch; margin: 0; color: #b8b9b6; font-size: 13px; line-height: 1.7; }

.scan-toolbar { min-width: 0; display: grid; grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.7fr) 264px 112px; border: 1px solid var(--grid); background: var(--panel); }
.source-state { min-width: 0; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); border-right: 1px solid var(--grid); }
.source-state i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.source-state.is-ready i { background: var(--signal); }
.source-state.is-error i { background: var(--sell); }
.source-state span { min-width: 0; display: grid; gap: 5px; }
.source-state b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.source-state small { color: var(--muted); font: 600 9px/1.3 ui-monospace, monospace; }
.search-control { min-width: 0; display: flex; align-items: center; padding: 0 var(--space-6); border-right: 1px solid var(--grid); }
.search-control input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; font: 750 18px/1.2 ui-monospace, monospace; }
.search-control input::placeholder { color: #77787c; }
.search-control kbd { color: var(--muted); background: transparent; font: 700 11px/1 ui-monospace, monospace; }
.range-control { display: grid; grid-template-columns: repeat(5, 1fr); }
.range-control button { position: relative; min-height: 66px; border: 0; border-right: 1px solid var(--grid); color: var(--muted); background: transparent; font: 700 10px/1 ui-monospace, monospace; }
.range-control button:hover, .range-control button.is-active { color: var(--signal); background: rgba(24, 211, 145, .09); }
.range-control button.is-loading { cursor: wait; }
.range-control button.is-loading::after { content: ""; position: absolute; top: 50%; left: calc(50% + 18px); width: 8px; height: 8px; margin-top: -5px; border: 1px solid rgba(24, 211, 145, .32); border-top-color: var(--signal); border-radius: 50%; animation: range-spin .72s linear infinite; }
.refresh-action { border: 0; color: var(--text); background: transparent; font: 750 11px/1 ui-monospace, monospace; }
.refresh-action:hover { color: var(--signal); background: var(--panel-hover); }
.refresh-action:disabled { opacity: .45; cursor: wait; }

.strategy-rail { min-width: 0; display: grid; grid-template-columns: repeat(4, minmax(150px, .72fr)) minmax(280px, 1.3fr); border: 1px solid var(--grid); background: var(--panel); }
.strategy-rail > label, .strategy-summary { min-width: 0; display: grid; gap: var(--space-2); padding: 14px var(--space-4); border-right: 1px solid var(--grid); }
.strategy-rail > :last-child { border-right: 0; }
.strategy-rail span { color: var(--muted); font: 650 9px/1 ui-monospace, monospace; }
.strategy-rail input, .strategy-rail select { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; font: 750 14px/1.2 ui-monospace, monospace; }
.strategy-rail small { color: #77787c; font-size: 10px; line-height: 1.4; }
.strategy-summary b { overflow: hidden; color: var(--signal); font: 750 12px/1.2 ui-monospace, monospace; text-overflow: ellipsis; white-space: nowrap; }

.market-panel { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--grid); background: var(--panel); }
.market-panel::before { content: ""; position: absolute; z-index: 3; top: -1px; left: 0; width: 34%; height: 2px; background: var(--signal); transform: scaleX(0); transform-origin: left; opacity: 0; pointer-events: none; }
.market-panel.is-loading::before { opacity: 1; animation: matrix-progress 1.15s cubic-bezier(.16, 1, .3, 1) infinite; }
.market-panel.is-loading .market-scroll, .market-panel.is-loading .market-footer { opacity: .46; transition: opacity 160ms ease-out; }
.market-scroll, .trade-scroll { width: 100%; min-width: 0; max-width: 100%; overflow-x: auto; outline: 0; }
.market-table { width: 100%; min-width: 1040px; border-collapse: collapse; table-layout: fixed; }
.market-table th, .market-table td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); }
.market-table th:last-child, .market-table td:last-child { border-right: 0; }
.market-table th { height: 108px; padding: 14px 12px; color: var(--text); background: #171718; text-align: center; font: 700 12px/1.2 ui-monospace, monospace; vertical-align: middle; }
.market-table th:nth-child(1) { width: 58px; }
.market-table th:nth-child(2) { width: 145px; }
.market-table th:nth-child(3) { width: 145px; }
.market-table th:nth-child(4) { width: 235px; }
.market-table th:nth-child(5) { width: 150px; }
.market-table th:nth-child(6) { width: 190px; }
.market-table th:nth-child(7) { width: 115px; }
.market-table th small { display: block; margin-top: 7px; color: #77787c; font-size: 9px; letter-spacing: .06em; }
.market-table th.is-active { background: rgba(24, 211, 145, .06); box-shadow: inset 0 -3px 0 var(--signal); }
.favorite-column { padding: 0 !important; }
.favorite-filter { width: 100%; height: 100%; border: 0; color: #77787c; background: transparent; font-size: 25px; }
.favorite-filter:hover, .favorite-filter.is-active { color: var(--amber); background: var(--panel-hover); }
.sort-button { padding: var(--space-2); border: 0; color: inherit; background: transparent; font: inherit; }
.sort-button i { color: var(--muted); font-style: normal; }
.sort-button:hover { color: var(--signal); }

.market-table tbody tr { height: 88px; transition: background 140ms ease-out; }
.market-table tbody tr[data-symbol] { cursor: pointer; }
.market-table tbody tr[data-symbol]:hover, .market-table tbody tr[data-symbol]:focus-within { background: var(--panel-hover); }
.market-table td { padding: 12px; color: var(--text); text-align: center; font: 650 12px/1.4 ui-monospace, monospace; }
.favorite-button { width: 40px; height: 40px; border: 0; color: #4b4c50; background: transparent; font-size: 25px; }
.favorite-button:hover, .favorite-button.is-active { color: var(--amber); }
.symbol-cell, .sample-cell, .return-cell, .edge-cell { display: grid; gap: 5px; }
.symbol-cell { text-align: left; }
.symbol-cell strong { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 17px; }
.symbol-cell small, .sample-cell small, .return-cell small, .edge-cell small { color: #77787c; font-size: 9px; line-height: 1.4; }
.sample-cell strong, .return-cell strong, .edge-cell strong { font-size: 16px; }
.sample-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sample-metrics span { display: grid; gap: 2px; }
.sample-metrics b { font-size: 15px; line-height: 1; }
.sample-metrics i { color: #77787c; font-size: 8px; font-style: normal; letter-spacing: .06em; }
.sample-metrics .is-reference b { color: var(--cyan); }
.coverage-tracks { width: 88px; display: grid; gap: 3px; margin: 3px auto 0; }
.coverage-track { display: block; height: 2px; overflow: hidden; background: var(--grid); }
.coverage-track b { display: block; height: 100%; background: var(--signal); }
.coverage-track.is-reference b { background: var(--cyan); }
.route-cell { display: flex; align-items: center; justify-content: center; gap: 9px; white-space: nowrap; }
.route-tag { padding: 5px 7px; border: 1px solid currentColor; border-radius: 5px; font-size: 9px; }
.route-tag.buy { color: var(--buy); }
.route-tag.sell { color: var(--sell); }
.route-cell > i { color: var(--muted); font-style: normal; }
.is-gain { color: var(--signal) !important; }
.is-loss, .fee { color: var(--sell) !important; }
.detail-button { min-width: 50px; min-height: 38px; display: inline-grid; place-items: center; border: 1px solid var(--grid); color: var(--text); background: transparent; font-size: 11px; font-weight: 700; }
.detail-button:hover { color: var(--signal); border-color: var(--signal); }
.loading-row td, .empty-market-row td { height: 130px; color: var(--muted); text-align: center; }
.loading-row span { display: inline-block; width: 8px; height: 8px; margin-right: var(--space-2); border-radius: 50%; background: var(--amber); }
.market-footer { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: 0 var(--space-4); color: var(--muted); font: 650 10px/1.4 ui-monospace, monospace; }


.method-note { display: grid; grid-template-columns: 120px minmax(0, 75ch); gap: 20px; padding: 18px 20px; border: 1px solid var(--grid); background: #171718; }
.method-note strong { color: var(--amber); font: 750 9px/1.4 ui-monospace, monospace; }
.method-note p { margin: 0; color: #b8b9b6; font-size: 11px; line-height: 1.6; }
.toast { position: fixed; right: var(--space-6); bottom: var(--space-6); max-width: 420px; padding: 14px 17px; border: 1px solid var(--grid); color: var(--text); background: var(--panel-hover); font-size: 12px; line-height: 1.5; box-shadow: 12px 16px 32px rgba(0, 0, 0, .42); transform: translateY(18px); opacity: 0; pointer-events: none; transition: transform .22s cubic-bezier(.16, 1, .3, 1), opacity .18s ease-out; }
.toast.show { transform: translateY(0); opacity: 1; }

@keyframes range-spin { to { transform: rotate(360deg); } }
@keyframes matrix-progress { 0% { transform: translateX(-105%) scaleX(.35); } 58% { transform: translateX(175%) scaleX(1); } 100% { transform: translateX(305%) scaleX(.45); } }

@media (prefers-reduced-motion: reduce) {
  .range-control button.is-loading::after, .market-panel.is-loading::before { animation: none; }
  .market-panel.is-loading::before { width: 100%; transform: none; }
}

@media (max-width: 1040px) {
  .topbar { gap: var(--space-3); }
  .brand-lockup { gap: var(--space-4); }
  .workspace-nav a { padding-inline: 10px; }
  .member-link { display: none; }
  .scan-toolbar { grid-template-columns: 1fr 1.5fr; }
  .source-state, .search-control { min-height: 66px; }
  .search-control { border-right: 0; }
  .range-control, .refresh-action { border-top: 1px solid var(--grid); }
  .strategy-rail { grid-template-columns: 1fr 1fr; }
  .strategy-rail > :nth-child(even) { border-right: 0; }
  .strategy-rail > :nth-child(-n+4) { border-bottom: 1px solid var(--grid); }
  .strategy-summary { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .matrix-shell { padding: 0 12px 30px; }
  .topbar { min-height: 0; align-items: stretch; flex-direction: column; gap: 14px; padding-top: 17px; }
  .brand-lockup { width: 100%; display: grid; gap: 14px; }
  .brand-name { padding-left: 2px; }
  .workspace-nav { width: calc(100% + 24px); height: 50px; margin: 0 -12px; padding: 0 4px; gap: 0; border-top: 1px solid var(--grid); }
  .workspace-nav a { padding-inline: 12px; font-size: 9px; }
  .workspace-nav a.is-active::after { right: 12px; left: 12px; }
  .member-link { display: none; }
  .page-heading { padding-top: 34px; }
  .scan-toolbar, .strategy-rail { grid-template-columns: 1fr; }
  .source-state, .search-control, .range-control, .strategy-rail > label, .strategy-summary { border-right: 0; border-bottom: 1px solid var(--grid); }
  .search-control { min-height: 66px; }
  .range-control { border-top: 0; }
  .strategy-rail > :nth-child(-n+3) { border-bottom: 1px solid var(--grid); }
  .strategy-summary { grid-column: auto; border-bottom: 0; }
  .market-table { min-width: 1000px; }
  .market-footer { align-items: flex-start; flex-direction: column; padding-block: var(--space-3); }
  .method-note { grid-template-columns: 1fr; gap: var(--space-2); }
}
