:root {
  color-scheme: light dark;

  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --text: #1e2430;
  --muted: #5d6878;
  --border: rgba(32, 45, 64, 0.12);
  --shadow: 0 10px 30px rgba(26, 33, 49, 0.08);

  --line: #1c6cf1;
  --line-soft: rgba(28, 108, 241, 0.18);
  --point: #1c6cf1;
  --point-active: #0f4db2;
  --transition-band: rgba(242, 154, 74, 0.14);
  --fixed-band: rgba(28, 108, 241, 0.08);
  --boundary: rgba(127, 93, 244, 0.72);
  --grid: rgba(32, 45, 64, 0.12);
  --axis: rgba(32, 45, 64, 0.24);
  --tooltip: rgba(255, 255, 255, 0.96);
  --tooltip-border: rgba(32, 45, 64, 0.12);
  --tooltip-shadow: 0 12px 28px rgba(26, 33, 49, 0.16);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: rgba(20, 25, 35, 0.76);
    --surface-strong: rgba(20, 25, 35, 0.92);
    --text: #eef3fb;
    --muted: #a7b3c4;
    --border: rgba(230, 238, 250, 0.1);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);

    --line: #6aa6ff;
    --line-soft: rgba(106, 166, 255, 0.22);
    --point: #6aa6ff;
    --point-active: #a9cbff;
    --transition-band: rgba(255, 176, 91, 0.16);
    --fixed-band: rgba(106, 166, 255, 0.1);
    --boundary: rgba(171, 147, 255, 0.74);
    --grid: rgba(230, 238, 250, 0.12);
    --axis: rgba(230, 238, 250, 0.24);
    --tooltip: rgba(18, 22, 30, 0.96);
    --tooltip-border: rgba(230, 238, 250, 0.08);
    --tooltip-shadow: 0 14px 30px rgba(0, 0, 0, 0.36);
  }
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(28, 108, 241, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(242, 154, 74, 0.08), transparent 24%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  width: min(1220px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.page-header {
  display: grid;
  grid-template-columns: 1.8fr minmax(240px, 320px);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.2vw, 2.7rem);
  line-height: 1.08;
}

.subtitle {
  margin: 12px 0 0;
  max-width: 72ch;
  color: var(--muted);
  line-height: 1.55;
}

.status-card,
.chart-panel,
.note-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.status-card {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.status-label {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.status-value {
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 700;
  line-height: 1.1;
}

.status-subvalue {
  margin-top: 6px;
  font-size: 1rem;
}

.status-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.chart-panel {
  padding: 14px 14px 16px;
}

.panel-topbar {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.legend-swatch {
  display: inline-block;
  border-radius: 999px;
}

.legend-swatch.band {
  width: 18px;
  height: 12px;
  border: 1px solid var(--border);
}

.legend-swatch.transition { background: var(--transition-band); }
.legend-swatch.fixed { background: var(--fixed-band); }
.legend-swatch.line {
  width: 24px;
  height: 0;
  border-top: 3px solid var(--line);
}
.legend-swatch.boundary {
  width: 18px;
  height: 0;
  border-top: 2px dashed var(--boundary);
}

.ghost-button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  transform: translateY(-1px);
  outline: none;
  border-color: var(--line);
}

.chart-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.chart {
  display: block;
  width: 100%;
  height: auto;
}

.tooltip {
  position: absolute;
  min-width: 220px;
  pointer-events: none;
  background: var(--tooltip);
  border: 1px solid var(--tooltip-border);
  box-shadow: var(--tooltip-shadow);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  z-index: 2;
}

.tooltip-price {
  font-weight: 700;
  margin-bottom: 6px;
}

.tooltip-duty,
.tooltip-tier,
.tooltip-rate {
  font-size: 0.94rem;
  color: var(--muted);
  line-height: 1.45;
}

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

.note-card {
  padding: 18px;
}

.note-card h2 {
  margin: 0 0 10px;
  font-size: 1.02rem;
}

.note-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.axis-label,
.tick-label,
.boundary-label,
.zone-label,
.annotation-label {
  font-family: inherit;
  fill: var(--muted);
}

.axis-line,
.grid-line {
  stroke: var(--axis);
}

.grid-line {
  stroke: var(--grid);
}

.chart-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: var(--line-soft);
}

.chart-point {
  fill: var(--point);
  stroke: var(--surface-strong);
  stroke-width: 2.5;
  cursor: pointer;
  transition: r 120ms ease, fill 120ms ease;
}

.chart-point.is-active,
.chart-point:hover,
.chart-point:focus-visible {
  fill: var(--point-active);
  outline: none;
}

.boundary-line {
  stroke: var(--boundary);
  stroke-width: 2;
  stroke-dasharray: 7 7;
}

.band-fixed {
  fill: var(--fixed-band);
}

.band-transition {
  fill: var(--transition-band);
}

.selection-line {
  stroke: var(--point-active);
  stroke-width: 1.5;
  stroke-dasharray: 5 7;
}

@media (max-width: 900px) {
  .page-header,
  .notes-grid {
    grid-template-columns: 1fr;
  }

  .panel-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .ghost-button {
    align-self: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 16px, 1220px);
    padding-top: 16px;
  }

  .chart-panel {
    padding: 10px;
  }

  .tooltip {
    min-width: 190px;
    max-width: calc(100vw - 40px);
    padding: 10px 12px;
  }
}
