:root {
  --bg: #0d1320;
  --panel: rgba(14, 22, 38, 0.84);
  --panel-strong: rgba(10, 16, 29, 0.92);
  --text: #ebf2ff;
  --muted: #a9b7d2;
  --line: rgba(255, 255, 255, 0.1);
  --brand: #67b6ff;
  --brand-soft: rgba(103, 182, 255, 0.18);
  --brand-2: #9bffb0;
  --brand-3: #ffcb77;
  --danger: #ff8d8d;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.36);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(1200px 720px at 8% 0%, rgba(103, 182, 255, 0.16), transparent 54%),
    radial-gradient(900px 640px at 90% 14%, rgba(155, 255, 176, 0.1), transparent 46%),
    linear-gradient(180deg, #0a101b, #0d1320 38%, #0e1623);
  padding: 18px;
}

.app {
  width: min(1188px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 14px;
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.hero {
  padding: 20px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.04;
}

.hero p {
  margin: 0;
  max-width: 960px;
  color: rgba(235, 242, 255, 0.8);
}

.method-drawer {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.method-drawer summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(235, 242, 255, 0.86);
}

.method-drawer summary::-webkit-details-marker {
  display: none;
}

.method-drawer summary::after {
  content: "+";
  float: right;
  font-size: 16px;
  line-height: 1;
  color: rgba(103, 182, 255, 0.92);
}

.method-drawer[open] summary::after {
  content: "-";
}

.method-drawer-body {
  display: grid;
  gap: 10px;
  padding: 0 16px 16px;
}

.method-drawer-body p {
  color: rgba(235, 242, 255, 0.76);
}

.hero-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: stretch;
  margin-top: 16px;
}

.hero-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
}

.hero-table {
  min-width: 860px;
}

.hero-table th,
.hero-table td {
  text-align: center;
}

.hero-table tbody tr:hover {
  background: transparent;
}

.hero-table th:first-child,
.hero-table td:first-child {
  text-align: left;
}

.event-toggle-card {
  display: grid;
  gap: 12px;
  align-self: stretch;
  align-content: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
  color: inherit;
  text-decoration: none;
}

.event-toggle-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.event-toggle-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(235, 242, 255, 0.82);
}

.event-toggle-copy {
  font-size: 12px;
  line-height: 1.45;
  color: rgba(235, 242, 255, 0.66);
}

.event-switch {
  position: relative;
  display: inline-flex;
}

.event-switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  margin: 0;
}

.event-switch-track {
  position: relative;
  width: 56px;
  height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(8, 12, 20, 0.94), rgba(21, 31, 49, 0.88));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.event-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(235, 242, 255, 0.98), rgba(169, 183, 210, 0.88));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.32);
  transition: transform 0.18s ease;
}

.event-switch input:focus-visible + .event-switch-track {
  border-color: rgba(103, 182, 255, 0.82);
  box-shadow: 0 0 0 4px rgba(103, 182, 255, 0.14);
}

.event-switch input:checked + .event-switch-track {
  border-color: rgba(155, 255, 176, 0.36);
  background: linear-gradient(180deg, rgba(155, 255, 176, 0.28), rgba(103, 182, 255, 0.28));
}

.event-switch input:checked + .event-switch-track::after {
  transform: translateX(26px);
  background: linear-gradient(180deg, rgba(255, 203, 119, 0.96), rgba(255, 175, 84, 0.86));
}

.table-wrap-tall {
  max-height: 640px;
}

.sort-head {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
}

.sort-head.is-active {
  color: var(--brand-3);
}

.panel {
  padding: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

.panel-tool {
  min-width: 260px;
  max-width: 340px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
}

.panel-tool-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(235, 242, 255, 0.58);
  white-space: nowrap;
}

.panel-tool select {
  min-width: 170px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.compact-head h3,
.compact-head h2 {
  margin-bottom: 4px;
}

.panel-head h2,
.panel-head h3 {
  margin: 0;
}

.panel-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.controls {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(103, 182, 255, 0.05));
}

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

.grid-controls {
  margin-top: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.validation-message {
  min-height: 18px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--danger);
}

.validation-message:empty {
  display: none;
}

