:root {
  --bg: #0b0e14;
  --surface: #131722;
  --surface-2: #1a2030;
  --border: #2a3348;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --binance: #f0b90b;
  --binance-dim: rgba(240, 185, 11, 0.12);
  --coinbase: #0052ff;
  --coinbase-dim: rgba(0, 82, 255, 0.12);
  --green: #0ecb81;
  --red: #f6465d;
  --amber: #f5a623;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Noto Sans SC', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100vw;
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  width: 100%;
  overflow-x: hidden;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lang-flags {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.lang-flag {
  padding: 3px 5px;
  border: 2px solid transparent;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  line-height: 0;
  transition: border-color 0.2s, background 0.2s, opacity 0.2s;
  opacity: 0.55;
}

.lang-flag:hover {
  opacity: 0.85;
  background: rgba(255, 255, 255, 0.05);
}

.lang-flag.active {
  opacity: 1;
  border-color: var(--amber);
  background: rgba(240, 185, 11, 0.08);
}

.lang-flag img {
  display: block;
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.header-right {
  text-align: right;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.author-credit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.author-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.author-name {
  color: var(--text);
  font-weight: 500;
}

.connection-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 4px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 1.5s infinite;
}

.connection-status.connected .status-dot {
  background: var(--green);
  animation: none;
}

.connection-status.partial .status-dot {
  background: var(--amber);
}

.connection-status.disconnected .status-dot {
  background: var(--red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.uptime {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

.coin-selector {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.coin-selector-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.coin-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.coin-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.coin-icon {
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
}

.coin-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px 1px 4px;
  border-radius: 999px;
}

.coin-tag .coin-icon {
  width: 14px;
  height: 14px;
}

.event-time-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.arb-spot-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
}

.arb-spot-label {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 4px;
}

.arb-spot-fees {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 0.78rem;
}

.arb-spot-net {
  font-family: var(--mono);
  font-weight: 600;
}

.arb-spot-net.positive { color: var(--green); }
.arb-spot-net.negative { color: var(--red); }

.arb-spot-verdict {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
}

.arb-spot-verdict.profit {
  background: rgba(14, 203, 129, 0.12);
  color: var(--green);
}

.arb-spot-verdict.loss {
  background: rgba(246, 70, 93, 0.12);
  color: var(--red);
}

.coin-pill:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.coin-pill.active {
  background: rgba(0, 82, 255, 0.12);
  border-color: #4d8bff;
  color: #4d8bff;
}

.arb-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.arb-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.arb-banner-title h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.arb-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.arb-verdict {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.arb-verdict.profit {
  background: rgba(14, 203, 129, 0.12);
  color: var(--green);
}

.arb-verdict.loss {
  background: rgba(246, 70, 93, 0.12);
  color: var(--red);
}

.arb-verdict.neutral {
  background: var(--surface-2);
  color: var(--text-muted);
}

.arb-flow {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 14px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.5;
}

.arb-flow .buy { color: var(--green); font-weight: 600; }
.arb-flow .sell { color: var(--red); font-weight: 600; }
.arb-flow .arrow { color: var(--text-muted); }

.arb-flow-stack {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.arb-flow-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}

.arb-flow-row strong {
  margin-left: auto;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--text);
}

.arb-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 900px) {
  .arb-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  .arb-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.arb-cell {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

.arb-cell.highlight {
  border: 1px solid rgba(14, 203, 129, 0.25);
  background: rgba(14, 203, 129, 0.06);
}

.arb-cell.highlight.loss {
  border-color: rgba(246, 70, 93, 0.25);
  background: rgba(246, 70, 93, 0.06);
}

.arb-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.arb-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 600;
}

.arb-value.fee {
  color: var(--amber);
}

.arb-value.positive { color: var(--green); }
.arb-value.negative { color: var(--red); }

.arb-fee-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.insight-banner {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.insight-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--amber);
}

.insight-banner strong {
  color: var(--text);
}

.price-grid {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 280px) 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: stretch;
}

.price-card {
  min-height: 340px;
  padding: 0;
  overflow: hidden;
  border-top-width: 3px;
  border-top-style: solid;
}

.price-card-layout {
  display: flex;
  align-items: stretch;
  min-height: 340px;
}

.price-card[data-slot="right"] .price-card-layout {
  flex-direction: row-reverse;
}

.price-card-body {
  flex: 1;
  min-width: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.exchange-switcher {
  flex-shrink: 0;
  width: 44px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 6px;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
}

.exchange-switcher-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.ex-switch-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
}

.ex-switch-btn .icon-wrap {
  width: 24px !important;
  height: 24px !important;
}

.ex-switch-btn .exchange-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 5px;
}

.ex-switch-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ex-switch-btn.active {
  border-color: var(--ex-color, #4d8bff);
  background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 900px) {
  .price-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .price-card,
  .price-card-layout,
  .spread-card {
    min-height: auto;
  }

  .price-card-layout,
  .price-card[data-slot="right"] .price-card-layout {
    flex-direction: column;
  }

  .exchange-switcher,
  .exchange-switcher-right {
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 8px 10px;
    -webkit-overflow-scrolling: touch;
  }
}

.price-card,
.spread-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.spread-card {
  padding: 20px;
}

.icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.icon-wrap .color-block {
  display: none;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--mono);
  line-height: 1;
  text-transform: uppercase;
  color: #fff;
}

.icon-wrap.fallback .color-block,
.ex-icon-wrap.fallback .ex-block {
  display: flex;
}

.icon-wrap.fallback .coin-icon,
.icon-wrap.fallback .exchange-icon {
  display: none;
}

.ex-icon-wrap.fallback img {
  display: none;
}

.ex-block {
  border-radius: 6px;
}

.coin-block {
  border-radius: 50%;
}

.price-card.leading {
  box-shadow: 0 0 0 1px var(--green), 0 0 24px rgba(14, 203, 129, 0.08);
}

.price-card.lagging {
  opacity: 0.85;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.exchange-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
}

.exchange-icon-sm {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  margin-right: 4px;
  border-radius: 4px;
  object-fit: cover;
}

.exchange-badge {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 4px;
}

.binance .exchange-badge {
  background: var(--binance-dim);
  color: var(--binance);
}

.coinbase .exchange-badge {
  background: var(--coinbase-dim);
  color: #4d8bff;
}

.symbol {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: var(--mono);
}

.lead-badge.hidden,
.inversion-badge.hidden,
.status-badge.hidden {
  display: none;
}

.status-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-badge.lead {
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
}

.status-badge.lag {
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
}

.lead-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(14, 203, 129, 0.15);
  color: var(--green);
}

.lead-badge.hidden,
.inversion-badge.hidden {
  display: none;
}

.price-value {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.price-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.change.up { color: var(--green); }
.change.down { color: var(--red); }

.latency {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.lag-seconds {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--amber);
  visibility: hidden;
  min-width: 80px;
  text-align: center;
}

.lag-seconds.visible {
  visibility: visible;
}

.lag-seconds-big {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--amber);
  min-height: 1.6em;
  line-height: 1.6;
  transition: color 0.3s ease, opacity 0.3s ease;
}

.lag-status.is-idle .lag-seconds-big {
  color: var(--text-muted);
  opacity: 0.45;
  font-size: 1.1rem;
}

.lag-status.is-idle .lag-text {
  color: var(--text-muted);
}

.sparkline {
  width: 100%;
  height: 48px;
  display: block;
}

.spread-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  background: var(--surface-2);
  min-height: 340px;
}

