:root {
  --bg: #f5efe1;
  --bg-elevated: rgba(255, 250, 239, 0.88);
  --panel: rgba(255, 249, 236, 0.82);
  --panel-strong: rgba(255, 244, 222, 0.96);
  --ink: #1b1a16;
  --muted: #625d50;
  --line: rgba(31, 28, 20, 0.12);
  --accent: #ba4a18;
  --accent-dark: #832f0d;
  --positive: #0d6b3a;
  --negative: #a52f1c;
  --warning: #7a5800;
  --shadow: 0 20px 50px rgba(71, 52, 18, 0.1);
  --radius: 20px;
  --font-sans: "Avenir Next", "Helvetica Neue", sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(212, 116, 57, 0.18), transparent 35%),
    radial-gradient(circle at bottom left, rgba(99, 132, 74, 0.13), transparent 30%),
    linear-gradient(180deg, #fbf6eb 0%, #f1e7d2 100%);
  color: var(--ink);
  font-family: var(--font-sans);
}

body {
  overflow-x: hidden;
}

.app-shell {
  max-width: 1480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 24px 18px;
}

.topbar,
.panel-header,
.reference-header,
.footer-bar,
.product-tabs,
.selector-row,
.topbar-meta,
.indicator-bar,
.strip-grid {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.price-ticker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.price-ticker-card {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(92, 70, 22, 0.12);
  background: rgba(255, 246, 228, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.price-ticker-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.price-ticker-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.price-ticker-contract {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.price-ticker-value {
  margin-top: 6px;
  font-size: 42px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
}

.price-ticker-change {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.topbar h1,
.panel-header h2,
.reference-header h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.topbar h1 {
  font-size: 34px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar-meta {
  gap: 12px;
}

.clock-card,
.indicator-card,
.panel,
.reference-pane {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.clock-card {
  display: grid;
  gap: 4px;
  min-width: 220px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.clock-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.16em;
}

.clock-value {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.session-pill,
.ghost-button,
.tab-button,
.selector-button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  color: var(--ink);
}

.session-pill {
  display: inline-flex;
  width: fit-content;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}

.session-pill.open {
  background: rgba(13, 107, 58, 0.12);
  color: var(--positive);
}

.session-pill.closed,
.session-pill.maintenance {
  background: rgba(165, 47, 28, 0.1);
  color: var(--negative);
}

.ghost-button,
.tab-button,
.selector-button {
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.ghost-button:hover,
.tab-button:hover,
.selector-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.78);
}

.indicator-bar {
  position: sticky;
  top: 12px;
  z-index: 30;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 233, 0.88);
  box-shadow: var(--shadow);
}

.indicator-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel-strong);
  border: 1px solid rgba(92, 70, 22, 0.12);
}

.indicator-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.indicator-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.indicator-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.muted {
  color: var(--muted);
}

.product-tabs {
  gap: 10px;
  margin-bottom: 16px;
}

.product-brief,
.secondary-indicator-bar {
  margin-bottom: 16px;
}

.secondary-indicator-bar {
  position: static;
  top: auto;
  z-index: auto;
  padding: 10px;
}

.product-brief-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.brief-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(54, 42, 16, 0.08);
  background: rgba(255, 251, 241, 0.84);
}

.brief-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brief-copy {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-top: 12px;
}

.brief-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brief-value {
  margin-top: 3px;
  font-size: 13px;
  font-weight: 700;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.history-card {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(54, 42, 16, 0.08);
  background: rgba(255, 251, 241, 0.84);
}

.history-value-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.history-change {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.history-chart {
  height: 64px;
  margin-top: 10px;
}

.history-chart svg {
  width: 100%;
  height: 100%;
}

.history-empty {
  display: grid;
  place-items: center;
  height: 100%;
  color: var(--muted);
  font-size: 12px;
}

.tab-button.active,
.selector-button.active {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff8ee;
}

.main-grid {
  display: block;
}

.primary-panel {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-swatch.live {
  background: rgba(13, 107, 58, 0.8);
}

.legend-swatch.stale {
  background: rgba(165, 47, 28, 0.55);
}

.strip-grid {
  gap: 10px;
  align-items: stretch;
  flex-wrap: nowrap;
}

.strip-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(54, 42, 16, 0.1);
  background: rgba(255, 251, 241, 0.84);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.strip-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(80, 56, 18, 0.08);
}

.strip-card.selected {
  border-color: rgba(186, 74, 24, 0.62);
  box-shadow: 0 0 0 1px rgba(186, 74, 24, 0.15);
}

.strip-card.stale {
  background: rgba(245, 237, 223, 0.72);
}

.strip-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.strip-symbol {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.strip-code-hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.strip-expiry {
  color: var(--muted);
  font-size: 12px;
}

.strip-price {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.strip-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 10px;
}

.metric-label,
.mini-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mini-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.selector-row {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.scenario-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scenario-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.scenario-input {
  width: 110px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
}

.scenario-input:focus {
  outline: 2px solid rgba(186, 74, 24, 0.28);
  outline-offset: 2px;
}

.chain-metadata,
.status-line,
.hotkey-line {
  color: var(--muted);
  font-size: 12px;
}

.chain-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.chain-insights {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.strip-context {
  margin-bottom: 14px;
}

.insight-pill {
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(54, 42, 16, 0.08);
  background: rgba(255, 246, 229, 0.82);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chain-container {
  overflow: hidden;
}

.chain-grid {
  display: grid;
  gap: 14px;
}

.chain-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.chain-table th,
.chain-table td {
  padding: 7px 6px;
  border-bottom: 1px solid rgba(44, 36, 20, 0.08);
  text-align: right;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chain-table th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chain-table th.strike-col,
.chain-table td.strike-col {
  text-align: center;
  width: 78px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.metric-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-note {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.chain-table td.side-cell.itm {
  background: rgba(13, 107, 58, 0.06);
}

.chain-table td.side-cell.otm {
  background: rgba(122, 88, 0, 0.05);
}

.chain-table tr.atm-row td {
  background: rgba(186, 74, 24, 0.08);
}

.chain-table tr.selected-row td {
  box-shadow: inset 0 0 0 999px rgba(130, 56, 20, 0.06);
}

.chain-table td.signal-iv-shift,
.calendar-cell.signal-iv-shift {
  box-shadow: inset 0 0 0 1px rgba(186, 74, 24, 0.28);
}

.chain-table td.signal-spread-widened,
.calendar-cell.signal-spread-widened {
  box-shadow: inset 0 0 0 1px rgba(161, 109, 8, 0.32);
}

.chain-table td.signal-volume-spike,
.calendar-cell.signal-volume-spike {
  box-shadow: inset 0 0 0 1px rgba(13, 107, 58, 0.32);
}

/* Quality scoring overlay */
.chain-table td.quality-high,
.calendar-cell.quality-high {
  background: rgba(13, 107, 58, 0.06);
}

.chain-table td.quality-mid,
.calendar-cell.quality-mid {
  background: rgba(122, 88, 0, 0.06);
}

.chain-table td.quality-low,
.calendar-cell.quality-low {
  background: rgba(165, 47, 28, 0.08);
}

/* Data health panel */
.data-health-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
  border-top: 1px solid var(--rule);
  background: var(--panel-bg);
  color: var(--muted);
}

.data-health-bar .health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.health-dot.fresh { background: var(--positive); }
.health-dot.recent { background: var(--warning); }
.health-dot.stale { background: var(--negative); opacity: 0.7; }
.health-dot.very_stale { background: var(--negative); }

.data-health-bar .health-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* EIA inventory bar */
.eia-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.72rem;
  border-top: 1px solid var(--rule);
  background: var(--panel-bg);
  color: var(--muted);
}

.eia-bar .eia-item {
  white-space: nowrap;
}

.eia-bar .eia-change {
  font-weight: 600;
}

.compare-table td.expiry-col,
.compare-table th.expiry-col {
  text-align: center;
  width: 110px;
  font-weight: 700;
}

.scenario-table th,
.scenario-table td {
  text-align: right;
}

.scenario-table th.scenario-instrument,
.scenario-table td.scenario-instrument {
  width: 290px;
  text-align: left;
}

.scenario-title {
  font-weight: 700;
}

.scenario-subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.scenario-explainer {
  margin-top: 6px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
}

.calendar-table th.calendar-col,
.calendar-table td.calendar-cell {
  min-width: 118px;
}

.calendar-subhead {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.calendar-cell {
  background: rgba(255, 250, 238, 0.62);
  vertical-align: top;
}

.calendar-cell.empty {
  color: var(--muted);
  background: rgba(245, 237, 223, 0.4);
}

.calendar-price {
  font-size: 14px;
  font-weight: 700;
}

.move-cell {
  transition: background 120ms ease;
}

.heat-strong-positive {
  background: rgba(13, 107, 58, 0.14);
}

.heat-strong-negative {
  background: rgba(165, 47, 28, 0.14);
}

.glossary-pane {
  position: fixed;
  top: 0;
  left: 0;
  width: min(520px, 96vw);
  height: 100vh;
  padding: 20px 18px;
  border-right: 1px solid var(--line);
  background: rgba(247, 240, 227, 0.96);
  box-shadow: 18px 0 60px rgba(61, 45, 18, 0.14);
  transform: translateX(-104%);
  transition: transform 180ms ease;
  z-index: 55;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.glossary-pane.open {
  transform: translateX(0);
}

.glossary-content {
  display: grid;
  gap: 14px;
  height: calc(100% - 80px);
  overflow-y: auto;
  padding-right: 2px;
}

.glossary-grid {
  display: grid;
  gap: 12px;
}

.glossary-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 249, 237, 0.9);
  border: 1px solid rgba(54, 42, 16, 0.08);
}

.glossary-item h3 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
}

.glossary-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-pill {
  display: inline-flex;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(186, 74, 24, 0.08);
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 700;
}

.reference-pane {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 92vw);
  height: 100vh;
  padding: 20px 18px;
  border-left: 1px solid var(--line);
  background: rgba(247, 240, 227, 0.94);
  box-shadow: -18px 0 60px rgba(61, 45, 18, 0.14);
  transform: translateX(104%);
  transition: transform 180ms ease;
  z-index: 50;
}

.reference-pane.open {
  transform: translateX(0);
}

.reference-header {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.reference-content {
  display: grid;
  gap: 14px;
  height: calc(100% - 80px);
  overflow-y: auto;
  padding-right: 2px;
}

.reference-strip .strip-grid {
  flex-direction: column;
}

.reference-strip .strip-card {
  min-width: auto;
}

.footer-bar {
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
}

.mono {
  font-family: var(--font-mono);
}

.loading-card {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed rgba(73, 56, 24, 0.18);
  color: var(--muted);
  text-align: center;
  background: rgba(255, 251, 244, 0.55);
}

@media (max-width: 1180px) {
  .price-ticker {
    grid-template-columns: 1fr;
  }

  .product-brief-grid {
    grid-template-columns: 1fr;
  }

  .indicator-bar {
    flex-wrap: wrap;
  }

  .indicator-card {
    min-width: calc(50% - 6px);
  }

  .history-grid {
    grid-template-columns: 1fr;
  }

  .footer-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .strip-grid {
    flex-wrap: wrap;
  }

  .strip-card {
    min-width: calc(50% - 5px);
  }

  .chain-container {
    overflow-x: auto;
  }

  .glossary-pane,
  .reference-pane {
    width: 100vw;
  }
}
