/* Investing-style components: ticker, stat-card-with-trend, dense-table.
   Loaded globally via base.html. RTL-aware. */

:root {
  --erra-up: #16a34a;
  --erra-up-bg: rgba(22, 163, 74, 0.10);
  --erra-down: #dc2626;
  --erra-down-bg: rgba(220, 38, 38, 0.10);
  --erra-flat: #64748b;
  --erra-trust: #2563eb;
  --erra-trust-bg: rgba(37, 99, 235, 0.10);
  --erra-card-border: #e2e8f0;
  --erra-card-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

/* ─── Ticker tape ────────────────────────────────────────────── */

.market-ticker {
  position: relative;
  width: 100%;
  height: 36px;
  overflow: hidden;
  background: #0f172a;
  color: #f8fafc;
  border-bottom: 1px solid #1e293b;
  font-size: 12px;
  line-height: 1;
  z-index: 30;
}

.market-ticker-track {
  display: inline-flex;
  align-items: center;
  height: 100%;
  animation: market-ticker-marquee 90s linear infinite;
  white-space: nowrap;
  will-change: transform;
}

.market-ticker:hover .market-ticker-track {
  animation-play-state: paused;
}

.market-ticker-row {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding-inline-start: 0;
}

.market-ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 100%;
  color: #f1f5f9;
  text-decoration: none;
  border-inline-end: 1px solid #1e293b;
  transition: background-color 0.15s ease;
}

.market-ticker-item:hover {
  background: #1e293b;
  color: #ffffff;
}

