:root {
  --canvas: #f4efe6;
  --canvas-2: #ebe3d6;
  --panel: rgba(255, 252, 247, 0.94);
  --panel-strong: #fffdf9;
  --panel-soft: rgba(247, 241, 232, 0.88);
  --line: rgba(62, 62, 54, 0.12);
  --line-strong: rgba(47, 45, 38, 0.18);
  --ink: #1f2d33;
  --muted: #5f6c72;
  --muted-strong: #445257;
  --accent: #a55a32;
  --accent-deep: #77401f;
  --accent-soft: #ead7c9;
  --accent-cool: #35566d;
  --accent-sage: #6f8265;
  --ok: #2f6b57;
  --danger: #a14a3d;
  --shadow: 0 18px 40px rgba(35, 39, 31, 0.09);
  --shadow-soft: 0 10px 24px rgba(35, 39, 31, 0.06);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 14px;
  background:
    radial-gradient(circle at top left, rgba(214, 187, 166, 0.45), transparent 32%),
    radial-gradient(circle at bottom right, rgba(134, 154, 121, 0.2), transparent 28%),
    linear-gradient(180deg, var(--canvas), var(--canvas-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(74, 62, 44, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(74, 62, 44, 0.045) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.45), transparent 88%);
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 20px 56px;
  display: grid;
  gap: 16px;
}

.hero,
.panel,
.metric-card,
.chart-card {
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.hero {
  position: relative;
  overflow: hidden;
  color: #f8f2eb;
  background:
    radial-gradient(circle at top right, rgba(228, 172, 121, 0.16), transparent 28%),
    linear-gradient(145deg, rgba(30, 46, 57, 0.98), rgba(58, 71, 62, 0.95));
  border-radius: var(--radius-xl);
  padding: 28px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -8% -52% auto;
  width: 280px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(220, 168, 124, 0.22), transparent 68%);
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr);
  gap: 22px;
  align-items: start;
}

.hero-copy {
  max-width: 700px;
}

.kicker,
.section-kicker,
.aside-label,
.preset-label,
.scenario-tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 600;
}

.kicker {
  color: rgba(248, 242, 235, 0.74);
}

h1 {
  margin: 12px 0 14px;
  font-family: "Newsreader", serif;
  font-size: clamp(2.3rem, 4.8vw, 4.35rem);
  line-height: 0.96;
  font-weight: 600;
  letter-spacing: -0.04em;
}

.subtitle {
  margin: 0;
  max-width: 58ch;
  color: rgba(248, 242, 235, 0.8);
  font-size: 1rem;
  line-height: 1.55;
}

.hero-aside {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 251, 246, 0.08);
  border: 1px solid rgba(255, 245, 234, 0.12);
  backdrop-filter: blur(6px);
}

.aside-label {
  color: rgba(248, 242, 235, 0.7);
}

.hero-points {
  margin: 12px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: rgba(248, 242, 235, 0.88);
}

.hero-points li {
  line-height: 1.4;
}

.scenario-strip {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  padding: 14px;
  border-radius: var(--radius-lg);
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 12px;
  align-items: center;
  background: rgba(250, 243, 235, 0.1);
  border: 1px solid rgba(255, 245, 234, 0.12);
}

.scenario-field {
  justify-content: space-between;
}

.scenario-field span {
  color: rgba(248, 242, 235, 0.8);
}

.scenario-tag {
  text-align: right;
  color: rgba(248, 242, 235, 0.72);
}

.hero-footnote {
  margin: 14px 0 0;
  color: rgba(248, 242, 235, 0.64);
  font-size: 0.83rem;
}

.panel,
.metric-card,
.chart-card {
  background: var(--panel);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-lg);
}

.controls,
.insights {
  padding: 16px;
}