.inversion-slot {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  width: 100%;
}

.inversion-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(245, 166, 35, 0.15);
  color: var(--amber);
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.inversion-badge.visible {
  visibility: visible;
  opacity: 1;
}

.spread-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.spread-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
}

.spread-pct {
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.spread-direction {
  font-size: 0.85rem;
  margin-top: 10px;
  color: var(--text-muted);
}

.lag-status {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  width: 100%;
  min-height: 130px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.lag-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.lag-text {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  display: block;
  min-height: 2.6em;
  line-height: 1.3;
  transition: color 0.3s ease;
}

.confidence-bar {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

.confidence-fill {
  height: 100%;
  width: 0%;
  background: var(--green);
  border-radius: 2px;
  transition: width 0.8s ease, background 0.5s ease;
}

.confidence-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
}

.main-panels {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .main-panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-coin {
  font-weight: 500;
}

.panel-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--sans);
}

.btn-clear:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

#spreadChart {
  width: 100%;
  height: 200px;
  display: block;
}

.event-list {
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
}

.event-list::-webkit-scrollbar {
  width: 6px;
}

.event-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.event-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.event-item.ongoing {
  background: rgba(245, 166, 35, 0.04);
  margin: 0 -8px;
  padding: 10px 8px;
  border-radius: 6px;
}

