/* ════════════════════════════════════════════════════════════════════
   Live Arb (#tab-livearb) — LIVE cross-exchange funding arb screener.
   Loris-style dense grid: one column per venue, BUY (lowest rate) cells
   tinted green, SELL (highest) tinted red, Max Arb in green. Every colour
   is a theme token so dark + light both read; the table panel is the
   solid --card surface so sticky header / first columns can paint over
   scrolled rows. Classes are prefixed `lar-` (JS: pages/live-arb.js).
   ════════════════════════════════════════════════════════════════════ */

#tab-livearb {
  --lar-row: var(--card);
  --lar-row-alt: color-mix(in srgb, var(--foreground) 2.2%, var(--card));
  --lar-row-hover: color-mix(in srgb, var(--foreground) 5.5%, var(--card));
  --lar-gold: #d4a017;
}

.lar-card {
  padding: 14px 16px 12px;
  margin-bottom: 16px;
}

/* ── Toolbar ──────────────────────────────────────────────────────── */
.lar-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.lar-search {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  width: 210px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--muted-foreground);
  cursor: text;
  transition: border-color .15s ease;
}
.lar-search:focus-within { border-color: var(--ring); color: var(--foreground); }
.lar-search svg { width: 14px; height: 14px; flex: none; }
.lar-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 12px;
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.lar-search input::placeholder { text-transform: none; color: var(--muted-foreground); }
.lar-kbd {
  font: 500 10px/1 var(--font-mono);
  padding: 2px 5px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--muted-foreground);
}
.lar-search:focus-within .lar-kbd { display: none; }

/* Venue chips — logo + name pill, checkbox hidden but focusable. */
.lar-venues { display: flex; flex-wrap: wrap; gap: 6px; }
.lar-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 10px 0 4px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-elevated);
  font-size: 11.5px;
  cursor: pointer;
  user-select: none;
  transition: background-color .1s ease, border-color .1s ease, opacity .1s ease;
}
.lar-chip input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
}
.lar-chip .tdd-cex-badge { gap: 6px; font-weight: 500; }
.lar-chip .tdd-cex-logo-wrap { width: 22px; height: 22px; border-radius: 999px; }
.lar-chip:hover { background: color-mix(in srgb, var(--vc, var(--foreground)) 8%, var(--surface-elevated)); }
.lar-chip:has(input:checked) {
  border-color: color-mix(in srgb, var(--vc, var(--foreground)) 55%, transparent);
  background: color-mix(in srgb, var(--vc, var(--foreground)) 6%, var(--surface-elevated));
}
.lar-chip:has(input:not(:checked)) { opacity: .45; border-style: dashed; }
.lar-chip:has(input:not(:checked)):hover { opacity: .75; }
.lar-chip:has(input:focus-visible) { box-shadow: 0 0 0 2px color-mix(in srgb, var(--vc, var(--foreground)) 35%, transparent); }

.lar-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.lar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-elevated);
  color: var(--foreground);
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.lar-btn:hover { background: var(--hover-tint); border-color: var(--ring); }
.lar-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.lar-btn svg { width: 15px; height: 15px; flex: none; }
.lar-btn--icon { width: 30px; padding: 0; }
.lar-btn--ghost { background: transparent; }
.lar-btn[aria-expanded="true"] { border-color: var(--ring); background: var(--hover-tint); }

.lar-unit-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface-tinted);
  color: var(--muted-foreground);
}

#lar-pause .lar-ico-play { display: none; }
#lar-pause[aria-pressed="true"] .lar-ico-play { display: block; }
#lar-pause[aria-pressed="true"] .lar-ico-pause { display: none; }
#lar-pause[aria-pressed="true"] { color: var(--status-dev); border-color: color-mix(in srgb, var(--status-dev) 50%, transparent); }
#lar-refresh.is-spinning svg { animation: lar-spin .9s linear infinite; }
@keyframes lar-spin { to { transform: rotate(360deg); } }

