:root {
  --bg: #f6f8fb;
  --bg-elevated: #ffffff;
  --bg-muted: #eef2f7;
  --text: #0c1222;
  --text-muted: #5c6b82;
  --border: #dde4ee;
  --accent: #0a5c7a;
  --accent-soft: #e8f4fa;
  --accent-hover: #084a63;
  --market-up: #0d7a4f;
  --market-down: #b42318;
  --market-warn: #b45309;
  --salaf: #6b4c9a;
  --spot: #0a5c7a;
  --success: #0d7a4f;
  --warning: #b45309;
  --error: #b42318;
  --shadow: 0 1px 2px rgba(12, 18, 34, 0.04), 0 4px 12px rgba(12, 18, 34, 0.05);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --sidebar-width: 280px;
  --hero-height: 52px;
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg-elevated: #111a2e;
  --bg-muted: #1a2540;
  --text: #e8eef8;
  --text-muted: #94a3b8;
  --border: #243049;
  --accent: #38bdf8;
  --accent-soft: #0c2d44;
  --accent-hover: #7dd3fc;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

body { min-height: 100vh; }

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: 168px 1fr;
  flex: 1;
  min-height: 0;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.65rem 0.55rem;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--hero-height);
  height: calc(100vh - var(--hero-height));
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: 0.12s ease;
  border-left: 2px solid transparent;
}

.nav-item:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  border-left-color: var(--accent);
}

.nav-icon { display: none; }

.content-area {
  padding: 0.65rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
}

.page { display: none; flex-direction: column; gap: 0.65rem; }
.page.active { display: flex; }

.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0.55rem 0.85rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.status-item strong { color: var(--text); }
.status-warn { color: var(--warning); }

.last-updated {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.chip {
  border: 1px solid var(--border);
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.chip:hover { border-color: var(--accent); }
.chip-muted { background: var(--bg-muted); color: var(--text-muted); cursor: default; }

.page-intro { padding: 1.1rem 1.25rem; }
.page-intro h2 { margin: 0 0 0.35rem; font-size: 1.1rem; }
.page-desc { margin: 0; color: var(--text-muted); font-size: 0.88rem; max-width: 720px; }

.mono, .data-table td.mono, .data-table th.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.kpi-card.kpi-accent {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--accent-soft), var(--bg-elevated));
}

