@font-face {
  font-family: "IBM Plex Sans";
  src: url("assets/fonts/IBM-Plex-Sans-Var-Roman.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #e7f5f7;
  --muted: #8aa6ae;
  --faint: #54727c;
  --bg: #050b13;
  --panel: #091522;
  --panel-raised: #0d1c2b;
  --line: #1a3544;
  --line-bright: #2a596a;
  --cyan: #2bd8e6;
  --cyan-soft: #7be7ef;
  --amber: #ffb547;
  --red: #ff5f45;
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  color: var(--ink);
  background: var(--bg);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: -2;
  background:
    radial-gradient(circle at 78% 8%, rgba(22, 93, 111, .14), transparent 34rem),
    linear-gradient(180deg, #07121d 0%, var(--bg) 48%, #030810 100%);
}

body::after {
  z-index: -1;
  background:
    linear-gradient(rgba(20, 59, 74, .1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 59, 74, .1) 1px, transparent 1px),
    linear-gradient(180deg, rgba(1, 6, 12, .05) 0%, rgba(1, 6, 12, .32) 100%);
  background-size: 34px 34px, 34px 34px, auto;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  min-height: 124px;
  padding: 22px clamp(20px, 3vw, 44px);
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(3, 9, 16, .98) 0%, rgba(3, 10, 17, .88) 31%, rgba(2, 9, 15, .22) 62%, rgba(2, 8, 14, .62) 100%),
    linear-gradient(180deg, rgba(1, 6, 11, .08), rgba(1, 6, 11, .58)),
    url("assets/submarine-background-v2.png") 67% 62% / cover no-repeat;
  background-image:
    linear-gradient(90deg, rgba(3, 9, 16, .98) 0%, rgba(3, 10, 17, .88) 31%, rgba(2, 9, 15, .22) 62%, rgba(2, 8, 14, .62) 100%),
    linear-gradient(180deg, rgba(1, 6, 11, .08), rgba(1, 6, 11, .58)),
    image-set(url("assets/submarine-background-v2.webp") type("image/webp"), url("assets/submarine-background-v2.png") type("image/png"));
  box-shadow: 0 18px 45px rgba(0, 0, 0, .32);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-copy {
  position: relative;
  z-index: 1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, .95);
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: repeating-radial-gradient(circle, transparent 0 7px, rgba(43, 216, 230, .18) 8px 9px);
  position: relative;
  overflow: hidden;
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 50% 0 auto 50%;
  height: 1px;
  background: linear-gradient(90deg, var(--cyan), transparent);
  transform-origin: left;
  transform: rotate(-28deg);
  width: 50%;
}

.brand-mark span { width: 6px; height: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 12px var(--amber); }
.topbar h1, .panel-heading h2, .results-toolbar h2, .dialog-bar h2 { margin: 0; font-weight: 650; letter-spacing: -.025em; }
.topbar h1 { font-size: clamp(1.2rem, 2vw, 1.65rem); }
.header-subtitle { max-width: 760px; margin: 5px 0 0; color: #b9cdd2; font-size: .875rem; line-height: 1.4; }
.eyebrow { margin: 0 0 4px; color: var(--cyan-soft); font-size: .75rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }

.workspace {
  width: min(1660px, 100%);
  margin: 0 auto;
  padding: 24px clamp(16px, 2vw, 30px) 54px;
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.filters, .results-panel {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(13, 28, 43, .94), rgba(7, 18, 29, .91));
  backdrop-filter: blur(14px) saturate(1.08);
  box-shadow: var(--shadow);
}

.filters { padding: 22px; border-radius: 6px; position: sticky; top: 148px; max-height: calc(100vh - 168px); overflow-y: auto; }
.results-panel { padding: clamp(18px, 2.4vw, 30px); border-radius: 6px; min-height: 70vh; }
.panel-heading, .results-toolbar, .dialog-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-heading { margin-bottom: 24px; }
.panel-heading h2, .results-toolbar h2 { font-size: 1.35rem; }
.frequency-card { margin: 0 -11px; padding: 14px 10px 16px; border: 1px solid var(--line-bright); border-radius: 4px; background: linear-gradient(150deg, rgba(3, 13, 23, .8), rgba(8, 26, 39, .66)); box-shadow: inset 0 1px 0 rgba(123, 231, 239, .06); }
.frequency-card > .field-label { margin: 0 0 10px; }
.field-label, .sort-control { display: block; color: #b9cdd2; font-size: .87rem; font-weight: 650; }
.field-label { margin: 19px 0 8px; }
.field-help { margin: 7px 0 0; color: var(--faint); font-size: .78rem; line-height: 1.45; }
.frequency-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "input add" "help clear"; align-items: center; gap: 5px 8px; }
.frequency-entry input { grid-area: input; min-width: 0; }
.frequency-entry .frequency-help { grid-area: help; margin: 0; align-self: center; white-space: nowrap; font-size: .75rem; letter-spacing: -.01em; transform: translateY(3px); pointer-events: none; }
.frequency-help-compact { display: none; }
.search-input { display: flex; align-items: center; gap: 8px; }
.frequency-entry input, .search-input, input[type="number"], select {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #07111c;
  outline: none;
}
.frequency-entry input, input[type="number"] { padding: 0 12px; }
.frequency-entry input:focus, .search-input:focus-within, input[type="number"]:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(43, 216, 230, .1); }
.frequency-entry .add-button {
  grid-area: add;
  min-height: 43px;
  border: 0;
  border-radius: 4px;
  padding: 0 16px;
  color: #021014;
  font-weight: 750;
  background: var(--cyan);
}
.frequency-entry .clear-button { grid-area: clear; position: relative; z-index: 1; min-height: 44px; min-width: 72px; padding: 0 10px; border: 1px solid var(--line-bright); border-radius: 4px; color: var(--cyan-soft); background: rgba(7, 17, 28, .72); font-size: .85rem; touch-action: manipulation; }
.frequency-entry .clear-button:hover { color: #fff; border-color: var(--cyan); }

@media (max-width: 440px) {
  .frequency-help-full { display: none; }
  .frequency-help-compact { display: inline; }
}
.search-input { padding: 0 10px; }
.search-input span { color: var(--cyan); font-size: 1.25rem; }
.search-input input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; min-height: 41px; }

.frequency-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; min-height: 0; }
.frequency-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 8px 6px 10px; border: 1px solid #286677; border-radius: 4px; color: #d8fbfd; background: rgba(43, 216, 230, .1); font-size: .84rem; }
.frequency-chip button { border: 0; padding: 0; color: var(--muted); background: none; line-height: 1; }
.range-row { margin: 20px 0 7px; display: flex; justify-content: space-between; gap: 16px; color: #b9cdd2; font-size: .84rem; font-weight: 650; }
.range-row output { color: var(--cyan-soft); font-variant-numeric: tabular-nums; }
.range { width: 100%; height: 6px; appearance: none; border-radius: 2px; background: linear-gradient(90deg, var(--cyan), #163646); }
.range::-webkit-slider-thumb { appearance: none; width: 17px; height: 17px; border: 3px solid #06202a; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 1px var(--cyan); }
.heat-range { background: linear-gradient(90deg, #426ccc, #12bddd 25%, #42d76e 50%, #ffcf52 75%, #f1432f); }
.color-scale { display: flex; justify-content: space-between; gap: 4px; margin-top: 8px; color: var(--muted); font-size: .75rem; }

.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
.filter-grid > * { min-width: 0; }
.filter-grid select { padding: 0 10px; }
.rpm-tolerance { margin-top: 17px; }
.advanced-filters { margin-top: 18px; }
.advanced-filters > summary { display: none; color: var(--cyan-soft); font-size: .88rem; font-weight: 700; cursor: pointer; }
.advanced-body .filter-grid { margin-top: 0; }

.results-toolbar { border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.results-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; }
.sort-control { display: flex; align-items: center; gap: 10px; }
.sort-control select { width: auto; min-width: 190px; padding: 0 10px; }
.results-controls .sort-control:first-child select { min-width: 78px; }
.results-progress { margin-top: 16px; color: var(--muted); font-size: .87rem; }
.results-progress:empty, .results-sentinel[hidden] { display: none; }
.results-sentinel { height: 1px; }
.active-query { margin: 14px 0 18px; min-height: 22px; color: var(--muted); font-size: .88rem; }
.results { display: grid; gap: 14px; }

.contact-card { border: 1px solid var(--line); border-radius: 5px; background: rgba(4, 13, 23, .84); overflow: hidden; transition: border-color .18s ease, transform .18s ease; }
.contact-card:hover { border-color: #285568; transform: translateY(-1px); }
.card-main { padding: 18px; }
.card-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.card-title { margin: 0; color: #f2fbfc; font-size: clamp(1.08rem, 1.7vw, 1.32rem); line-height: 1.25; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0 0; }
.badge { padding: 4px 7px; border-radius: 3px; color: #a9c2ca; background: #102431; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge.cyan { color: #bdf7fa; background: rgba(43, 216, 230, .12); }
.badge.missing { color: #ffd39a; background: rgba(255, 181, 71, .12); }
.match-score { flex: 0 0 auto; min-width: 72px; text-align: right; }
.match-score strong { display: block; color: var(--cyan-soft); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.match-score span { color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.description { margin: 14px 0; color: #a9bdc3; line-height: 1.5; font-size: .9rem; }

.vessel-overview { display: grid; grid-template-columns: minmax(190px, 28%) minmax(0, 1fr); gap: 16px; align-items: stretch; margin-top: 14px; }
.overview-details { min-width: 0; }
.overview-details .description { margin-top: 0; }
.identification-button { min-height: 172px; padding: 0; overflow: hidden; display: grid; grid-template-rows: 1fr auto; border: 1px solid #214657; border-radius: 4px; color: var(--ink); background: #f7f7f5; text-align: left; }
.identification-button:hover { border-color: var(--cyan); }
.identification-button img { width: 100%; height: 132px; display: block; object-fit: contain; background: #fff; }
.identification-button picture, .lofar-probe picture { display: block; }
.identification-button > span { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: #0a1926; }
.identification-button b { color: var(--cyan-soft); font-size: .76rem; }
.identification-button small { color: var(--muted); font-size: .7rem; }

.signature { display: grid; gap: 8px; margin: 13px 0 15px; padding: 12px; border: 1px solid #173342; border-radius: 4px; background: #07131f; }
.signature-row { display: grid; grid-template-columns: 64px minmax(70px, 1fr) 98px; gap: 10px; align-items: center; font-size: .8rem; }
.signature-row strong { color: #dff9fa; font-variant-numeric: tabular-nums; }
.signal-track { height: 7px; overflow: hidden; border-radius: 2px; background: #102336; }
.signal-fill { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, #1b51a4, #27d7e4 48%, #ffd052 77%, #ed4437); }
.signature-meta { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.fact { min-height: 64px; padding: 10px; border-radius: 4px; background: #0b1b28; }
.fact span { display: block; color: var(--faint); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.fact strong { display: block; margin-top: 5px; color: #dcecef; font-size: .88rem; line-height: 1.25; }
.shaft-line { margin: 12px 0 0; color: #9ab2b9; font-size: .85rem; }
.shaft-line b { color: var(--amber); font-weight: 650; }

.lofar-view { margin-top: 14px; border: 1px solid #214657; border-radius: 4px; overflow: hidden; background: #081427; }
.lofar-button { display: block; width: 100%; padding: 0; border: 0; background: #081427; text-align: left; }
.lofar-button img { width: 100%; height: auto; display: block; image-rendering: auto; }
.lofar-probe { display: block; position: relative; width: 100%; padding: 0; border: 0; cursor: crosshair; }
.lofar-cursor { display: none; position: absolute; top: 0; bottom: 0; width: 1px; background: #f0ffff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .5); pointer-events: none; }
.lofar-frequency-tooltip { display: none; position: absolute; top: 6px; transform: translateX(-50%); padding: 4px 7px; border: 1px solid #397788; border-radius: 3px; color: #d8fcff; background: rgba(3, 12, 19, .96); font-size: .875rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.is-probing .lofar-cursor, .is-probing .lofar-frequency-tooltip { display: block; }
.lofar-caption { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; padding: 7px 10px; color: var(--muted); font-size: .76rem; }
.lofar-caption b { color: var(--cyan-soft); }
.lofar-switch { padding: 0; border: 0; color: var(--cyan-soft); background: transparent; font-size: inherit; font-weight: 700; text-align: left; text-decoration: underline; text-underline-offset: 2px; }
.lofar-switch:hover { color: #fff; }
.lofar-switch:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.dossier { border-top: 1px solid var(--line); }
.dossier summary { padding: 12px 18px; color: var(--cyan-soft); cursor: pointer; font-size: .84rem; font-weight: 650; }
.dossier-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 4px 18px 18px; }
.dossier h4 { margin: 8px 0; color: var(--amber); font-size: .75rem; letter-spacing: .09em; text-transform: uppercase; }
.dossier pre { margin: 0; color: #a6bbc1; font: 400 .78rem/1.45 "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif; white-space: pre-wrap; }

.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 18px 0 6px; color: var(--ink); }
.empty-state p { max-width: 520px; margin: 0 auto; line-height: 1.55; }
.empty-radar { width: 76px; height: 76px; margin: 0 auto; border: 1px solid var(--line-bright); border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 11px, rgba(43, 216, 230, .16) 12px 13px); }

.lofar-dialog { width: min(1120px, calc(100% - 32px)); padding: 0; border: 1px solid var(--line-bright); border-radius: 6px; color: var(--ink); background: #07111d; box-shadow: 0 30px 100px #000; }
.lofar-dialog::backdrop { background: rgba(0, 4, 9, .82); backdrop-filter: blur(5px); }
.dialog-bar { padding: 17px 20px; border-bottom: 1px solid var(--line); }
.dialog-bar h2 { font-size: 1.2rem; }
.close-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #0d1d2a; font-size: 1.5rem; }
.lofar-dialog img { width: calc(100% - 40px); height: auto; margin: 0 20px 16px; display: block; border: 1px solid #1b4659; image-rendering: auto; }
.dialog-probe { margin: 0 20px 16px; outline: 1px solid #1b4659; }
.lofar-dialog .dialog-probe img { width: 100%; height: auto; margin: 0; border: 0; }
.identification-dialog img { max-height: calc(100vh - 190px); margin-top: 20px; object-fit: contain; background: #fff; }
.frequency-axis { position: relative; height: 38px; margin: 0 20px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.frequency-axis > span { position: absolute; bottom: 7px; white-space: nowrap; }
.dialog-meta { margin: 0; padding: 0 20px 20px; color: var(--faint); font-size: .8rem; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .filters { position: static; max-height: none; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .advanced-filters { border: 1px solid var(--line); border-radius: 4px; background: #07111c; }
  .advanced-filters > summary { display: block; padding: 12px; }
  .advanced-body { padding: 0 12px 14px; }
}

@media (max-width: 620px) {
  body::after {
    background:
      linear-gradient(rgba(20, 59, 74, .08) 1px, transparent 1px),
      linear-gradient(90deg, rgba(20, 59, 74, .08) 1px, transparent 1px),
      linear-gradient(rgba(1, 7, 13, .68), rgba(1, 7, 13, .72));
    background-size: 34px 34px, 34px 34px, auto;
  }
  .topbar {
    min-height: 96px;
    padding: 14px 16px;
    background-position: center, center, 70% 64%;
  }
  .brand-mark { width: 42px; height: 42px; }
  .workspace { padding: 14px 10px 40px; gap: 14px; }
  .filters, .results-panel { border-radius: 5px; padding: 16px; }
  .filter-grid, .dossier-grid { grid-template-columns: 1fr; }
  .results-toolbar, .card-head { align-items: start; }
  .results-toolbar { flex-direction: column; }
  .sort-control { width: 100%; justify-content: space-between; }
  .sort-control select { min-width: 0; flex: 1; }
  .results-controls { width: 100%; }
  .results-controls .sort-control:first-child select { flex: 1; min-width: 0; }
  .facts { grid-template-columns: 1fr 1fr; }
  .vessel-overview { grid-template-columns: 1fr; }
  .identification-button { min-height: 0; }
  .identification-button img { height: auto; max-height: 230px; }
  .signature-row { grid-template-columns: 54px 1fr; }
  .signature-meta { grid-column: 2; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