/* ── Settings popover ─────────────────────────────────────────────── */
.lar-settings-anchor { position: relative; }
.lar-settings {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  width: 350px;
  max-height: min(640px, calc(100vh - 120px));
  overflow-y: auto;
  padding: 6px 14px 12px;
  background: var(--popover);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
:root[data-theme="light"] .lar-settings { box-shadow: 0 14px 40px rgba(0, 0, 0, .12); }
.lar-set-section { padding: 8px 0; border-bottom: 1px solid var(--border); }
.lar-set-section:last-of-type { border-bottom: 0; }
.lar-set-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted-foreground);
  margin-bottom: 4px;
}
.lar-set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  font-size: 12px;
}
.lar-set-label { color: var(--foreground); }
.lar-set-check { cursor: pointer; }
.lar-set-check input,
.lar-set-colopts input { accent-color: var(--profit); }
.lar-set-cols { align-items: flex-start; padding: 4px 0; }
.lar-set-colopts { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lar-set-colopts label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted-foreground); }
.lar-set-colopts label:has(input:checked) { color: var(--foreground); }
.lar-set-input {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted-foreground);
}
.lar-set-input input {
  width: 64px;
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--foreground);
  font-size: 12px;
  font-family: var(--font-mono);
  text-align: right;
}
.lar-set-input input:focus { outline: none; border-color: var(--ring); }
.lar-set-range { display: inline-flex; align-items: center; gap: 6px; }
.lar-set-foot { padding-top: 10px; display: flex; justify-content: flex-end; }

.lar-select {
  height: 26px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--foreground);
  font-size: 12px;
  font-family: var(--font-mono);
}
.lar-select:focus { outline: none; border-color: var(--ring); }

/* Segmented control (unit / format / interval / timeframe). */
.lar-seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}
.lar-seg button {
  min-width: 38px;
  height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  border-left: 1px solid var(--border-strong);
  transition: background .12s ease, color .12s ease;
}
.lar-seg button:first-child { border-left: 0; }
.lar-seg button:hover:not(:disabled) { color: var(--foreground); background: var(--hover-tint); }
.lar-seg button.active { background: var(--foreground); color: var(--background); font-weight: 600; }
.lar-seg button:disabled { opacity: .35; cursor: not-allowed; }
.lar-seg--sm button { height: 24px; min-width: 34px; font-size: 11px; }

/* ── Status line ──────────────────────────────────────────────────── */
.lar-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin: 10px 0 8px;
  font-size: 11.5px;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.lar-status-sep { opacity: .5; }