.kpi-hint {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.value-sm { font-size: 0.95rem !important; font-weight: 600 !important; }

.chart-empty, .empty-state {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 1.5rem;
}

.empty-state-card {
  max-width: 420px;
  text-align: center;
}

.empty-title {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.empty-body {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.empty-steps {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  text-align: left;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.table-empty { padding: 2rem !important; border: none !important; }

.onboarding-panel {
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.onboarding-panel.hidden { display: none; }

.onboarding-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.onboarding-steps {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1.25rem;
  padding: 0.45rem 1rem;
  background: #0f172a;
  color: #e2e8f0;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--hero-height);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.4);
}

.hero-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: #f8fafc;
}

.hero-sub {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: #94a3b8;
}

.hero .btn-ghost {
  color: #e2e8f0;
  border-color: #334155;
}

.hero .btn-ghost:hover {
  background: #1e293b;
  border-color: #475569;
}

.hero .last-updated {
  color: #94a3b8;
  font-size: 0.68rem;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 999px;
  font-size: 0.68rem;
  color: #e2e8f0;
}

.hero-pill--live {
  background: rgba(21, 128, 61, 0.2);
  border-color: rgba(34, 197, 94, 0.35);
}

.hero-pill--live .pill-label {
  color: #86efac;
}

.pill-label {
  color: #94a3b8;
  font-weight: 500;
}

.hero-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.hero-subscription {
  display: flex;
  justify-content: center;
  margin-top: 0.35rem;
}

.hero-usage-warn {
  display: flex;
  justify-content: center;
  margin-top: 0.35rem;
}

.hero-usage-warn .hero-pill--warn {
  max-width: 42rem;
  text-align: center;
  line-height: 1.35;
  padding: 0.35rem 0.75rem;
}

.hero-pill--warn {
  background: color-mix(in srgb, #b45309 18%, #1e293b);
  color: #fde68a;
  text-decoration: none;
}

.hero-pill--warn:hover {
  text-decoration: underline;
}

.hero-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #94a3b8;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filters-hint {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.filters-body.collapsed,
.filter-chips.collapsed { display: none; }

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.55rem 0.75rem;
}

.kpi-card.kpi-hero .value {
  font-size: 1.5rem;
}

.kpi-card.kpi-warn {
  border-color: var(--market-warn);
}

.price-kind-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-spot {
  background: rgba(10, 92, 122, 0.1);
  color: var(--spot);
}

.badge-salaf {
  background: rgba(107, 76, 154, 0.12);
  color: var(--salaf);
}

.spread-up { color: var(--market-warn); }
.spread-down { color: var(--market-up); }

.topbar { display: none; }

/* Market Snapshot */
.snapshot-meta {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.snapshot-wrap { max-height: 600px; }
.spread-up { color: var(--warning); }
.spread-down { color: var(--success); }

/* Products */
.product-search {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font: inherit;
  min-width: 220px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.product-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: 0.15s ease;
  box-shadow: var(--shadow);
}

.product-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.product-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.product-card h3 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
}

.product-records {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.product-card-price {
  margin-top: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
}

.product-card-spark {
  margin-top: 0.5rem;
  height: 24px;
  color: var(--accent);
}

.sparkline { width: 100%; height: 24px; }
.sparkline-empty { font-size: 0.75rem; color: var(--text-muted); }

.product-card-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.producer-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: flex-end;
}

.producer-sort {
  min-width: 200px;
}

.producers-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  padding: 0 0.25rem 0.85rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.producers-summary strong {
  color: var(--text);
}

.producers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.85rem;
}

.producer-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: 0.15s ease;
}

.producer-card:hover {
  border-color: var(--accent);
}

.producer-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.producer-card h3 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.35;
}

.producer-family {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 500;
}

.producer-primary {
  margin: 0.55rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.producer-primary strong {
  color: var(--text);
  font-weight: 600;
}

.producer-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.producer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.5rem;
  padding: 0.4rem 0.45rem;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  font-size: 0.75rem;
}

.producer-row.producer-empty {
  color: var(--text-muted);
  font-style: italic;
  background: transparent;
  padding-left: 0;
}

.producer-name {
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: center;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  color: var(--text);
}

.producer-name:hover {
  color: var(--accent);
  text-decoration: underline;
}

.producer-stats {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.producer-share {
  font-weight: 600;
  color: var(--accent);
}

.producer-mps {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  justify-content: flex-end;
}

.mp-tag {
  font-size: 0.62rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.producer-more {
  margin-top: 0.45rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Sources */
.quality-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.quality-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: center;
}

.quality-card.warn { border-color: var(--warning); }
.quality-card.ok { border-color: var(--success); }

.quality-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--mono);
}

.quality-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.quality-bar {
  height: 4px;
  background: var(--bg-muted);
  border-radius: 2px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.quality-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.quality-pct {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.sources-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1rem;
}

.files-scroll {
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-row {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.file-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.status-success .file-status-dot { background: var(--success); }
.status-warning .file-status-dot { background: var(--warning); }
.status-error .file-status-dot { background: var(--error); }

.file-name { font-size: 0.8rem; font-weight: 600; word-break: break-all; }
.file-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }

.warnings-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
}

.warnings-list li { margin-bottom: 0.35rem; }

.data-table.compact th,
.data-table.compact td { padding: 0.4rem 0.55rem; }

/* Drawer */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 250;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  margin: 0;
  font-size: 1rem;
}

.drawer-body {
  padding: 1rem 1.25rem 2rem;
  overflow-y: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem 1rem;
  margin: 0;
}

.detail-grid dt {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 0;
  font-size: 0.88rem;
  word-break: break-word;
}

.drawer-overlay { z-index: 240; }

body[data-page="sources"] .filters-panel,
body[data-page="sources"] .page-only { display: none; }

.chart-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 280px;
}

.chart-product-select { min-width: 280px; }

.similar-products {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
}

.similar-chip {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
}

.similar-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.compare-layout .chart-panel.wide { grid-column: 1 / -1; }

