* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #050607;
  --bg-elevated: #0a0c10;
  --surface: #0e1218;
  --panel: #12171f;
  --panel-2: #171d27;
  --panel-border: rgba(180, 200, 230, 0.1);
  --panel-border-strong: rgba(200, 220, 255, 0.16);
  --text: #f4f7fb;
  --text-muted: #9aa6b8;
  --text-dim: #667084;
  --accent: #4cc9f0;
  --accent-soft: rgba(76, 201, 240, 0.14);
  --accent-selected: rgba(76, 201, 240, 0.22);
  --lime: #c8ff4a;
  --input-bg: rgba(4, 6, 9, 0.88);
  --input-border: rgba(180, 200, 230, 0.14);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 0 0 1px rgba(0, 0, 0, 0.45) inset,
    0 10px 28px rgba(0, 0, 0, 0.42);
  --carbon-fine: repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.028) 0 1px,
      transparent 1px 3px
    ),
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.28) 0 1px,
      transparent 1px 3px
    );
  --mono: ui-monospace, "Cascadia Code", Consolas, "Courier New", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --focus-ring: 0 0 0 2px var(--bg), 0 0 0 4px rgba(76, 201, 240, 0.45);
}

html, body {
  height: 100%;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(76, 201, 240, 0.07), transparent 58%),
    radial-gradient(700px 420px at 94% 92%, rgba(200, 255, 74, 0.035), transparent 52%),
    var(--carbon-fine),
    linear-gradient(180deg, #0b0e13 0%, var(--bg) 42%, #030405 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 12px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 55%),
    var(--carbon-fine),
    var(--surface);
  border-bottom: 1px solid var(--panel-border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.titlebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.titlebar-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f8fafc;
  background:
    radial-gradient(circle at 30% 26%, #6b778c, #10151d 68%),
    var(--carbon-fine),
    #0c1016;
  border: 1.5px solid rgba(200, 255, 74, 0.45);
  box-shadow:
    0 0 0 2px rgba(200, 255, 74, 0.08),
    0 0 16px rgba(76, 201, 240, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.titlebar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.titlebar-label {
  font-weight: 750;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.15;
  background: linear-gradient(90deg, #f8fafc 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.titlebar-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.titlebar-credit {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  flex-shrink: 0;
}

.titlebar-credit-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.titlebar-credit-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.titlebar-credit-name em {
  font-style: normal;
  color: var(--lime);
}

.panels {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  gap: 12px;
  padding: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.045) 0%, transparent 40%),
    var(--carbon-fine),
    linear-gradient(180deg, rgba(18, 24, 34, 0.96), rgba(10, 13, 18, 0.98)),
    var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
  pointer-events: none;
  z-index: 1;
}

.panel.left {
  width: 300px;
  flex-shrink: 0;
  padding: 14px;
  gap: 10px;
}

.panel.center {
  width: 340px;
  flex-shrink: 0;
}

.panel.right {
  flex: 1;
  min-width: 280px;
  padding: 0;
  align-self: flex-start; /* height follows caption + chart + notes */
  display: flex;
  flex-direction: column;
}

.panel-caption {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  background: rgba(8, 10, 14, 0.55);
  border-bottom: 1px solid var(--panel-border);
}

.panel-caption::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.field span {
  font-weight: 600;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field select,
.field input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%),
    var(--input-bg);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px),
    0 0;
  background-size: 5px 5px, 5px 5px, auto;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.field select:focus,
.field input[type="number"]:focus {
  outline: none;
  border-color: rgba(76, 201, 240, 0.55);
  box-shadow: var(--focus-ring);
}

.field select option {
  background: #0e1218;
  color: var(--text);
}

.specs {
  background: rgba(4, 6, 9, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
}

.specs-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--panel-border);
}

.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}

.spec-label {
  color: var(--text-dim);
  font-weight: 500;
}

.spec-row [data-spec] {
  font-weight: 600;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
}

.rank-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 2px;
}