.lar-online { display: inline-flex; align-items: center; gap: 6px; color: var(--foreground); }
.lar-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted-foreground);
}
.lar-online[data-state="ok"] .lar-dot { background: var(--profit); }
.lar-online[data-state="ok"] .lar-dot::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--profit);
  opacity: 0;
  animation: lar-ping 2.4s ease-out infinite;
}
.lar-online[data-state="warn"] .lar-dot { background: var(--status-dev); }
.lar-online[data-state="err"] .lar-dot { background: var(--loss); }
.lar-online[data-state="err"] { color: var(--loss); }
@keyframes lar-ping { 0% { transform: scale(.6); opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }

.lar-health { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; margin-left: 6px; }
.lar-h {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  letter-spacing: .03em;
  cursor: default;
}
.lar-h i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.lar-h[data-state="ok"] i { background: var(--profit); }
.lar-h[data-state="stale"] i { background: var(--status-dev); }
.lar-h[data-state="err"] i { background: var(--loss); }
.lar-h[data-state="err"] { color: var(--loss); }
.lar-h.is-unselected { opacity: .4; }
.lar-status-right { display: inline-flex; gap: 12px; margin-left: auto; }

/* ── Table ────────────────────────────────────────────────────────── */
.lar-table-wrap {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 250px);
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--lar-row);
  overscroll-behavior: contain;
}
.lar-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.lar-table th,
.lar-table td {
  padding: 6px 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.lar-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--lar-row);
  border-bottom: 1px solid var(--border-strong);
  color: var(--muted-foreground);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: center;
  vertical-align: middle;
  height: 38px;
}
.lar-th-sort { cursor: pointer; user-select: none; }
.lar-th-sort:hover { color: var(--foreground); }
.lar-th-in { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.lar-th-sort .lar-th-in::after {
  content: '';
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  opacity: 0;
}
.lar-th-sort.is-sort-desc .lar-th-in::after { border-top: 4px solid currentColor; opacity: .9; }
.lar-th-sort.is-sort-asc .lar-th-in::after { border-bottom: 4px solid currentColor; opacity: .9; }
.lar-th-sort.is-sort-desc,
.lar-th-sort.is-sort-asc { color: var(--foreground); }
.lar-th-unit { font-weight: 500; opacity: .6; text-transform: none; letter-spacing: 0; }
.lar-table thead .tdd-cex-badge { gap: 6px; font-weight: 600; }
.lar-table thead .tdd-cex-logo-wrap { width: 18px; height: 18px; border-radius: 5px; }
.lar-table thead .tdd-cex-name { font-size: 10.5px; text-transform: uppercase; }

/* Row background flows through --rb so the BUY/SELL tints and the
   heatmap mix over the zebra / hover / open state instead of fighting it
   on specificity. Sticky cells paint the same --rb (they must be opaque). */
.lar-table tbody tr { --rb: var(--lar-row); }
.lar-table tbody tr:nth-child(even) { --rb: var(--lar-row-alt); }
.lar-table tbody tr.lar-row:hover,
.lar-table tbody tr.lar-row:focus-visible,
.lar-table tbody tr.lar-row.is-open { --rb: var(--lar-row-hover); }
.lar-table tbody td { background: var(--rb); }
.lar-row { cursor: pointer; }
.lar-row:focus-visible { outline: none; }
.lar-table tbody tr.lar-row:focus-visible .lar-c-sym,
.lar-table tbody tr.lar-row.is-open .lar-c-sym { box-shadow: inset 3px 0 0 var(--foreground), inset -1px 0 0 var(--border); }

/* Sticky star + symbol columns. */
.lar-table .lar-c-star {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 34px;
  min-width: 34px;
  padding: 0;
  text-align: center;
}
.lar-table .lar-c-sym {
  position: sticky;
  left: 34px;
  z-index: 2;
  min-width: 120px;
  text-align: left;
  box-shadow: inset -1px 0 0 var(--border);
}
.lar-table thead .lar-c-star,
.lar-table thead .lar-c-sym { z-index: 4; }
.lar-table thead .lar-c-sym { text-align: left; }
.lar-table thead .lar-c-sym .lar-th-in { justify-content: flex-start; }
.lar-star-h { color: var(--muted-foreground); font-size: 12px; }

.lar-star {
  width: 100%;
  height: 100%;
  min-height: 28px;
  font-size: 14px;
  line-height: 1;
  color: var(--border-strong);
  transition: color .12s ease, transform .12s ease;
}
.lar-star:hover { color: var(--muted-foreground); transform: scale(1.12); }
.lar-star.on { color: var(--lar-gold); }

.lar-sym { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; color: var(--foreground); }
.lar-sym .ticker-icon { width: 16px; height: 16px; margin-right: 7px; }
.lar-sym-txt { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.lar-sym-suffix { color: var(--muted-foreground); font-weight: 500; font-size: 11px; }
.lar-cls {
  margin-left: 6px;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.lar-tradfi-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--surface-tinted);
  color: var(--muted-foreground);
  font-size: 8px;
}
.lar-tradfi-ico--lg { width: 24px; height: 24px; font-size: 11px; }
.lar-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--status-dev) 18%, transparent);
  color: var(--status-dev);
  font-size: 10px;
  font-weight: 700;
  cursor: help;
}

.lar-c-num { text-align: right; }
.lar-table thead th.lar-c-num { text-align: right; }
.lar-table thead .lar-c-num .lar-th-in { justify-content: flex-end; }
.lar-c-rank { color: var(--muted-foreground); }
.lar-c-max { color: var(--profit); }
.lar-c-max.is-strong { font-weight: 700; }
.lar-c-next { color: var(--muted-foreground); }
.lar-muted { color: var(--muted-foreground); }
.lar-dash { color: var(--muted-foreground); opacity: .55; text-align: center; }
.lar-c-num.lar-dash { text-align: right; }
.lar-table td.pos { color: var(--profit); }
.lar-table td.neg { color: var(--loss); }