@media (max-width: 1100px) {
  .app-body { grid-template-columns: 1fr; }
  .main-nav {
    flex-direction: row;
    overflow-x: auto;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
  }
  .nav-label { white-space: nowrap; }
  .sources-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .content-area { padding: 0.75rem; }
  .sidebar, .drawer { width: 100%; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.subtitle {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-dir {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  font: inherit;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: white;
}

.btn-ghost {
  background: transparent;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
}

.full-width { width: 100%; }

.icon-btn {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.main-content {
  padding: 1.25rem 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* legacy alias */

.panel, .filters-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.65rem 0.85rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

.panel-header h2 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.panel-sub {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.file-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--bg);
}

.file-card .name {
  font-weight: 600;
  font-size: 0.85rem;
  word-break: break-all;
}

.file-card .status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-success { color: var(--success); }
.status-warning { color: var(--warning); }
.status-error { color: var(--error); }

.file-card .meta {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.meta-row {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.meta-chip {
  background: var(--bg-muted);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.filters-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#applyFiltersBtn.pending {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.85rem;
}

.filter-field label, .field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.filter-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.filter-label-row label {
  margin-bottom: 0;
}

.btn-link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link:hover {
  color: var(--accent-hover);
}

.price-usd { color: #0b6e99; font-variant-numeric: tabular-nums; }
.price-irr { color: #7c3aed; font-variant-numeric: tabular-nums; }

[data-theme="dark"] .price-usd { color: #38bdf8; }
[data-theme="dark"] .price-irr { color: #c4b5fd; }

.filter-field input,
.select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font: inherit;
  font-size: 0.82rem;
}

.select[multiple] { min-height: 72px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow);
}

.kpi-card .label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-card .value {
  margin-top: 0.2rem;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.kpi-card .unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.charts-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.chart-panel.wide { grid-column: 1 / -1; }

.chart-container {
  min-height: 260px;
  width: 100%;
  overflow-x: auto;
}

.chart-container-tall {
  min-height: 360px;
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-page-info {
  min-width: 4rem;
  text-align: center;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.data-table th,
.data-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}

.data-table th:hover { color: var(--accent); }

.data-table tbody tr:hover {
  background: var(--accent-soft);
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1rem;
}

.sidebar-body {
  padding: 1rem 1.25rem 2rem;
  overflow-y: auto;
  flex: 1;
}

.settings-group {
  margin-bottom: 1.25rem;
}

.settings-group h3 {
  margin: 0 0 0.6rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.hint {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.mode-tab {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.5rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.toggle-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.toggle-item input { accent-color: var(--accent); }

.column-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.column-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: grab;
  font-size: 0.82rem;
}

.column-list li.dragging { opacity: 0.5; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  z-index: 300;
  max-width: 360px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.55);
  display: grid;
  place-items: center;
  z-index: 400;
  color: white;
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

[data-widget].hidden { display: none !important; }

body[data-mode="compare"] [data-widget]:not([data-widget="marketplaceBar"]):not([data-widget="productCompare"]):not([data-widget="kpis"]):not([data-widget="files"]) {
  /* handled in JS */
}

@media (max-width: 1100px) {
  .charts-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .main-content { padding: 1rem; }
  .sidebar { width: 100%; }
  .app-body { grid-template-columns: 1fr; }
  .main-nav {
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: linear-gradient(160deg, var(--bg-muted), var(--bg));
}

.login-card {
  width: min(100%, 380px);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.login-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-sub {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.login-form {
  margin-top: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-error {
  margin: 0;
  font-size: 0.8rem;
  color: var(--error);
}

.login-error.hidden { display: none; }

.login-success {
  margin: 0;
  font-size: 0.85rem;
  color: var(--success, #0a7);
}

.login-success.hidden { display: none; }

.login-checkbox {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.85rem;
  margin: 0.35rem 0;
}

.login-checkbox a { color: var(--accent); }

.login-pricing-link {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.8rem;
}

.login-pricing-link a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

.login-pricing-link a:hover {
  text-decoration: underline;
}

/* Pricing page */
.pricing-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--bg-muted), var(--bg));
}

.pricing-header {
  border-bottom: 1px solid #1e293b;
  background: #0f172a;
  color: #e2e8f0;
}

.pricing-header .pricing-logo,
.pricing-header .pricing-logo strong {
  color: #f8fafc;
}

.pricing-header .login-eyebrow {
  color: #94a3b8;
}

.pricing-header .btn-ghost {
  color: #e2e8f0;
  border-color: #334155;
}

.pricing-header .btn-primary {
  background: #2563eb;
  border-color: #2563eb;
}

.platform-ticker {
  background: #111827;
  color: #cbd5e1;
  border-bottom: 1px solid #1e293b;
  font-size: 0.75rem;
  padding: 0.35rem 1rem;
  text-align: center;
}

.platform-ticker strong {
  color: #f8fafc;
  font-weight: 600;
}

.pricing-compare {
  margin: 2.5rem 0;
}

.pricing-compare h2 {
  font-size: 1.05rem;
  margin: 0 0 1rem;
}

.pricing-compare-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elevated);
}

.pricing-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 640px;
}

.pricing-compare-table th,
.pricing-compare-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: center;
}

.pricing-compare-table th:first-child,
.pricing-compare-table td:first-child {
  text-align: left;
  font-weight: 500;
}

.pricing-compare-table thead th {
  background: var(--bg-muted);
  font-size: 0.78rem;
}

.pricing-compare-table .col-featured {
  background: rgba(37, 99, 235, 0.06);
}

.preview-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.preview-search-row input[type="search"] {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.preview-search-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0.35rem 0 0;
}

.preview-search-hint a {
  color: var(--accent);
}

.pricing-sticky-cta {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.96);
  border-top: 1px solid #334155;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25);
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.pricing-sticky-cta span {
  color: #e2e8f0;
  font-size: 0.82rem;
}

@media (max-width: 768px) {
  .pricing-sticky-cta {
    display: flex;
  }
  .pricing-main {
    padding-bottom: 5rem;
  }
}

.pricing-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pricing-logo {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.pricing-logo strong {
  font-size: 0.95rem;
}

.pricing-nav {
  display: flex;
  gap: 0.5rem;
}

.pricing-main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
  width: 100%;
}

.pricing-hero {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pricing-hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 3vw, 1.65rem);
  font-weight: 700;
}

.pricing-lead {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 36rem;
  margin-inline: auto;
}

.pricing-note {
  margin: 0.75rem auto 0;
  padding: 0.5rem 0.75rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  max-width: 32rem;
}

.pricing-note.hidden { display: none; }

.pricing-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.pricing-toggle-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pricing-toggle-label em {
  font-style: normal;
  color: var(--market-up);
  font-weight: 600;
}

.pricing-toggle {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  padding: 2px;
  cursor: pointer;
  position: relative;
}

.pricing-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.pricing-toggle-knob {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.pricing-toggle[aria-pressed="true"] .pricing-toggle-knob {
  transform: translateX(20px);
  background: var(--accent);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  align-items: stretch;
}

.pricing-loading,
.pricing-error {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.pricing-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
}

.pricing-card--featured {
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(10, 92, 122, 0.12);
}

.pricing-badge {
  position: absolute;
  top: -0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.pricing-card-title {
  margin: 0.25rem 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
}

.pricing-price {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.pricing-price-suffix {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.pricing-limits,
.pricing-features {
  margin: 0 0 0.65rem;
  padding-left: 1.1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pricing-limits li { margin-bottom: 0.2rem; }

.pricing-features {
  flex: 1;
  color: var(--text);
}

.pricing-features li { margin-bottom: 0.25rem; }

.pricing-cta { margin-top: auto; }

.pricing-faq {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.pricing-faq h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.pricing-faq dl {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.pricing-faq dt {
  font-weight: 600;
  font-size: 0.85rem;
}

.pricing-faq dd {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.pricing-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pricing-hero-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent, #2563eb);
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 999px;
  padding: 0.25rem 0.65rem;
  margin-bottom: 0.75rem;
}

.pricing-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  justify-content: center;
  margin: 1.25rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pricing-trust span::before {
  content: "✓ ";
  color: #15803d;
  font-weight: 700;
}

.pricing-preview {
  margin: 2rem 0 2.5rem;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.02), rgba(37, 99, 235, 0.04));
}

.pricing-preview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.pricing-preview-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.pricing-preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pricing-preview-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.pricing-preview-kpi {
  background: var(--bg-elevated, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
}

.pricing-preview-kpi strong {
  display: block;
  font-size: 1rem;
}

.pricing-preview-kpi span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.pricing-preview-table-wrap {
  overflow-x: auto;
}

.pricing-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.pricing-preview-table th,
.pricing-preview-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 0.35rem;
  text-align: left;
}

.pricing-preview-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.pricing-preview-cta {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.pricing-preview-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 36rem;
}

.pricing-footer a {
  color: var(--accent);
  text-decoration: none;
}

.pricing-footer a:hover { text-decoration: underline; }

.pricing-disclaimer {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
}