.event-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.event-time {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.event-lag {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
}

.event-lag.ongoing {
  color: var(--amber);
  background: rgba(245, 166, 35, 0.12);
}

.event-lag.done {
  color: var(--green);
  background: rgba(14, 203, 129, 0.12);
}

.event-lag.timeout {
  color: var(--red);
  background: rgba(246, 70, 93, 0.12);
}

.event-desc {
  line-height: 1.5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.event-icon {
  border-radius: 3px;
  vertical-align: -3px;
  flex-shrink: 0;
}

.event-item:last-child {
  border-bottom: none;
}

.event-desc .lead {
  color: var(--green);
  font-weight: 600;
}

.event-desc .lag {
  color: var(--amber);
  font-weight: 600;
}

.event-desc .catch-up {
  color: var(--coinbase);
  font-weight: 600;
}

.event-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 20px 0;
  text-align: center;
}

.fee-panel {
  margin-bottom: 24px;
}

.fee-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .fee-grid {
    grid-template-columns: 1fr;
  }
}

.fee-exchange h3 {
  font-size: 0.95rem;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fee-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.fee-table th,
.fee-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.fee-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.75rem;
}

.fee-table td {
  font-family: var(--mono);
  font-size: 0.8rem;
}

.fee-table td:first-child {
  font-family: var(--sans);
}

.fee-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
}

.arb-calc {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 16px;
}

.arb-calc h3 {
  font-size: 0.9rem;
  margin-bottom: 12px;
}

.arb-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.arb-row:last-child {
  border-bottom: none;
}

.arb-row span:last-child {
  font-family: var(--mono);
  font-weight: 600;
}