/* Venue cells — Loris: positive ≥ 3 bps/8h reads red, ≤ −3 reads green. */
.lar-c-v { min-width: 104px; text-align: center; }
.lar-cell-in { display: inline-flex; align-items: center; gap: 6px; }
.lar-c-v.lar-rate-hi { color: var(--loss); }
.lar-c-v.lar-rate-lo { color: var(--profit); }
.lar-table tbody td.lar-buy {
  background: color-mix(in srgb, var(--profit) 18%, var(--rb));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--profit) 40%, transparent);
}
.lar-table tbody td.lar-sell {
  background: color-mix(in srgb, var(--loss) 18%, var(--rb));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--loss) 40%, transparent);
}
/* max == min (every rate identical) — Loris badges both; keep it neutral. */
.lar-table tbody td.lar-buy.lar-sell { background: color-mix(in srgb, var(--foreground) 6%, var(--rb)); box-shadow: none; }
/* Heatmap (toggle): magnitude tint on the non-badge cells. */
.lar-hm tbody td.lar-hp { background: color-mix(in srgb, var(--loss) var(--h, 0%), var(--rb)); }
.lar-hm tbody td.lar-hn { background: color-mix(in srgb, var(--profit) var(--h, 0%), var(--rb)); }

.lar-badge {
  display: inline-block;
  padding: 2px 4px 1.5px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .03em;
  font-family: var(--font-mono);
}
.lar-badge--buy { background: var(--profit); color: #06120a; }
.lar-badge--sell { background: var(--loss); color: #fff; }

.lar-table tbody tr.lar-skel-row td { cursor: default; }

.lar-empty { padding: 48px 16px; text-align: center; }
.lar-empty-title { font-size: 13px; font-weight: 600; color: var(--foreground); }
.lar-empty-sub { margin-top: 6px; font-size: 12px; color: var(--muted-foreground); }

.lar-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
}
.lar-source { font-size: 11px; color: var(--muted-foreground); line-height: 1.5; }

/* Skeleton shimmer. */
.lar-skel {
  display: inline-block;
  height: 10px;
  max-width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--surface-tinted) 0%, color-mix(in srgb, var(--foreground) 9%, transparent) 50%, var(--surface-tinted) 100%);
  background-size: 200% 100%;
  animation: lar-shimmer 1.3s ease-in-out infinite;
  vertical-align: middle;
}
@keyframes lar-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Hover tooltip (single floating element) ─────────────────────── */
.lar-tip {
  position: fixed;
  z-index: 95;
  min-width: 230px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 10px 12px;
  background: var(--popover);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .45);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--foreground);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
:root[data-theme="light"] .lar-tip { box-shadow: 0 12px 32px rgba(0, 0, 0, .14); }
.lar-tip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.lar-tip-head .tdd-cex-logo-wrap { width: 20px; height: 20px; }
.lar-tip-sym { font-weight: 600; color: var(--muted-foreground); font-size: 11px; }
.lar-tip-row { display: flex; justify-content: space-between; gap: 18px; line-height: 1.6; }
.lar-tip-row > span:first-child { color: var(--muted-foreground); }
.lar-tip-row .pos { color: var(--profit); }
.lar-tip-row .neg { color: var(--loss); }
.lar-tip-sep {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted-foreground);
}
.lar-tip-route { margin-top: 3px; font-weight: 600; font-size: 11.5px; line-height: 1.7; }
.lar-tip-note { margin-top: 6px; font-size: 10.5px; color: var(--muted-foreground); }

