*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --line: #cfd6df;
  --text: #18202a;
  --muted: #647181;
  --accent: #0f766e;
  --accent-soft: #dcefed;
  --warn: #b45309;
  --mark: #b42318;
  --radius: 8px;
}

html {
  height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  overflow-x: hidden;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.topbar h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.source {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.shell {
  display: grid;
  gap: 12px;
  width: min(1360px, 100%);
  min-width: 0;
  margin: 0 auto;
  padding: 12px;
}

.result-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.result-band div,
.controls,
.table-panel,
.scan-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.result-band div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 12px;
}

.result-band span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-band strong {
  font-size: clamp(24px, 4vw, 42px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.controls {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

label span {
  color: var(--muted);
}

input[type="range"] {
  display: block;
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

output {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}

.details {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.details div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.details dt,
.details dd {
  margin: 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.table-panel {
  min-width: 0;
  overflow: hidden;
}

.table-wrap {
  min-width: 0;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 7px 8px;
  border: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  transition: background-color 120ms ease;
}

th {
  background: #f6f8fa;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

td.meta-cell {
  text-align: center;
}

tbody tr.is-row-ref td {
  background-color: rgba(180, 83, 9, var(--cell-alpha, 0));
}

tbody td.ref-cell {
  background-color: rgba(180, 83, 9, var(--cell-alpha, 0));
}

tbody td.weight-cell,
tbody td.ias-cell,
tbody td.wind-cell {
  background-color: rgba(180, 83, 9, var(--cell-alpha, 0));
}

.scan-panel {
  min-width: 0;
  overflow: auto;
  padding: 8px;
}

.scan-panel img {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
}

@media (max-width: 900px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .workspace,
  .result-band {
    grid-template-columns: 1fr;
  }

  .result-band,
  .workspace,
  .controls,
  .table-panel,
  .scan-panel {
    width: 100%;
    max-width: calc(100vw - 24px);
  }

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

  .details {
    grid-column: 1 / -1;
  }
}

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

  .controls label {
    width: calc(100vw - 50px);
    max-width: 100%;
  }

  input[type="range"] {
    width: min(280px, calc(100vw - 70px));
    max-width: 280px;
  }

  output {
    justify-self: start;
    font-weight: 800;
  }

  .details div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .details dd {
    font-weight: 800;
  }

  table {
    min-width: 820px;
  }

  .scan-panel img {
    min-width: 680px;
  }
}
