:root {
  color-scheme: dark;
  --bg: #080b0c;
  --panel: #0d1213;
  --panel-2: #111819;
  --line: rgba(180, 210, 202, 0.16);
  --line-strong: rgba(180, 210, 202, 0.28);
  --text: #edf4ef;
  --muted: #8c9b96;
  --accent: #49b894;
  --accent-soft: rgba(73, 184, 148, 0.14);
  --danger: #d96f66;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Geist", system-ui, sans-serif;
  --motion: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at 80% 8%, rgba(73, 184, 148, 0.12), transparent 26rem),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    var(--bg);
  background-size: auto, 42px 42px, 42px 42px, auto;
}

button, input, select { font: inherit; }

a { color: inherit; text-decoration: none; }

.site-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  z-index: 5;
  background-image: repeating-radial-gradient(circle at 0 0, #fff 0, transparent 1px, transparent 6px);
}

.page-shell {
  width: min(1420px, calc(100% - 40px));
  margin: 0 auto;
  padding: 42px 0 76px;
}

.hero {
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(360px, 1.05fr);
  align-items: center;
  gap: 48px;
  padding: 68px 0 52px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
}

h1, h2, p { margin: 0; }

h1 {
  margin-top: 22px;
  font-size: clamp(56px, 9vw, 132px);
  line-height: 0.86;
  letter-spacing: -0.08em;
}

h2 {
  margin-top: 12px;
  font-size: clamp(26px, 3vw, 42px);
  letter-spacing: -0.04em;
}

.hero-copy p {
  margin-top: 26px;
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.hero-actions, .form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.control-button, .ghost-button, .import-button {
  border: 0;
  cursor: pointer;
  min-height: 46px;
  border-radius: 999px;
  padding: 5px 6px 5px 18px;
  transition: transform 450ms var(--motion), border-color 450ms var(--motion), background 450ms var(--motion);
}

.control-button, .import-button {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: #06100d;
  background: var(--accent);
  font-weight: 700;
}

.import-button {
  color: #fff7e4;
  background: #b98038;
}

.control-button span, .import-button span {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 999px;
  background: rgba(5, 16, 13, 0.14);
  font-family: var(--mono);
  transition: transform 450ms var(--motion);
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  padding-right: 18px;
}

.control-button:hover, .ghost-button:hover, .import-button:hover { transform: translateY(-2px); }
.control-button:hover span, .import-button:hover span { transform: translate(2px, -1px); }
.control-button:active, .ghost-button:active, .import-button:active { transform: scale(0.98); }

.ram-stage-shell, .panel-shell {
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.ram-stage-core, .panel-core {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(17, 24, 25, 0.96), rgba(9, 13, 14, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.ram-stage-core {
  min-height: 430px;
  display: grid;
  place-items: center;
}

#ram-canvas {
  width: 100%;
  height: 430px;
  display: block;
}

.stage-readout {
  position: absolute;
  left: 22px;
  bottom: 22px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-family: var(--mono);
  color: var(--muted);
}

.stage-readout strong { color: var(--accent); font-size: 12px; }

.metrics-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.9fr 1.1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.metrics-grid article {
  min-height: 130px;
  padding: 24px;
  border-top: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(73, 184, 148, 0.08), transparent);
}

.metrics-grid span, .metrics-grid small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-transform: uppercase;
}

.metrics-grid strong {
  display: block;
  margin: 14px 0 10px;
  font-family: var(--mono);
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: -0.06em;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(0, 1.14fr);
  gap: 14px;
  margin-bottom: 14px;
}

.panel-core { padding: 26px; }
.insight-panel .panel-core { min-height: 100%; }
.chart-panel .panel-core { min-height: 100%; }

.chart-panel { margin-bottom: 14px; }

.insight-board {
  display: grid;
  gap: 14px;
}

.insight-primary,
.insight-minis article,
.insight-callout {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(73, 184, 148, 0.09), rgba(255, 255, 255, 0.025));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.insight-primary { padding: 22px; }

.insight-primary::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -28px;
  width: 118px;
  height: 118px;
  border: 1px solid rgba(73, 184, 148, 0.26);
  border-radius: 999px;
}