/* ── Detail drawer ────────────────────────────────────────────────── */
.lar-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  width: min(980px, 96vw);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-left: 1px solid var(--border-strong);
  box-shadow: -18px 0 48px rgba(0, 0, 0, .4);
  animation: lar-drawer-in .22s cubic-bezier(.22, 1, .36, 1);
}
:root[data-theme="light"] .lar-drawer { box-shadow: -18px 0 48px rgba(0, 0, 0, .12); }
@keyframes lar-drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.lar-drawer-head {
  flex: none;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.lar-dh-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lar-dh-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.lar-dh-dd { font-size: 12px; padding: 4px 10px; white-space: nowrap; }
.lar-dh-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.lar-dh-title .ticker-icon { width: 24px; height: 24px; margin-right: 8px; }
.lar-dh-title .lar-tradfi-ico { margin-right: 8px; }
.lar-dh-sym { font-size: 18px; font-weight: 700; letter-spacing: .01em; }
.lar-dh-kicker {
  margin-left: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted-foreground);
}
.lar-drawer-close {
  flex: none;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted-foreground);
  font-size: 16px;
  line-height: 1;
}
.lar-drawer-close:hover { color: var(--foreground); border-color: var(--ring); }

.lar-dh-route {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.lar-route {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-elevated);
}
.lar-route--long { border-color: color-mix(in srgb, var(--profit) 45%, var(--border-strong)); }
.lar-route--short { border-color: color-mix(in srgb, var(--loss) 45%, var(--border-strong)); }
.lar-route-side { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.lar-route--long .lar-route-side { color: var(--profit); }
.lar-route--short .lar-route-side { color: var(--loss); }
.lar-route-logo { display: inline-flex; }
.lar-route-logo .tdd-cex-logo-wrap { width: 20px; height: 20px; border-radius: 5px; }
.lar-route .lar-select { border-color: transparent; background: transparent; max-width: 200px; }
.lar-route .lar-select:hover { border-color: var(--border-strong); }
.lar-dh-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-foreground);
}
.lar-link {
  font-size: 11px;
  color: var(--foreground);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--foreground) 30%, transparent);
  text-underline-offset: 2px;
}
.lar-link:hover { text-decoration-color: currentColor; }

.lar-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 32px;
  overscroll-behavior: contain;
}
.lar-d-sec { margin-bottom: 22px; }
.lar-d-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 8px;
}
.lar-d-head h4 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--foreground);
}
.lar-d-hint { font-size: 11px; color: var(--muted-foreground); }
.lar-d-note { margin-top: 6px; font-size: 11px; }
.lar-d-error {
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--loss) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--loss) 6%, transparent);
  color: var(--foreground);
  font-size: 12px;
}

/* KPI tiles. */
.lar-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lar-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 11px 13px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-elevated);
}
.lar-kpi .lar-skel { display: block; }
.lar-kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted-foreground);
}
.lar-kpi-value {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.lar-kpi-value .pos { color: var(--profit); }
.lar-kpi-value .neg { color: var(--loss); }
.lar-kpi--hero { border-color: color-mix(in srgb, var(--profit) 28%, var(--border)); }
.lar-kpi--hero .lar-kpi-value { font-size: 24px; }
.lar-kpi-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}
.lar-kpi-sub:empty { display: none; }
.lar-kpi-sub b { font-weight: 600; }
.lar-kpi-sub .pos { color: var(--profit); }
.lar-kpi-sub .neg { color: var(--loss); }
.lar-kpi--legs .lar-kpi-value { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; }
.lar-kpi-leg { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.lar-kpi-leg .tdd-cex-logo-wrap { width: 18px; height: 18px; border-radius: 5px; }
.lar-kpi-leg .pos { color: var(--profit); }
.lar-kpi-leg .neg { color: var(--loss); }
.lar-kpi-side {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
}
.lar-kpi-side--long { background: color-mix(in srgb, var(--profit) 18%, transparent); color: var(--profit); }
.lar-kpi-side--short { background: color-mix(in srgb, var(--loss) 18%, transparent); color: var(--loss); }
.lar-kpi-cd { font-size: 14px; font-weight: 600; min-width: 52px; }

.lar-d-warnings {
  margin: 10px 0 0;
  padding: 8px 12px 8px 26px;
  border: 1px solid color-mix(in srgb, var(--status-dev) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--status-dev) 6%, transparent);
  font-size: 11.5px;
  color: var(--foreground);
}
.lar-d-warnings li + li { margin-top: 2px; }