.arb-row.highlight {
  color: var(--amber);
  font-weight: 500;
  padding-top: 10px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .app {
    padding: 14px 12px 32px;
  }

  .header {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }

  .header-left,
  .header-right {
    width: 100%;
  }

  .title-row {
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px;
  }

  .header h1 {
    font-size: 1.15rem;
    flex: 1;
    min-width: 0;
    line-height: 1.25;
  }

  .lang-flags {
    flex-shrink: 0;
  }

  .subtitle {
    font-size: 0.75rem;
    margin-top: 6px;
    line-height: 1.4;
  }

  .header-right {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px 12px;
    text-align: left;
  }

  .connection-status {
    margin-bottom: 0;
    justify-content: flex-start;
  }

  .status-text {
    font-size: 0.78rem;
  }

  .uptime {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .author-credit {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .coin-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 12px;
  }

  .coin-selector-label {
    font-size: 0.78rem;
  }

  .coin-pills {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 6px;
    max-width: 100%;
    scrollbar-width: none;
  }

  .coin-pills::-webkit-scrollbar {
    display: none;
  }

  .coin-pill {
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 0.72rem;
    gap: 4px;
  }

  .arb-banner {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .arb-banner-top {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
  }

  .arb-banner-title {
    flex: 1;
    min-width: 0;
  }

  .arb-banner-title h2 {
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .arb-hint {
    font-size: 0.68rem;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .arb-verdict {
    font-size: 0.68rem;
    padding: 3px 8px;
    flex-shrink: 0;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .arb-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
    font-size: 0.76rem;
    padding: 8px 10px;
    margin-bottom: 10px;
    white-space: normal;
    overflow: visible;
    max-width: 100%;
  }

  .arb-flow .buy,
  .arb-flow .sell {
    white-space: nowrap;
  }

  .arb-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .arb-cell {
    padding: 8px 10px;
  }

  .arb-cell.highlight {
    grid-column: span 2;
  }

  .arb-label {
    font-size: 0.68rem;
    margin-bottom: 2px;
  }

  .arb-value {
    font-size: 0.82rem;
  }

  .arb-fee-detail {
    font-size: 0.72rem;
    line-height: 1.4;
  }

  .arb-spot-row {
    gap: 6px 10px;
    font-size: 0.75rem;
  }

  .arb-spot-verdict {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }

  .insight-banner {
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    gap: 8px;
  }

  .price-card,
  .price-card-layout,
  .spread-card {
    min-height: 0 !important;
    height: auto;
  }

  .price-card-layout,
  .price-card[data-slot="right"] .price-card-layout {
    flex-direction: column !important;
    align-items: stretch;
  }

  .exchange-switcher,
  .exchange-switcher-right {
    width: 100% !important;
    max-width: 100% !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 6px 8px !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    gap: 4px;
  }

  .price-card-body {
    flex: none !important;
    width: 100% !important;
    padding: 10px 12px !important;
  }

  .card-header #leftExIcon,
  .card-header #rightExIcon {
    display: none;
  }

  .card-header {
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 6px;
    overflow: hidden;
  }

  .card-header .exchange-icon,
  .card-header .icon-wrap {
    flex-shrink: 0;
  }

  .exchange-badge {
    font-size: 0.72rem;
    padding: 2px 6px;
    flex-shrink: 0;
  }

  .symbol {
    font-size: 0.72rem;
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-badge {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .price-value {
    font-size: 1.45rem;
    margin-bottom: 4px;
  }

  .price-meta {
    flex-wrap: nowrap;
    gap: 6px;
    font-size: 0.72rem;
    margin-bottom: 8px;
  }

  .lag-seconds {
    min-width: auto;
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .latency {
    font-size: 0.68rem;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .sparkline {
    width: 100% !important;
    max-width: 100%;
    height: 36px;
    display: block;
  }

  .spread-value {
    font-size: 1.25rem;
  }

  .lag-text {
    min-height: auto;
    font-size: 0.78rem;
  }

  .ex-switch-btn {
    width: 28px;
    height: 28px;
  }

  .spread-card {
    padding: 12px 14px;
    min-height: 0 !important;
    align-items: stretch;
    text-align: left;
  }

  .spread-label,
  .spread-value,
  .spread-pct,
  .spread-direction {
    width: 100%;
    text-align: center;
  }

  .inversion-slot {
    min-height: auto;
    margin-top: 6px;
  }

  .lag-status {
    min-height: 0 !important;
    margin-top: 8px;
    padding-top: 8px;
  }

  .lag-seconds-big {
    font-size: 0.95rem;
    margin-top: 4px;
  }

  .arb-banner,
  .coin-selector,
  .price-grid,
  .stats-row,
  .main-panels,
  .fee-panel {
    max-width: 100%;
  }

  .arb-fee-detail,
  .arb-spot-row {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .fee-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  #spreadChart {
    max-width: 100%;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .stat-box {
    padding: 10px 12px;
  }

  .stat-box:last-child {
    grid-column: span 2;
  }

  .stat-label {
    font-size: 0.68rem;
  }

  .stat-value {
    font-size: 0.95rem;
  }

  .panel {
    padding: 14px;
  }

  .panel-header {
    flex-wrap: wrap;
    margin-bottom: 10px;
  }

  .panel-header h2 {
    font-size: 0.9rem;
  }

  .panel-hint {
    font-size: 0.68rem;
  }

  .fee-table {
    font-size: 0.78rem;
  }

  .fee-table th,
  .fee-table td {
    padding: 6px 8px;
  }
}
