:root {
  --bg: #121622;
  --panel: #162657;
  --panel-2: #2b3659;
  --panel-3: #202844;
  --accent: #b74e91;
  --accent-2: #5e42a6;
  --accent-3: #6fd0c7;
  --line: rgba(255, 255, 255, 0.15);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: rgba(255, 255, 255, 0.74);
  --muted: rgba(255, 255, 255, 0.52);
  --white: #ffffff;
  --danger: #ff9aa8;
  --contour-50: #c3ccd0;
  --contour-80: #9b8658;
  --contour-90: #6f9a86;
  --contour-95: #7892bd;
  --shadow: 0 1.25rem 2.75rem rgba(8, 12, 26, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

button,
input {
  font: inherit;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
legend,
strong {
  color: var(--white);
}

h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}

h2 {
  font-size: 1.55rem;
  line-height: 1.25;
  margin-bottom: 0.4rem;
}

h3 {
  font-size: 1rem;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 18rem;
  overflow-y: auto;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 2.5rem 2rem;
}

.sidebar-inner {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 3rem;
  text-align: right;
}

.brand {
  align-self: flex-end;
  color: var(--white);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.sidebar ul {
  display: grid;
  gap: 1.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar a {
  position: relative;
  display: block;
  border: 0;
  color: rgba(255, 255, 255, 0.48);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  line-height: 1.75;
  padding-bottom: 1rem;
  text-transform: uppercase;
}

.sidebar a::before,
.sidebar a::after {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 0.18rem;
  border-radius: 8px;
  content: "";
}

.sidebar a::before {
  background: #3c2c62;
}

.sidebar a::after {
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.18s ease;
}

.sidebar a:hover,
.sidebar a:focus-visible {
  color: var(--white);
}

.sidebar a:hover::after,
.sidebar a:focus-visible::after {
  width: 100%;
}

.sidebar .brand {
  padding-bottom: 0;
  color: var(--white);
  font-size: 0.78rem;
}

.sidebar .brand::before,
.sidebar .brand::after {
  display: none;
}

.page-shell {
  min-height: 100vh;
  margin-left: 18rem;
}

.section {
  position: relative;
}

.section-primary {
  background: var(--panel);
}

.section-secondary {
  background: var(--panel-2);
}

.section-tertiary {
  background: var(--panel-3);
}

.section-inner {
  width: min(100%, 88rem);
  margin: 0;
  padding: 4rem;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(22rem, 0.42fr) minmax(32rem, 1fr);
  gap: 2rem;
  align-items: start;
}

.input-panel,
.results-panel,
.plot-panel,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: var(--shadow);
}

.input-panel {
  position: sticky;
  top: 1.5rem;
  padding: 1.35rem;
}

.results-panel {
  min-width: 0;
  padding: 1.35rem;
}

.panel-heading {
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.privacy-note {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.92rem;
  margin-bottom: 0;
}

fieldset {
  margin: 0 0 1rem;
  padding: 0 0 1rem;
  border: 0;
  border-bottom: 1px solid var(--line);
}

fieldset:last-of-type {
  margin-bottom: 1.15rem;
}

legend {
  display: block;
  width: 100%;
  margin-bottom: 0.7rem;
  font-size: 0.84rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
}

label span,
.metric-label,
.plot-heading p,
.status-text,
td,
th {
  color: var(--muted);
}

label span {
  font-size: 0.75rem;
}

input[type="number"] {
  width: 100%;
  min-width: 0;
  height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--white);
  padding: 0 0.75rem;
}

input[type="number"]:focus {
  border-color: var(--white);
  box-shadow: 0 0 0 1px var(--white);
}

.form-actions,
.status-row,
.plot-heading {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  justify-content: space-between;
}

.form-actions {
  flex-wrap: wrap;
}

button {
  min-height: 2.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 0 1.4rem;
  text-transform: uppercase;
  transition: border-color 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

button:hover,
button:focus-visible {
  border-color: var(--white);
  background: rgba(255, 255, 255, 0.06);
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-secondary {
  color: rgba(255, 255, 255, 0.86);
}

.form-error {
  min-height: 1.5rem;
  margin: 0.85rem 0 0;
  color: var(--danger);
  font-size: 0.88rem;
}

.progress {
  width: 100%;
  height: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3));
  transition: width 0.18s ease;
}

.status-text {
  min-height: 1.55rem;
  margin: 0.7rem 0 1rem;
  font-size: 0.92rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.summary-grid > div {
  min-width: 0;
  border-left: 3px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.85rem 0.9rem;
}

.metric-label {
  display: block;
  font-size: 0.75rem;
}

.summary-grid strong {
  display: block;
  overflow: hidden;
  font-size: 1.25rem;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plot-stack {
  display: grid;
  gap: 1rem;
}

.plot-panel {
  position: relative;
  min-width: 0;
  padding: 1rem;
}

.plot-heading {
  margin-bottom: 0.65rem;
}

.plot-heading p {
  margin-bottom: 0;
  font-size: 0.78rem;
  text-align: right;
}

.contour-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: flex-end;
}

.contour-key strong {
  font-weight: 600;
}

.contour-50 {
  color: var(--contour-50);
}

.contour-80 {
  color: var(--contour-80);
}

.contour-90 {
  color: var(--contour-90);
}

.contour-95 {
  color: var(--contour-95);
}

.plot-canvas {
  display: block;
  width: 100%;
  height: 430px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.12);
}

.plot-tooltip {
  position: absolute;
  z-index: 4;
  max-width: min(17rem, calc(100% - 1rem));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(18, 22, 34, 0.94);
  box-shadow: 0 0.85rem 1.6rem rgba(8, 12, 26, 0.34);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
  padding: 0.65rem 0.75rem;
  pointer-events: none;
}

.plot-tooltip.is-pinned {
  border-color: rgba(255, 255, 255, 0.34);
  padding-right: 2.15rem;
  pointer-events: auto;
}

.plot-tooltip[hidden] {
  display: none;
}

.plot-tooltip strong {
  display: block;
  margin-bottom: 0.15rem;
}

.tooltip-close {
  position: absolute;
  top: 0.38rem;
  right: 0.38rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  min-height: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  padding: 0;
  text-align: center;
  text-transform: none;
}

.tooltip-close::after {
  display: none;
}

.tooltip-hint {
  display: block;
  margin-top: 0.35rem;
  color: rgba(255, 255, 255, 0.44);
  font-size: 0.74rem;
}

.section-heading {
  max-width: 50rem;
  margin-bottom: 1.35rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.85rem 1rem;
  text-align: left;
}

th {
  color: var(--white);
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.explanation-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 0.36fr) minmax(24rem, 1fr);
  gap: 2rem;
  align-items: start;
}

.explanation-grid .section-heading {
  margin-bottom: 0;
}

.explanation-grid .section-heading p {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 0;
}

.explanation-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.3rem 1.6rem;
}

.explain-block {
  border-left: 3px solid rgba(255, 255, 255, 0.26);
  padding-left: 1rem;
}

.explain-block h3 {
  margin-bottom: 0.35rem;
}

.explain-block p {
  color: rgba(255, 255, 255, 0.72);
  margin-bottom: 0;
}

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

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

  .input-panel {
    position: static;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 1.25rem;
  }

  .sidebar-inner {
    min-height: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    text-align: left;
  }

  .brand {
    align-self: auto;
  }

  .sidebar ul {
    display: flex;
    gap: 0.9rem;
  }

  .sidebar a {
    padding-bottom: 0.55rem;
  }

  .page-shell {
    margin-left: 0;
  }

  .section-inner {
    padding: 2.25rem;
  }
}

@media (max-width: 760px) {
  h1 {
    font-size: 1.8rem;
  }

  .sidebar {
    padding: 0.75rem 1rem;
  }

  .sidebar-inner {
    gap: 0.7rem;
  }

  .sidebar .brand {
    flex: 0 0 auto;
    font-size: 0.68rem;
    letter-spacing: 0.18em;
  }

  .sidebar nav {
    min-width: 0;
  }

  .sidebar ul {
    justify-content: flex-end;
    gap: 0.5rem;
  }

  .sidebar a {
    font-size: 0.54rem;
    letter-spacing: 0.12em;
  }

  .field-grid,
  .summary-grid,
  .explanation-grid,
  .explanation-content {
    grid-template-columns: 1fr;
  }

  .section-inner {
    padding: 1.5rem;
  }

  .status-row,
  .plot-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .plot-heading p {
    text-align: left;
  }

  .plot-canvas {
    height: 340px;
  }

  button {
    width: 100%;
  }
}