.insight-minis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.insight-minis article { padding: 18px; }

.insight-callout {
  padding: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.insight-board span,
.insight-board small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.insight-board strong {
  display: block;
  margin: 12px 0 8px;
  font-family: var(--mono);
  font-size: 34px;
  letter-spacing: -0.06em;
}

.insight-minis strong { font-size: 28px; }

.insight-board p {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.7;
}

.chart-heading {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.25fr);
  align-items: end;
  gap: 18px;
}

.chart-note {
  margin-top: 10px;
  max-width: 720px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.chart-frame {
  position: relative;
  width: 100%;
  height: 380px;
  max-height: 380px;
}

#price-chart {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.section-heading { margin-bottom: 24px; }
.split-heading { display: flex; justify-content: space-between; gap: 20px; align-items: start; }

form, .field-grid, .filters-core { display: grid; gap: 16px; }
.field-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.field-group { display: grid; gap: 8px; }
.field-group label {
  color: #c5d0cc;
  font-size: 13px;
  font-weight: 600;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  min-height: 44px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
  outline: none;
  transition: border-color 300ms var(--motion), background 300ms var(--motion);
}

input:focus, select:focus {
  border-color: rgba(73, 184, 148, 0.74);
  background: rgba(73, 184, 148, 0.08);
}

.inline-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.filters-core { grid-template-columns: minmax(240px, 1.5fr) 0.52fr 0.62fr 0.62fr 1fr; }
.table-toolbar {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.025);
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 960px; }
th, td { padding: 15px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: 12px; font-family: var(--mono); font-weight: 600; text-transform: uppercase; }
td { color: #dce6e2; font-size: 14px; }
tbody tr { transition: background 300ms var(--motion); }
tbody tr:hover { background: rgba(73, 184, 148, 0.055); }
.number-cell { font-family: var(--mono); color: #f2fbf7; }
.tag { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--accent); font-family: var(--mono); font-size: 11px; white-space: nowrap; }
.check-cell { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.product-checkbox, #select-all-products { width: 16px; min-height: 16px; accent-color: var(--accent); }
.source-link { color: var(--accent); }
.delete-button { border: 1px solid rgba(217, 111, 102, 0.45); border-radius: 999px; padding: 7px 10px; color: #ffd3cf; background: rgba(217, 111, 102, 0.08); cursor: pointer; white-space: nowrap; }
.row-count { color: var(--muted); font-family: var(--mono); font-size: 12px; }

.empty-state {
  margin-top: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 22px;
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong { display: block; color: var(--text); margin-bottom: 8px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  max-width: 340px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(13, 18, 19, 0.96);
  transition: transform 420ms var(--motion), opacity 420ms var(--motion);
}

.toast.visible { transform: translateY(0); opacity: 1; }

.reveal {
  opacity: 0;
  transform: translateY(34px);
  animation: rise-in 820ms var(--motion) forwards;
}

.reveal:nth-of-type(2) { animation-delay: 100ms; }
.reveal:nth-of-type(3) { animation-delay: 180ms; }
.reveal:nth-of-type(4) { animation-delay: 260ms; }

@keyframes rise-in {
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 980px) {
  .page-shell { width: min(100% - 28px, 760px); padding-top: 22px; }
  .hero, .workspace-grid, .metrics-grid, .filters-core { grid-template-columns: 1fr; }
  .chart-heading { grid-template-columns: 1fr; }
  .hero { min-height: auto; gap: 22px; padding-top: 36px; }
  .metrics-grid article { min-height: auto; }
}

@media (max-width: 640px) {
  .page-shell { width: calc(100% - 20px); }
  .field-grid { grid-template-columns: 1fr; }
  .panel-core { padding: 18px; }
  .ram-stage-core { min-height: 320px; }
  #ram-canvas { height: 320px; }
  .chart-frame { height: 280px; max-height: 280px; }
  h1 { font-size: 58px; }
  .split-heading { display: grid; }
}