.charts {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.chart-wide {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.section-kicker {
  color: var(--accent);
}

.section-head h2,
.chart-header h2 {
  margin: 6px 0 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.section-copy {
  margin: 0;
  max-width: 56ch;
  color: var(--muted);
  line-height: 1.45;
}

.compact-copy {
  margin-top: 6px;
}

.controls-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar .field-inline {
  min-width: 185px;
}

.toolbar-note,
.helper-note,
.page-footnote p,
.import-status {
  color: var(--muted);
}

.toolbar-note {
  margin: 10px 0 0;
  font-size: 0.84rem;
}

.preset-row {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

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

.preset-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

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

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

/* Stacks like .field-inline does, but the label sits above the input so
   seven fields fit in three columns without a wider panel. Scoped to the
   block because .field-inline is declared later and would otherwise win the
   tie on align-items. */
.inference-fields .inference-field {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  font-size: 0.84rem;
}

.inference-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.drop-zone {
  margin-top: 12px;
  padding: 14px;
  text-align: center;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(87, 102, 111, 0.35);
  background: rgba(255, 252, 248, 0.85);
  color: var(--muted-strong);
  cursor: pointer;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: rgba(165, 90, 50, 0.5);
  background: rgba(255, 248, 241, 0.95);
}

.drop-zone:focus:not(:focus-visible) {
  border-color: rgba(165, 90, 50, 0.5);
  background: rgba(255, 248, 241, 0.95);
}

.drop-zone.is-dragover {
  border-color: rgba(53, 86, 109, 0.5);
  background: rgba(238, 244, 247, 0.92);
}

.import-status {
  min-height: 1.3em;
  margin: 8px 0 0;
  font-size: 0.82rem;
}

.import-status.error {
  color: var(--danger);
}

.import-status.success {
  color: var(--ok);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted-strong);
  font-size: 0.9rem;
}

.field-inline.compact {
  font-size: 0.84rem;
}

select,
.input,
button,
output {
  font-family: inherit;
}

.input,
select {
  width: 100%;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid rgba(75, 75, 62, 0.14);
  background: rgba(255, 252, 248, 0.95);
  color: var(--ink);
  padding: 9px 11px;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.hero .input {
  background: rgba(255, 251, 246, 0.95);
}

.input:focus,
select:focus {
  outline: none;
  border-color: rgba(165, 90, 50, 0.6);
  box-shadow: 0 0 0 3px rgba(165, 90, 50, 0.35);
  background: #fffdf9;
}

.table-wrap {
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 252, 248, 0.82);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid rgba(63, 56, 41, 0.08);
  vertical-align: middle;
}

th {
  background: rgba(241, 234, 224, 0.72);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

td {
  font-size: 0.88rem;
}

tbody tr:nth-child(2n) {
  background: rgba(255, 252, 248, 0.72);
}

tbody tr:hover {
  background: rgba(245, 238, 229, 0.92);
}

.cost-cell {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
}

.btn,
.btn-icon {
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.btn {
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 999px;
  font-weight: 500;
}

.btn:hover,
.btn-icon:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff8f2;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 20px rgba(165, 90, 50, 0.16);
}

.btn-primary:hover {
  border-color: rgba(119, 64, 31, 0.4);
}

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 251, 246, 0.88);
  border-color: rgba(75, 75, 62, 0.14);
}

.btn-ghost:hover,
.btn-pill:hover {
  border-color: rgba(165, 90, 50, 0.35);
  background: rgba(255, 248, 241, 0.98);
}

.btn-pill {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  border-color: rgba(75, 75, 62, 0.14);
  background: rgba(255, 253, 249, 0.96);
  color: var(--ink);
  font-size: 0.83rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  border-color: rgba(75, 75, 62, 0.14);
  background: rgba(255, 251, 246, 0.88);
  color: var(--muted-strong);
  font-size: 1rem;
}

/* Available to assistive tech, removed from the visual layout. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.metric-card {
  padding: 16px;
  background: linear-gradient(180deg, rgba(255, 253, 250, 0.98), rgba(247, 241, 232, 0.92));
}

.metric-card:nth-child(2) {
  background: linear-gradient(180deg, rgba(250, 248, 243, 0.98), rgba(240, 235, 227, 0.92));
}

.metric-card:nth-child(3) {
  background: linear-gradient(180deg, rgba(249, 252, 252, 0.98), rgba(236, 244, 244, 0.92));
}

.metric-card:nth-child(4) {
  background: linear-gradient(180deg, rgba(252, 250, 246, 0.98), rgba(243, 238, 230, 0.92));
}

.metric-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric-card h3 {
  margin: 12px 0 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.2rem;
  line-height: 1.2;
}

.metric-pulse {
  background: linear-gradient(180deg, rgba(255, 247, 241, 0.98), rgba(246, 233, 223, 0.94));
}

.metric-over {
  border-color: rgba(161, 74, 61, 0.28);
}

.metric-over h3 {
  color: var(--danger);
}

.metric-under {
  border-color: rgba(47, 107, 87, 0.22);
}

.metric-under h3 {
  color: var(--ok);
}

.chart-card {
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 252, 247, 0.98), rgba(246, 240, 231, 0.9));
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-header-stack {
  align-items: flex-start;
}

.chart-note,
.helper-note {
  margin: 10px 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.chart-note {
  margin: -2px 0 10px;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(115, 122, 123, 0.16);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.bar-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

.legend {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 248, 0.9);
  font-size: 0.77rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

canvas {
  width: 100%;
  max-width: 100%;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.94);
}

.forecast-canvas {
  height: clamp(200px, 30vw, 310px);
}

.recommendation-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 9px;
  color: var(--muted-strong);
}

.recommendation-list li {
  line-height: 1.5;
}

.page-footnote {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 18px;
}

.page-footnote p {
  margin: 0;
  font-size: 0.8rem;
}

@media (max-width: 1080px) {
  .hero-grid,
  .section-head {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .section-head {
    display: grid;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .chart-wide {
    grid-column: auto;
  }

  .scenario-strip {
    grid-template-columns: 1fr;
  }

  .scenario-tag {
    text-align: left;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 16px 12px 36px;
  }

  .hero,
  .controls,
  .insights,
  .chart-card,
  .metric-card {
    padding-left: 14px;
    padding-right: 14px;
  }

  .controls-top {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar,
  .toolbar .field-inline,
  .toolbar .btn {
    width: 100%;
  }

  .toolbar .field-inline {
    min-width: 0;
  }

  .preset-row {
    flex-direction: column;
    align-items: stretch;
  }

  .preset-actions,
  .preset-actions .btn {
    width: 100%;
  }

  .inference-groups,
  .inference-metrics {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 110px minmax(0, 1fr);
  }

  .bar-value {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: clamp(2rem, 13vw, 2.9rem);
  }

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

  .inference-fields {
    grid-template-columns: 1fr;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .forecast-canvas {
    height: clamp(190px, 58vw, 260px);
  }
}

.compare-panel {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(120, 140, 170, 0.28);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.compare-panel h2 {
  margin: 0 0 0.5rem;
}

.compare-summary {
  color: var(--muted, #5b6b7f);
  margin: 0 0 0.75rem;
}

/* Respect a reduced-motion preference. WCAG 2.3.3. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