.share-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 160px;
  margin-top: 10px;
  align-items: end;
}

.share-field {
  min-width: 0;
}

.share-field input[readonly] {
  color: rgba(235, 242, 255, 0.82);
}

.share-copy-btn {
  min-height: 42px;
}

.control-tile {
  display: grid;
  gap: 6px;
  align-content: end;
}

.control-tile-label {
  font-size: 12px;
  color: rgba(235, 242, 255, 0.76);
}

.secondary-action {
  width: 100%;
  min-height: 42px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: rgba(235, 242, 255, 0.76);
}

input,
select,
button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  font: inherit;
  padding: 9px 11px;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(103, 182, 255, 0.82);
  box-shadow: 0 0 0 4px rgba(103, 182, 255, 0.14);
}

select option {
  background: #0f1728;
}

button {
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.08s ease, border-color 0.16s ease, background 0.16s ease;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: rgba(103, 182, 255, 0.64);
  background: linear-gradient(180deg, rgba(103, 182, 255, 0.28), rgba(103, 182, 255, 0.12));
}

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

.status {
  margin: 12px 0 0;
  min-height: 18px;
  color: rgba(235, 242, 255, 0.84);
}

.tab-shell {
  padding-top: 12px;
}

.tab-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  border-radius: 999px;
  padding-inline: 14px;
}

.tab-btn.is-active {
  border-color: rgba(103, 182, 255, 0.64);
  background: rgba(103, 182, 255, 0.18);
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: grid;
  gap: 12px;
}

.summary-grid,
.note-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.metric-card,
.note-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(0, 0, 0, 0.2);
}

.metric-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-value {
  font-size: clamp(22px, 4vw, 30px);
  line-height: 1.05;
  font-weight: 800;
}

.panel-stack {
  display: grid;
  gap: 12px;
}

.reroll-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  justify-content: center;
}

.reroll-tables {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: min(720px, 100%);
  max-width: 100%;
  margin-inline: auto;
}

.reroll-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.reroll-table-wrap table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
}

.reroll-lower-wrap tbody td {
  border-bottom: 0;
}

.reroll-table-wrap tbody tr:hover {
  background: transparent;
}

.reroll-col-label {
  width: 34%;
}

.reroll-col-metric {
  width: 33%;
}

.reset-suggestion-row td {
  background: rgba(103, 182, 255, 0.12);
  font-weight: 700;
}

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

.lookup-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 2px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
  color: rgba(235, 242, 255, 0.8);
}

.legend-chip::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
}

.legend-chip-continue::before {
  background: rgba(155, 255, 176, 0.92);
}

.legend-chip-empty::before {
  background: rgba(255, 255, 255, 0.22);
}

.lookup-baseline-wrap {
  width: fit-content;
  max-width: 100%;
}

.lookup-baseline-table {
  min-width: 920px;
}

.lookup-baseline-table th,
.lookup-baseline-table td {
  text-align: center;
  min-width: 78px;
}

.lookup-baseline-table tbody tr:first-child th,
.lookup-baseline-table tbody tr:first-child td {
  background: rgba(10, 16, 29, 0.96);
}

.lookup-baseline-table th:first-child,
.lookup-baseline-table td:first-child {
  text-align: left;
  min-width: 180px;
}

.lookup-baseline-table th {
  background: rgba(10, 16, 29, 0.96);
}

.lookup-baseline-table tbody tr:hover,
.lookup-matrix-table tbody tr:hover {
  background: transparent;
}

.lookup-matrix-wrap {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.lookup-matrix-block {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.lookup-table-label {
  width: 100%;
  font-size: 13px;
  font-weight: 700;
  color: rgba(235, 242, 255, 0.86);
}

.lookup-matrix-table {
  width: max-content;
  min-width: 0;
}

.lookup-matrix-table th,
.lookup-matrix-table td {
  text-align: center;
  min-width: 78px;
}

.lookup-matrix-table th:first-child,
.lookup-matrix-table td:first-child {
  text-align: left;
  background: rgba(10, 16, 29, 0.96);
}

.lookup-corner {
  min-width: 120px;
}

.lookup-target-btn {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.lookup-target-btn:hover,
.lookup-target-btn:focus-visible {
  color: var(--brand-3);
}

.lookup-target-btn.is-active {
  color: var(--brand-2);
}

.lookup-empty {
  color: rgba(255, 255, 255, 0.24);
}

.lookup-highlight {
  background: rgba(155, 255, 176, 0.16);
  color: var(--brand-2);
  font-weight: 700;
 }

.lookup-col-hover,
.lookup-cross-hover,
.hero-col-hover {
  box-shadow: inset 0 0 0 999px rgba(103, 182, 255, 0.14);
}

.lattice-card {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
}

.lattice-diagram {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: auto;
}

.inset-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.14));
}