/* Drawer tables (windows + venue comparison). */
.lar-d-tablewrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.lar-d-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.lar-d-table th,
.lar-d-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.lar-d-table tbody tr:last-child th,
.lar-d-table tbody tr:last-child td { border-bottom: 0; }
.lar-d-table thead th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted-foreground);
  background: var(--surface-elevated);
}
.lar-d-table tbody th { font-weight: 600; }
.lar-d-table .num { text-align: right; }
.lar-d-table .pos { color: var(--profit); }
.lar-d-table .neg { color: var(--loss); }
.lar-d-table tbody tr:hover td,
.lar-d-table tbody tr:hover th { background: var(--hover-tint); }
.lar-partial {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
  background: color-mix(in srgb, var(--status-dev) 14%, transparent);
  color: var(--status-dev);
  cursor: help;
}

.lar-v-table .tdd-cex-badge { gap: 7px; font-weight: 600; }
.lar-v-table .tdd-cex-logo-wrap { width: 20px; height: 20px; border-radius: 5px; }
.lar-v-table tr.is-long th { box-shadow: inset 3px 0 0 var(--profit); }
.lar-v-table tr.is-short th { box-shadow: inset 3px 0 0 var(--loss); }
.lar-v-table th,
.lar-v-table td { padding: 6px 8px; }
.lar-v-contract { margin-top: 2px; color: var(--muted-foreground); font-size: 10.5px; font-weight: 400; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.lar-v-err { margin-top: 2px; font-size: 10px; font-weight: 500; color: var(--loss); }
.lar-v-pick { text-align: right; }
.lar-pick-wrap { display: inline-flex; gap: 4px; }
.lar-pick {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 64px;
  min-height: 22px;
  padding: 3px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 10.5px;
  font-family: var(--font-mono);
  line-height: 1.15;
  color: var(--muted-foreground);
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.lar-pick-px { font-size: 9.5px; font-weight: 500; color: var(--muted-foreground); }
.lar-pick:hover { color: var(--foreground); border-color: var(--ring); }
.lar-pick--long.active { color: var(--profit); border-color: color-mix(in srgb, var(--profit) 55%, transparent); background: color-mix(in srgb, var(--profit) 12%, transparent); font-weight: 600; }
.lar-pick--short.active { color: var(--loss); border-color: color-mix(in srgb, var(--loss) 55%, transparent); background: color-mix(in srgb, var(--loss) 12%, transparent); font-weight: 600; }
.lar-vbest-long { background: color-mix(in srgb, var(--profit) 11%, transparent); }
.lar-vbest-short { background: color-mix(in srgb, var(--loss) 11%, transparent); }
.lar-legend-chip { padding: 0 4px; border-radius: 3px; color: var(--foreground); }
.lar-d-table sup { font-size: 8px; color: var(--status-dev); margin-left: 1px; }

/* Price-spread verdict: favourable = the route pays if the gap drifts back
   to 0%, unfavourable = it costs. Defined after .lar-pick-px so it wins. */
.lar-pxc--fav { color: var(--profit); }
.lar-pxc--unfav { color: var(--loss); }
.lar-pxc--flat { color: var(--muted-foreground); }
.lar-kpi--px-fav { border-color: color-mix(in srgb, var(--profit) 28%, var(--border)); }
.lar-kpi--px-unfav { border-color: color-mix(in srgb, var(--loss) 28%, var(--border)); }
.lar-pxv-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--foreground);
}
.lar-pxv-banner--fav { border-color: color-mix(in srgb, var(--profit) 40%, var(--border)); background: color-mix(in srgb, var(--profit) 6%, transparent); }
.lar-pxv-banner--unfav { border-color: color-mix(in srgb, var(--loss) 40%, var(--border)); background: color-mix(in srgb, var(--loss) 6%, transparent); }
.lar-pxv {
  flex: none;
  margin-top: 1px;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.lar-pxv--fav { background: color-mix(in srgb, var(--profit) 16%, transparent); color: var(--profit); }
.lar-pxv--unfav { background: color-mix(in srgb, var(--loss) 16%, transparent); color: var(--loss); }
.lar-pxv--flat { background: var(--surface-tinted); color: var(--muted-foreground); }
.lar-pxv-body { min-width: 0; }
.lar-pxv-line b { font-weight: 600; }
.lar-pxv-line .lar-muted { margin-left: 8px; font-family: var(--font-mono); font-size: 10.5px; }

/* Charts. */
.lar-chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.lar-chart {
  margin: 0;
  min-width: 0;
  padding: 10px 10px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-elevated);
}
.lar-chart figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 3px 8px;
  margin: 0 2px 6px;
}
.lar-chart-title { font-size: 12px; font-weight: 600; }
.lar-chart-sub { font-size: 10.5px; color: var(--muted-foreground); text-align: right; }
.lar-chart-note { flex-basis: 100%; font-size: 10.5px; color: var(--muted-foreground); }
.lar-chart-note:empty { display: none; }
.lar-chart-note b { font-weight: 600; }
.lar-chart-box { position: relative; height: 230px; }
.lar-chart-skel {
  position: absolute;
  inset: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-tinted) 0%, color-mix(in srgb, var(--foreground) 7%, transparent) 50%, var(--surface-tinted) 100%);
  background-size: 200% 100%;
  animation: lar-shimmer 1.3s ease-in-out infinite;
}
.lar-chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .lar-chart-grid { grid-template-columns: minmax(0, 1fr); }
  .lar-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .lar-card { padding: 12px 10px 10px; }
  .lar-search { width: 100%; order: -1; }
  .lar-toolbar-actions { margin-left: 0; }
  .lar-venues { width: 100%; }
  .lar-settings {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: calc(100vh - 88px);
  }
  .lar-status-right { margin-left: 0; width: 100%; }
  .lar-table-wrap { max-height: calc(100vh - 230px); }
  .lar-table { font-size: 12px; }
  .lar-table th, .lar-table td { padding: 6px 8px; }
  .lar-c-v { min-width: 92px; }
  .lar-table .lar-c-sym { min-width: 96px; }
  .lar-sym-txt { max-width: 96px; }
  .lar-cls { display: none; }
  .lar-drawer { width: 100vw; border-left: 0; }
  .lar-drawer-head { padding: 12px 14px 10px; }
  .lar-drawer-body { padding: 12px 14px 28px; }
  .lar-dh-meta { width: 100%; margin-left: 0; }
  .lar-route .lar-select { max-width: 130px; }
  .lar-chart-box { height: 210px; }
}
@media (max-width: 480px) {
  /* Phone width: each route picker gets its own row (long + swap, then
     short) so the live rate in the option label isn't clipped, and the
     next-funding tile spans both KPI columns — its two nowrap leg lines
     (logo · countdown · interval · raw rate) overflow a half-width tile.
     The entry tile (tile 3, long book line) spans too, so the 2-column
     grid stays hole-free: APR | mark · entry · legs · OI | volume. */
  .lar-route { flex: 1 1 calc(100% - 46px); min-width: 0; }
  .lar-route .lar-select { flex: 1; min-width: 0; max-width: none; }
  .lar-kpi--legs,
  .lar-kpi--entry { grid-column: 1 / -1; }
  .lar-kpi { padding: 9px 10px; }
  .lar-kpi-value { font-size: 16px; }
  .lar-kpi--hero .lar-kpi-value { font-size: 19px; }
  .lar-kpi-cd { font-size: 12px; min-width: 44px; }
  .lar-kpi-leg { gap: 6px; font-size: 11px; }
  .lar-chip { padding-right: 8px; }
  .lar-chip .tdd-cex-name { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .lar-skel,
  .lar-chart-skel,
  #lar-refresh.is-spinning svg,
  .lar-online[data-state="ok"] .lar-dot::after { animation: none; }
  .lar-drawer { animation: none; }
}