.market-ticker-name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.market-ticker-price {
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.market-ticker-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.market-ticker-item[data-trend="up"] .market-ticker-delta { color: #4ade80; }
.market-ticker-item[data-trend="down"] .market-ticker-delta { color: #f87171; }
.market-ticker-item[data-trend="flat"] .market-ticker-delta { color: #cbd5e1; }

.market-ticker-spark {
  height: 16px;
  width: 48px;
  opacity: 0.85;
}

@keyframes market-ticker-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

html[dir="rtl"] .market-ticker-track {
  animation-name: market-ticker-marquee-rtl;
}

@keyframes market-ticker-marquee-rtl {
  from { transform: translateX(0); }
  to   { transform: translateX(50%); }
}

@media (max-width: 768px) {
  .market-ticker { height: 32px; font-size: 11px; }
  .market-ticker-item { padding: 0 10px; gap: 4px; }
  .market-ticker-spark { display: none; }
}

/* ─── Stat card with trend ───────────────────────────────────── */

.stat-card-trend {
  background: #ffffff;
  border: 1px solid var(--erra-card-border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-trend:has(.stat-card-trend-spark) { min-height: 110px; }

.stat-card-trend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-card-trend-label {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stat-card-trend-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 7px;
  border-radius: 6px;
}

.stat-card-trend-delta.is-up   { color: var(--erra-up); background: var(--erra-up-bg); }
.stat-card-trend-delta.is-down { color: var(--erra-down); background: var(--erra-down-bg); }

.stat-card-trend-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stat-card-trend-meta {
  font-size: 11px;
  color: #94a3b8;
}

.stat-card-trend-spark {
  width: 100%;
  height: 40px;
  margin-top: 4px;
}

/* ─── Dense table ────────────────────────────────────────────── */

.dense-table-wrap {
  background: #ffffff;
  border: 1px solid var(--erra-card-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--erra-card-shadow);
}

.dense-table-caption {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  border-bottom: 1px solid var(--erra-card-border);
  background: #f8fafc;
}

.dense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.dense-th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--erra-card-border);
  white-space: nowrap;
}

.dense-th.is-sortable { cursor: pointer; user-select: none; }
.dense-th.is-sortable:hover { color: var(--erra-trust); }

.dense-td {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.dense-tr:hover .dense-td { background: #f8fafc; }
.dense-tr:last-child .dense-td { border-bottom: none; }

.dense-table-wrap.is-compact .dense-td,
.dense-table-wrap.is-compact .dense-th { padding: 6px 10px; font-size: 12px; }

.align-start  { text-align: start; }
.align-end    { text-align: end; }
.align-center { text-align: center; }

.dense-cell-stack { display: inline-flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.dense-cell-value { font-weight: 600; }
.dense-cell-delta { font-size: 11px; font-weight: 600; }
.dense-cell-delta.is-up   { color: var(--erra-up); }
.dense-cell-delta.is-down { color: var(--erra-down); }

.dense-cell-empty { color: #cbd5e1; }
.dense-empty { padding: 20px; text-align: center; color: #94a3b8; }

.dense-table-spark { width: 80px; height: 22px; vertical-align: middle; }

@media (max-width: 768px) {
  .dense-th, .dense-td { padding: 6px 8px; font-size: 12px; }
  .dense-table-spark { width: 60px; height: 18px; }
}

/* ─── Home page (investing-style, restrained SaaS) ─────────────
   Principles:
   - Data > chrome. One outline per block, no doubled card-in-card.
   - One accent (trust-blue). Up/down only in delta values.
   - No decorative iconography, no gradients outside hero.
   - Logical properties (RTL-safe). No mixing left/right + inset-inline-*.
*/

.home-page {
  background: #fafbfc;
  margin: 0 -24px;
  padding: 0 24px 32px;
  min-height: calc(100vh - 200px);
}
@media (min-width: 1480px) {
  .home-page { padding-left: 48px; padding-right: 48px; }
}
@media (max-width: 768px) {
  .home-page { margin: 0 -16px; padding: 0 16px 24px; }
}

.home-wide {
  max-width: 1720px;
  margin: 16px auto 0;
  padding-inline: 24px;
}

.home-grid {
  max-width: 1720px;
  margin: 14px auto 0;
  padding-inline: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
@media (max-width: 768px) {
  .home-grid { padding-inline: 16px; }
}
@media (min-width: 1024px) {
  .home-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }
  .home-grid > .home-main { grid-column: span 7; }
  .home-grid > .home-side { grid-column: span 5; }
}

.home-main { display: grid; gap: 16px; min-width: 0; align-content: start; }
.home-side { display: grid; gap: 16px; min-width: 0; align-content: start; }

.home-section {
  background: #fff;
  border: 1px solid var(--erra-card-border);
  border-radius: 8px;
  padding: 16px;
}
.home-section.is-flush { padding: 0; overflow: hidden; }

.home-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.home-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}
.home-section-link {
  font-size: 12px;
  color: #64748b;
  text-decoration: none;
  font-weight: 500;
}
.home-section-link:hover { color: var(--erra-trust); }

/* ─── Market pulse bar — 4 lifetime KPIs, flat, no chart ──────── */
/* Wrap caps width so the strip does not stretch into "empty benchmark
   zone" on wide displays — numbers should feel grouped, not floating. */

.market-pulse-wrap {
  max-width: 1720px;
  margin: 14px auto 0;
  padding-inline: 24px;
}
@media (max-width: 768px) {
  .market-pulse-wrap { padding-inline: 16px; }
}

/* Pulse is a single bordered card whose 4 cells take equal width — to align
   visually with the nav-bento 12-col grid below, give each cell `span 3`. */
.market-pulse {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  background: #fff;
  border: 1px solid var(--erra-card-border);
  border-radius: 8px;
  overflow: hidden;
}
.pulse-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 11px 16px;
  min-height: 52px;
  justify-content: center;
  border-inline-start: 1px solid #f1f5f9;
  grid-column: span 3;
}
.pulse-item:first-child { border-inline-start: none; }

.pulse-label {
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pulse-value {
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .market-pulse { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pulse-item {
    border-inline-start: none;
    border-top: 1px solid #f1f5f9;
    grid-column: span 1;
  }
  .pulse-item:nth-child(-n+2) { border-top: none; }
  .pulse-item:nth-child(even) { border-inline-start: 1px solid #f1f5f9; }
  .pulse-value { font-size: 17px; }
}

/* ─── Compact sidebar widget rows (gainers / losers / movers) ── */

.side-widget-row {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
  text-decoration: none;
  color: inherit;
}
.side-widget-row:last-child { border-bottom: none; }
.side-widget-row:hover .side-widget-name { color: var(--erra-trust); }

.side-widget-rank {
  color: #94a3b8;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.side-widget-name {
  color: #0f172a;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.side-widget-meta {
  color: #64748b;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}
.side-widget-delta {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
  min-width: 48px;
}
.side-widget-delta.is-up   { color: var(--erra-up); }
.side-widget-delta.is-down { color: var(--erra-down); }

.side-empty {
  padding: 16px 0;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* ─── Navigation bento (3×2 grid of section cards) ────────────── */

.nav-bento {
  max-width: 1720px;
  margin: 14px auto 0;
  padding-inline: 24px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}
@media (max-width: 768px) {
  .nav-bento { padding-inline: 16px; }
}
.nav-bento > .nav-card { grid-column: span 4; }
@media (max-width: 1023px) {
  .nav-bento > .nav-card { grid-column: span 6; }
}
@media (max-width: 639px) {
  .nav-bento { grid-template-columns: 1fr; }
  .nav-bento > .nav-card { grid-column: span 1; }
}

.nav-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 14px;
  background: #fff;
  border: 1px solid var(--erra-card-border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.nav-card:hover {
  border-color: var(--nav-accent, var(--erra-trust));
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}
.nav-card:hover .nav-card-arrow { transform: translateX(3px); opacity: 1; }
html[dir="rtl"] .nav-card:hover .nav-card-arrow { transform: translateX(-3px); }

/* Visual preview block inside each nav-card. Inline SVG uses currentColor
   so accent recoloring happens via the wrapping color rule. */
.nav-card-preview {
  position: relative;
  width: 100%;
  height: 110px;
  border-radius: 8px;
  background: var(--nav-tile-bg, #eff6ff);
  color: var(--nav-accent, var(--erra-trust));
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-card-preview svg { width: 100%; height: 100%; display: block; }
.nav-card-preview { height: 160px; }
.nav-card-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
}
.nav-card-preview.is-real-thumb { background: #f4f0e8; }
.nav-card-preview.is-real-thumb svg { width: auto; max-width: 80%; max-height: 90%; }

.nav-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav-card-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.2;
  margin: 0;
}
.nav-card-title i {
  color: var(--nav-accent, var(--erra-trust));
  font-size: 16px;
}
.nav-card-arrow {
  color: #cbd5e1;
  font-size: 16px;
  opacity: 0.6;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.nav-card-desc {
  font-size: 12px;
  color: #64748b;
  line-height: 1.45;
  margin: 0;
  min-height: 34px; /* visual rhythm — all cards same height even with 1-line desc */
}
.nav-card-stat {
  font-size: 12px;
  font-weight: 600;
  color: var(--nav-accent, var(--erra-trust));
  font-variant-numeric: tabular-nums;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Accent modifiers — set CSS vars consumed by .nav-card */
.nav-card.is-map        { --nav-tile-bg: #dbeafe; --nav-accent: #1d4ed8; }
.nav-card.is-dashboard  { --nav-tile-bg: #e0e7ff; --nav-accent: #4338ca; }
.nav-card.is-movers     { --nav-tile-bg: #dcfce7; --nav-accent: #15803d; }
.nav-card.is-compare    { --nav-tile-bg: #fef3c7; --nav-accent: #b45309; }
.nav-card.is-aichat     { --nav-tile-bg: #f3e8ff; --nav-accent: #7c3aed; }
.nav-card.is-aianalysis { --nav-tile-bg: #cffafe; --nav-accent: #0891b2; }

/* ─── Combo widget (asset mix 30D + deals trend 30D) ──────────── */

.home-combo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  background: #fff;
  border: 1px solid var(--erra-card-border);
  border-radius: 8px;
  padding: 14px 16px;
}
@media (max-width: 768px) {
  .home-combo { grid-template-columns: 1fr; }
}
.combo-half {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.combo-half + .combo-half {
  padding-inline-start: 16px;
  border-inline-start: 1px solid #f1f5f9;
}
@media (max-width: 768px) {
  .combo-half + .combo-half {
    padding-inline-start: 0;
    padding-block-start: 12px;
    border-inline-start: none;
    border-block-start: 1px solid #f1f5f9;
  }
}
.combo-title {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.combo-mix {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.combo-mix-chart {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.combo-mix-chart canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.combo-mix-legend { display: grid; gap: 4px; font-size: 12px; }
.combo-mix-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.combo-mix-dot { width: 8px; height: 8px; border-radius: 2px; }
.combo-mix-label { color: #475569; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-mix-pct { color: #0f172a; font-weight: 600; font-variant-numeric: tabular-nums; }

.combo-trend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}
.combo-trend-numbers { display: flex; flex-direction: column; gap: 2px; }
.combo-trend-value {
  font-size: 22px;
  font-weight: 600;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.combo-trend-meta {
  font-size: 11px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
}
.combo-trend-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-inline-start: 6px;
}
.combo-trend-delta.is-up   { color: var(--erra-up); }
.combo-trend-delta.is-down { color: var(--erra-down); }
.combo-trend-spark {
  width: 130px;
  height: 50px;
}
.combo-trend-spark canvas { width: 100%; height: 100%; display: block; }

/* CTA link under the recent-deals teaser */
.home-cta-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--erra-trust);
  text-decoration: none;
  border-top: 1px solid #f1f5f9;
  width: 100%;
  justify-content: flex-end;
  transition: background 0.12s, color 0.12s;
}
.home-cta-link:hover { background: #f8fafd; color: #1e40af; }
.home-cta-link i { font-size: 14px; }

/* ─── Top regions list (progress bar showing share of max deals) ── */

.top-region-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
  text-decoration: none;
  color: inherit;
}
.top-region-row:last-child { border-bottom: none; }
.top-region-row:hover .top-region-name { color: var(--erra-trust); }

.top-region-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-region-bar-track {
  margin-top: 4px;
  width: 100%;
  height: 3px;
  background: #f1f5f9;
  border-radius: 2px;
  overflow: hidden;
}
.top-region-bar-fill {
  height: 100%;
  background: var(--erra-trust);
  opacity: 0.65;
  border-radius: 2px;
}
.top-region-meta {
  font-size: 11px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  text-align: end;
  white-space: nowrap;
}
.top-region-meta strong {
  display: block;
  color: #0f172a;
  font-weight: 600;
  font-size: 12px;
}

/* ─── Asset mix donut + legend table ───────────────────────────── */

.asset-mix-grid {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.asset-mix-chart-wrap {
  position: relative;
  width: 90px;
  height: 90px;
}
.asset-mix-chart-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}
.asset-mix-legend {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.asset-mix-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.asset-mix-dot {
  width: 8px; height: 8px; border-radius: 2px;
}
.asset-mix-label {
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.asset-mix-value {
  color: #0f172a;
  font-weight: 600;
}

/* ─── Recent deals + Top Movers tables on home — reuse .ln-table ── */
/* Match dashboard's exact header/hover tones so the visual language is one. */

.home-page .ln-table thead th {
  background: #f2f5f9;
  color: #4b5563;
  border-bottom: 1px solid #d1d8e2;
}
.home-page .ln-table tbody tr:hover td {
  background: #f8fafd;
}
.home-page .ln-table tbody td {
  color: #273447;
  border-bottom-color: #e2e8f0;
}
.home-page .ln-table tbody tr:last-child td { border-bottom: none; }

/* AI prompt strip removed — was visually disconnected from rest of the page. */
