:root {
  --bg: #f4efe7;
  --bg-strong: #e9e0d0;
  --paper: rgba(255, 251, 245, 0.9);
  --paper-strong: rgba(255, 248, 239, 0.97);
  --ink: #172033;
  --muted: #5d697d;
  --line: rgba(23, 32, 51, 0.12);
  --accent: #0d7a6e;
  --accent-soft: rgba(13, 122, 110, 0.12);
  --accent-alt: #d06636;
  --accent-alt-soft: rgba(208, 102, 54, 0.12);
  --warn: #9f4d1d;
  --warn-soft: rgba(159, 77, 29, 0.14);
  --shadow: 0 22px 64px rgba(23, 32, 51, 0.09);
  --radius: 28px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(13, 122, 110, 0.14), transparent 28%),
    radial-gradient(circle at 92% 14%, rgba(208, 102, 54, 0.14), transparent 24%),
    linear-gradient(180deg, var(--bg-strong) 0%, var(--bg) 30%, #fcfaf6 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px;
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 42px;
  border-radius: 40px;
  background:
    linear-gradient(135deg, rgba(18, 41, 54, 0.96), rgba(14, 26, 35, 0.96)),
    #122936;
  box-shadow: var(--shadow);
}

.hero h1 {
  max-width: 10ch;
  margin: 0;
  color: #fffaf3;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 6vw, 5rem);
  line-height: 0.96;
}

.eyebrow {
  margin: 0 0 10px;
  color: #a8f1d6;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.lede {
  max-width: 68ch;
  margin-top: 18px;
  color: rgba(255, 250, 243, 0.82);
  font-size: 1.02rem;
  line-height: 1.7;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.14);
  color: #fffaf3;
  font-weight: 700;
}

.pill--soft {
  background: rgba(168, 241, 214, 0.16);
  color: #d8fff1;
}

.dataset-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.dataset-chip {
  border: 1px solid rgba(255, 250, 243, 0.14);
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(255, 250, 243, 0.08);
  color: #fffaf3;
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.dataset-chip:hover,
.dataset-chip:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(168, 241, 214, 0.4);
  background: rgba(168, 241, 214, 0.12);
}

.dataset-chip.is-active {
  border-color: rgba(168, 241, 214, 0.8);
  background: rgba(168, 241, 214, 0.18);
}

.dataset-chip__title {
  display: block;
  font-weight: 700;
}

.dataset-chip__meta {
  display: block;
  margin-top: 4px;
  color: rgba(255, 250, 243, 0.72);
  font-size: 0.84rem;
}

.hero__glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(12px);
  opacity: 0.7;
}

.hero__glow--left {
  left: -60px;
  bottom: -80px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(208, 102, 54, 0.82), transparent 65%);
}

.hero__glow--right {
  right: -50px;
  top: -60px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(13, 122, 110, 0.76), transparent 62%);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
  margin-top: 22px;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 14px 42px rgba(23, 32, 51, 0.06);
  backdrop-filter: blur(10px);
}

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

.panel__header {
  margin-bottom: 16px;
}

.panel h2 {
  margin: 0;
  font-size: 1.6rem;
}

.panel__text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.note-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.note {
  padding: 14px 16px;
  border: 1px solid rgba(13, 122, 110, 0.16);
  border-radius: 18px;
  background: var(--accent-soft);
  color: var(--ink);
  line-height: 1.5;
}

.note--warn {
  border-color: rgba(159, 77, 29, 0.16);
  background: var(--warn-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.stat-card {
  min-height: 104px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper-strong);
}

.stat-val {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.4;
}

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

.control {
  display: grid;
  gap: 8px;
  grid-column: span 3;
}

.control span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.control input,
.control select {
  min-height: 48px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.control input:focus,
.control select:focus {
  outline: 2px solid rgba(13, 122, 110, 0.18);
  border-color: rgba(13, 122, 110, 0.42);
}

.control:first-child {
  grid-column: span 6;
}

.control--actions {
  align-items: end;
}

.btn-secondary {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 16px;
  background: #fff8f0;
  color: var(--ink);
  cursor: pointer;
}

.results-area {
  min-height: 40px;
}

.results-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 700;
}

.tag--muted {
  background: rgba(23, 32, 51, 0.08);
}

.tag--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.data-table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(23, 32, 51, 0.08);
}

.data-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.68);
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(23, 32, 51, 0.08);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  position: sticky;
  top: 0;
  background: rgba(244, 239, 231, 0.98);
  z-index: 1;
  font-size: 0.84rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
  white-space: nowrap;
}

.data-table tr[data-row-id] {
  cursor: pointer;
}

.data-table tr[data-row-id]:hover {
  background: rgba(13, 122, 110, 0.05);
}

.data-table tr.is-selected {
  background: rgba(13, 122, 110, 0.12);
}

.data-table td.zero {
  color: rgba(93, 105, 125, 0.45);
}

.matrix-table td:first-child,
.matrix-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: rgba(255, 251, 245, 0.98);
}

.matrix-table td.total,
.matrix-table th.total {
  font-weight: 700;
}

.detail-card {
  display: grid;
  gap: 18px;
}

.detail-card--empty {
  color: var(--muted);
  min-height: 320px;
  place-items: center;
}

.detail-block {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
}

.detail-name {
  margin: 0;
  font-size: 1.8rem;
}

.detail-subtitle {
  margin-top: 6px;
  color: var(--muted);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

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

.meta-item {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(23, 32, 51, 0.04);
}

.meta-item dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.meta-item dd {
  margin: 8px 0 0;
  font-size: 1rem;
  font-weight: 700;
}

.route-card {
  display: grid;
  gap: 16px;
}

.route-frame {
  padding: 12px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 20% 20%, rgba(13, 122, 110, 0.14), transparent 24%),
    radial-gradient(circle at 82% 24%, rgba(208, 102, 54, 0.14), transparent 18%),
    linear-gradient(180deg, rgba(18, 41, 54, 0.05), rgba(18, 41, 54, 0.02));
  border: 1px solid rgba(23, 32, 51, 0.08);
}

.route-frame svg {
  display: block;
  width: 100%;
  height: auto;
}

.route-caption {
  color: var(--muted);
  line-height: 1.6;
}

.split-list {
  display: grid;
  gap: 10px;
}

.split-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(23, 32, 51, 0.04);
}

.split-item strong {
  font-size: 0.98rem;
}

.split-item span {
  color: var(--muted);
  white-space: nowrap;
}

.empty-state {
  padding: 20px;
  border-radius: 20px;
  background: rgba(23, 32, 51, 0.04);
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .control,
  .control:first-child {
    grid-column: span 6;
  }
}

@media (max-width: 900px) {
  .page-shell {
    padding: 18px;
  }

  .hero {
    padding: 28px;
  }

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

  .control,
  .control:first-child {
    grid-column: span 6;
  }

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

  .data-table {
    min-width: 640px;
  }
}