.ranked-list {
  list-style: none;
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
  background: rgba(4, 6, 9, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  -webkit-overflow-scrolling: touch;
}

.ranked-list li {
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(180, 200, 230, 0.06);
  white-space: nowrap;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
}

.ranked-list li:last-child {
  border-bottom: none;
}

.ranked-list li:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.ranked-list li.selected {
  background: var(--accent-selected);
  font-weight: 600;
  color: #e8f7ff;
  border-left: 3px solid var(--accent);
  padding-left: 7px;
}

.table-wrap {
  flex: 1;
  overflow: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}

thead th {
  position: sticky;
  top: 0;
  background: #12171f;
  border-bottom: 1px solid var(--panel-border-strong);
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 10px;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  z-index: 1;
}

tbody td {
  padding: 5px 12px;
  border-bottom: 1px solid rgba(180, 200, 230, 0.06);
}

tbody tr:hover td {
  filter: brightness(1.08);
}

/* SPL bands — muted for dark carbon UI, still readable */
tbody tr.spl-red {
  background: rgba(220, 55, 70, 0.88);
  color: #fff5f5;
}

tbody tr.spl-yellow {
  background: rgba(212, 168, 28, 0.88);
  color: #1a1405;
}

tbody tr.spl-green {
  background: rgba(52, 160, 100, 0.78);
  color: #ecfdf5;
}

tbody tr.spl-gray {
  background: rgba(100, 116, 139, 0.45);
  color: #e2e8f0;
}

.chart-wrap {
  flex: 0 0 auto;
  height: 1000px;
  max-height: 1000px;
  min-height: 220px;
  padding: 12px 14px 14px;
  display: flex;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(76, 201, 240, 0.04), transparent 55%);
}

#splChart {
  width: 100% !important;
  height: 100% !important;
  max-height: 100%;
}

.chart-notes {
  flex-shrink: 0;
  background:
    var(--carbon-fine),
    linear-gradient(180deg, #0c1016, #07090c);
  color: var(--text-dim);
  padding: 12px 14px 14px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  line-height: 1.45;
}

.footer-credits {
  margin-bottom: 6px;
  color: var(--text-muted);
}

.footer-credits strong {
  color: var(--text);
  font-weight: 600;
}

.footer-disclaimer {
  color: var(--text-dim);
  max-width: none;
}

/* Custom scrollbars (WebKit) */
.ranked-list::-webkit-scrollbar,
.table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.ranked-list::-webkit-scrollbar-thumb,
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(154, 166, 184, 0.28);
  border-radius: 8px;
}

.ranked-list::-webkit-scrollbar-track,
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}


/* Distance max slider */
.distance-control {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(8, 10, 14, 0.45);
}

.distance-control-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.distance-control-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.distance-control-value {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.distance-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(76, 201, 240, 0.35), rgba(200, 255, 74, 0.25));
  outline: none;
  border: 1px solid rgba(180, 200, 230, 0.14);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.distance-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #e8f7ff, #4cc9f0 55%, #1a6f8a);
  border: 1.5px solid rgba(200, 255, 74, 0.55);
  box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.15), 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.distance-control input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 28%, #e8f7ff, #4cc9f0 55%, #1a6f8a);
  border: 1.5px solid rgba(200, 255, 74, 0.55);
  box-shadow: 0 0 0 2px rgba(76, 201, 240, 0.15), 0 2px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.distance-control input[type="range"]:focus {
  box-shadow: var(--focus-ring);
}

.distance-control-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.footer-osha {
  margin-top: 6px;
  margin-bottom: 6px;
  color: var(--text-muted);
  max-width: none;
}

.footer-osha strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Mobile / tablet ── */
@media (max-width: 1100px) {
  .panels {
    flex-wrap: wrap;
    overflow: auto;
  }

  .panel.left {
    width: 100%;
    max-height: none;
  }

  .panel.center {
    width: calc(42% - 6px);
    min-height: 240px;
    max-height: 320px;
  }

  .panel.right {
    width: calc(58% - 6px);
    min-width: 0;
    align-self: flex-start;
  }

  .chart-wrap {
    height: 960px;
    max-height: 960px;
    min-height: 800px;
  }
}

@media (max-width: 768px) {
  .titlebar {
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .titlebar-label {
    font-size: 13px;
  }

  .titlebar-credit {
    width: 100%;
    align-items: flex-start;
    text-align: left;
    padding-top: 4px;
    border-top: 1px solid var(--panel-border);
  }

  .panels {
    flex-direction: column;
    overflow: auto;
    padding: 10px;
    gap: 10px;
  }

  .panel.left,
  .panel.center,
  .panel.right {
    width: 100%;
    min-width: 0;
  }

  .panel.left {
    max-height: none;
  }

  .panel.center {
    min-height: 200px;
    max-height: 280px;
  }

  .panel.right {
    align-self: stretch;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .chart-wrap {
    height: 800px;
    max-height: 800px;
    min-height: 720px;
  }

  .ranked-list {
    max-height: 220px;
    flex: none;
  }

  .chart-notes {
    padding: 10px 12px 14px;
  }
}

@media (max-width: 420px) {
  .titlebar-mark {
    width: 32px;
    height: 32px;
    font-size: 10px;
  }

  .titlebar-label {
    font-size: 12px;
    letter-spacing: 0.04em;
  }

  .chart-wrap {
    height: 720px;
    max-height: 720px;
    min-height: 640px;
  }
}