canvas {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(13, 19, 32, 0.96), rgba(7, 11, 20, 0.98));
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.table-wrap-fit {
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.table-wrap-fit table {
  width: max-content;
  min-width: 0;
  margin-inline: auto;
}

.table-wrap-tall.table-wrap-fit {
  scrollbar-color: rgba(103, 182, 255, 0.72) rgba(8, 12, 20, 0.88);
  scrollbar-width: thin;
}

.table-wrap-tall.table-wrap-fit::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.table-wrap-tall.table-wrap-fit::-webkit-scrollbar-track {
  background: rgba(8, 12, 20, 0.88);
  border-radius: 999px;
}

.table-wrap-tall.table-wrap-fit::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(103, 182, 255, 0.92), rgba(103, 182, 255, 0.54));
  border: 2px solid rgba(8, 12, 20, 0.88);
  border-radius: 999px;
}

.table-wrap-tall.table-wrap-fit::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(155, 255, 176, 0.9), rgba(103, 182, 255, 0.66));
}

.table-wrap-tall.table-wrap-fit::-webkit-scrollbar-corner {
  background: rgba(8, 12, 20, 0.88);
}

.table-wrap.is-cumulative-hidden .col-cumulative {
  display: none;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(10, 16, 29, 0.96);
  color: rgba(235, 242, 255, 0.9);
  z-index: 1;
}

tbody tr:hover {
  background: rgba(103, 182, 255, 0.08);
}

.cell-hit {
  color: var(--brand-2);
  font-weight: 700;
}

.cell-miss {
  color: rgba(255, 255, 255, 0.45);
}

.note,
.note-card p {
  margin: 0;
  font-size: 12px;
  color: rgba(235, 242, 255, 0.66);
}

.note-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.nav-rail {
  width: min(280px, 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.16);
  padding: 10px;
}

.nav-rail-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(233, 238, 252, 0.9);
  margin: 0;
}

.nav-rail-toggle {
  border-radius: 10px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.nav-rail-sections {
  display: grid;
  gap: 10px;
}

.nav-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  padding: 8px;
}

.nav-home-card {
  display: grid;
  gap: 8px;
}

.nav-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-group-title {
  color: rgba(233, 238, 252, 0.62);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0 2px;
}

.nav-rail-list {
  display: grid;
  gap: 8px;
}

.nav-rail-link {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 650;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.06s ease;
}

.nav-rail-link:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.24);
}

.nav-rail-link:active {
  transform: translateY(1px);
}

.nav-rail-link.is-active {
  border-color: rgba(103, 182, 255, 0.48);
  background: linear-gradient(180deg, rgba(103, 182, 255, 0.24), rgba(103, 182, 255, 0.08));
}

.nav-rail.is-collapsed {
  width: 64px;
  padding: 10px 8px;
}

.nav-rail.is-collapsed .nav-card:not(.nav-home-card) {
  display: none;
}

.nav-rail.is-collapsed .nav-home-card .nav-rail-list,
.nav-rail.is-collapsed .nav-home-card .nav-rail-title {
  display: none;
}

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

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .hero-table-row {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .reroll-layout {
    grid-template-columns: 1fr;
  }

  .panel-tool {
    width: 100%;
    max-width: none;
    justify-content: space-between;
  }

  .panel-tool select {
    min-width: 0;
    flex: 1 1 auto;
  }

  .metric-value {
    font-size: 24px;
  }

  .share-row {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 1280px) {
  .nav-rail {
    position: fixed;
    left: 16px;
    top: 16px;
    z-index: 5;
  }
}
