/* ============ VesselTwin themes: token sets only, zero theme-conditional markup ============ */
:root[data-theme="glacier"] {
  --bg: #FBFBF9;
  --surface: #FFFFFF;
  --border: #E7E5E0;
  --grid-line: #EFEDE8;
  --ink: #16181D;
  --muted: #8A8F98;
  --ballast: #2563EB;
  --laden: #EA580C;
  --ballast-2: #2563EB;
  --laden-2: #EA580C;
  --success: #15803D;
  --amber: #B45309;
  --danger: #B91C1C;
  --chip-bg: #F4F3F0;
  --chip-hover: #ECEAE5;
  --radius: 99px;
  --radius-card: 14px;
  --shadow: 0 1px 2px rgba(22,24,29,.04), 0 4px 16px rgba(22,24,29,.04);
  --chrome-bg: #16181D;
  --chrome-ink: #FFFFFF;
  --scatter-opacity: .38;
  --band-opacity: .10;
  --font-display: "Inter Tight", Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;
}
:root[data-theme="aurora"] {
  --bg: #0F1117;
  --surface: #1A1D27;
  --border: #262A36;
  --grid-line: #171B25;
  --ink: #F4F4F5;
  --muted: #A1A1AA;
  --ballast: #2DD4BF;
  --ballast-2: #818CF8;
  --laden: #F472B6;
  --laden-2: #FB923C;
  --success: #34D399;
  --amber: #FBBF24;
  --danger: #F87171;
  --chip-bg: #232734;
  --chip-hover: #2B3040;
  --radius: 10px;
  --radius-card: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 32px rgba(0,0,0,.25);
  --chrome-bg: #0B0D12;
  --chrome-ink: #F4F4F5;
  --scatter-opacity: .45;
  --band-opacity: .14;
  --font-display: Inter, "Inter Tight", system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  transition: background .18s ease, color .18s ease;
}
kbd {
  font: 500 10.5px var(--font-body);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--muted);
  background: var(--surface);
}
.num, select {
  font: 500 12.5px var(--font-body);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--chip-bg);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 3px 7px;
  width: 64px;
}
.num:focus, select:focus { outline: none; border-color: var(--ballast); background: var(--surface); }
select { width: auto; cursor: pointer; }

/* ============ chrome ============ */
.chrome {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--chrome-bg); color: var(--chrome-ink);
  padding: 0 20px; height: 48px;
}
.chrome-left { display: flex; align-items: center; gap: 14px; }
.wordmark { font: 600 13px var(--font-display); letter-spacing: .22em; }
.divider { width: 1px; height: 18px; background: rgba(255,255,255,.25); }
.apptitle { font: 500 13px var(--font-display); opacity: .85; }
.chrome-right { display: flex; align-items: center; gap: 10px; }
.version-chip {
  font: 500 11px var(--font-body); font-variant-numeric: tabular-nums;
  border: 1px solid rgba(255,255,255,.28); border-radius: 99px;
  padding: 2.5px 10px; opacity: .9;
}
.icon-btn {
  display: grid; place-items: center; width: 30px; height: 30px;
  background: transparent; color: var(--chrome-ink);
  border: 1px solid rgba(255,255,255,.22); border-radius: 99px; cursor: pointer;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }

/* ============ layout ============ */
.layout {
  display: grid; grid-template-columns: 320px 1fr; gap: 16px;
  padding: 16px 20px; max-width: 1480px; margin: 0 auto;
  min-height: calc(100vh - 48px);
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
.panel { min-width: 0; }
.side { display: flex; flex-direction: column; gap: 12px; }

/* ============ search ============ */
.search-wrap { position: relative; }
.mode-toggle {
  display: inline-flex; background: var(--chip-bg); border-radius: var(--radius);
  padding: 3px; margin-bottom: 8px;
}
.mode-btn {
  font: 500 12px var(--font-body); color: var(--muted);
  background: transparent; border: none; border-radius: var(--radius);
  padding: 4px 14px; cursor: pointer; transition: all .15s;
}
.mode-btn.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 14px;
  box-shadow: var(--shadow); transition: border-color .15s;
}
.search-box:focus-within { border-color: var(--ballast); }
.search-ico { color: var(--muted); flex: none; }
#search {
  flex: 1; border: none; outline: none; background: transparent;
  font: 500 13.5px var(--font-body); color: var(--ink); min-width: 0;
}
#search::placeholder { color: var(--muted); }
.typeahead {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow); overflow: hidden;
  max-height: 380px; overflow-y: auto;
}
.ta-section { font: 600 10px var(--font-body); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 8px 14px 3px; }
.ta-item {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 7px 14px; cursor: pointer;
}
.ta-item.sel, .ta-item:hover { background: var(--chip-bg); }
.ta-name { font-weight: 500; }
.ta-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.recents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.recent-chip {
  font: 500 11.5px var(--font-body); color: var(--muted);
  background: var(--chip-bg); border: none; border-radius: var(--radius);
  padding: 4px 12px; cursor: pointer; transition: all .15s;
}
.recent-chip:hover { background: var(--chip-hover); color: var(--ink); }

/* ============ entity card ============ */
.entity-card, .inputs, .confidence {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); padding: 14px 16px; box-shadow: var(--shadow);
}
.entity-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.entity-name { font: 600 15px var(--font-display); }
.entity-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.class-chip {
  font: 600 10.5px var(--font-body); letter-spacing: .04em;
  background: var(--chip-bg); border-radius: var(--radius);
  padding: 3px 10px; white-space: nowrap;
}
.particulars {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 10px; margin-top: 12px;
}
.particulars > div { min-width: 0; }
.particulars dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.particulars dd { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.year-picker { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
.year-chip {
  font: 500 11.5px var(--font-body); font-variant-numeric: tabular-nums;
  background: var(--chip-bg); border: 1px solid transparent; border-radius: var(--radius);
  padding: 3px 10px; cursor: pointer; color: var(--muted);
}
.year-chip.active { border-color: var(--ballast); color: var(--ink); background: var(--surface); }
.year-chip small { opacity: .65; margin-left: 3px; }

/* ============ inputs ============ */
.inputs { display: flex; flex-direction: column; gap: 16px; }
.group-label {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  font: 600 10.5px var(--font-body); letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
}
.unit { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: -2px; }
.seg { display: flex; background: var(--chip-bg); border-radius: var(--radius); padding: 3px; margin-top: 6px; }
.seg button {
  flex: 1; font: 500 12px var(--font-body); color: var(--muted);
  background: transparent; border: none; border-radius: var(--radius);
  padding: 5px 0; cursor: pointer; transition: all .15s;
}
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.seg.small button { font-size: 11px; padding: 4px 0; }
.slider-wrap { position: relative; margin-top: 8px; padding: 0 2px; }
input[type="range"] {
  width: 100%; appearance: none; height: 3px; border-radius: 2px;
  background: var(--grid-line); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ballast);
  box-shadow: var(--shadow); cursor: grab;
}
.slider-tick {
  position: absolute; top: -3px; width: 2px; height: 9px;
  background: var(--muted); border-radius: 1px; pointer-events: none;
}
.slider-tick.today { background: var(--success); }
.hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.chip-btn {
  font: 500 12px var(--font-body); color: var(--ink);
  background: var(--chip-bg); border: none; border-radius: var(--radius);
  padding: 5.5px 14px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chip-btn:hover { background: var(--chip-hover); }
.chip-btn.active { background: var(--ink); color: var(--bg); }
.weather-panel { display: flex; flex-direction: column; gap: 10px; }
.esd-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.esd-chip {
  font: 500 11.5px var(--font-body); color: var(--muted);
  background: var(--chip-bg); border: 1px solid transparent; border-radius: var(--radius);
  padding: 4px 12px; cursor: pointer; transition: all .15s;
}
.esd-chip.active { border-color: var(--success); color: var(--ink); background: var(--surface); }
.esd-chip small { opacity: .6; margin-left: 4px; }
.curve.sim { stroke-dasharray: 2 5; stroke-width: 2; opacity: .9; }
.input-row { display: flex; gap: 14px; align-items: center; }
.input-row label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* ============ confidence ============ */
.conf-head { display: flex; justify-content: space-between; align-items: center; }
.conf-chip {
  font: 600 10.5px var(--font-body); letter-spacing: .05em; text-transform: uppercase;
  border-radius: var(--radius); padding: 3px 11px;
}
.conf-chip.green { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.conf-chip.amber { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }
.conf-chip.red { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.conf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin: 12px 0; }
.conf-item dt { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.conf-item dd { font-size: 12.5px; font-weight: 500; font-variant-numeric: tabular-nums; }
.conf-item dd .flag { color: var(--amber); font-size: 10.5px; margin-left: 4px; }

/* ============ chart column ============ */
.chart-col { display: flex; flex-direction: column; gap: 12px; }
.view-tabs { display: inline-flex; background: var(--chip-bg); border-radius: var(--radius); padding: 3px; align-self: flex-start; }
.view-tab {
  font: 600 12.5px var(--font-body); color: var(--muted);
  background: transparent; border: none; border-radius: var(--radius);
  padding: 6px 20px; cursor: pointer; transition: all .15s;
}
.view-tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.sim-bar {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 22px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 14px 18px;
}
.sim-group { display: flex; flex-direction: column; gap: 7px; }
.sim-group .seg { margin-top: 0; }
.sim-grow { flex: 1; min-width: 220px; }
.sim-group .num { width: 72px; }
.sim-readout { flex-basis: 100%; display: flex; flex-direction: column; gap: 3px;
  border-top: 1px solid var(--grid-line); padding-top: 10px; }
.sim-readout .hint:empty { display: none; }
.sim-readout #simHint { color: var(--ink); font-weight: 500; }
.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; color: var(--muted); min-height: 420px;
  border: 1px dashed var(--border); border-radius: var(--radius-card);
}
.empty-art { font-size: 42px; opacity: .4; }
.empty-state h2 { font: 600 17px var(--font-display); color: var(--ink); }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.chart-title-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chart-title { font: 600 19px var(--font-display); letter-spacing: -.01em; }
.served-badges { display: flex; gap: 5px; }
.served-badge {
  font: 600 10px var(--font-body); letter-spacing: .05em; text-transform: uppercase;
  border-radius: var(--radius); padding: 3px 9px;
  background: var(--chip-bg); color: var(--muted);
}
.served-badge.vessel { color: var(--success); background: color-mix(in srgb, var(--success) 12%, transparent); }
.served-badge.design, .served-badge.design_year { color: var(--ballast); background: color-mix(in srgb, var(--ballast) 12%, transparent); }
.served-badge.class { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.chart-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chart-wrap {
  position: relative; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card);
  box-shadow: var(--shadow); padding: 10px;
}
#chart { display: block; width: 100%; height: auto; }
.chart-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--muted); text-align: center; padding: 24px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}
.crosshair-readout {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow); padding: 7px 11px;
  font-size: 11.5px; font-variant-numeric: tabular-nums; line-height: 1.5; white-space: nowrap;
}
.readout-row { display: flex; gap: 8px; align-items: center; }
.readout-dot { width: 7px; height: 7px; border-radius: 50%; }
.pin-delta {
  position: absolute; top: 14px; right: 16px; z-index: 4;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow); padding: 7px 11px; font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
.pin-delta b { font-size: 13px; }

/* ============ CP check ============ */
.cp-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; font-size: 12px; }
.cp-cond {
  font: 600 10px var(--font-body); letter-spacing: .04em; border-radius: var(--radius);
  padding: 2.5px 9px; color: var(--surface); flex: none; width: 58px; text-align: center;
}
.cp-cond.ballast { background: var(--ballast); }
.cp-cond.laden { background: var(--laden); }
.cp-row .num { width: 58px; }
.cp-x {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; padding: 0 4px;
}
.cp-x:hover { color: var(--danger); }
.cp-verdict { display: flex; align-items: baseline; gap: 7px; font-size: 11.5px; margin: 3px 0; }
.cp-verdict .v-chip {
  font: 600 9.5px var(--font-body); letter-spacing: .04em; border-radius: var(--radius);
  padding: 2px 8px; flex: none;
}
.v-chip.fair { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.v-chip.margin { background: color-mix(in srgb, var(--ballast) 14%, transparent); color: var(--ballast); }
.v-chip.risk { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.cp-mark { stroke-width: 1.5; }

/* ============ sister vessels ============ */
.sister-list { max-height: 200px; overflow-y: auto; margin-top: 6px; }
.sister-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 3.5px 2px; font-size: 12px; border-bottom: 1px solid var(--grid-line);
}
.sister-row:last-child { border-bottom: none; }
.sister-name { font-weight: 500; cursor: pointer; }
.sister-name:hover { color: var(--ballast); }
.sister-meta { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sister-add {
  font: 600 13px var(--font-body); background: var(--chip-bg); color: var(--muted);
  border: none; border-radius: var(--radius); width: 22px; height: 22px; cursor: pointer;
  flex: none; line-height: 1;
}
.sister-add:hover { background: var(--chip-hover); color: var(--ink); }
.sister-add.in { color: var(--success); }

/* ============ compare ============ */
.search-box.small { padding: 6px 12px; margin-top: 6px; }
.search-box.small input { flex: 1; border: none; outline: none; background: transparent;
  font: 500 12.5px var(--font-body); color: var(--ink); min-width: 0; }
.cmp-group { position: relative; }
.cmp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.cmp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 11.5px var(--font-body); border-radius: var(--radius);
  padding: 3.5px 6px 3.5px 12px; background: var(--chip-bg); color: var(--ink);
}
.cmp-chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cmp-chip button { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0 3px; }
.cmp-chip button:hover { color: var(--danger); }
.cmp-table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 12px; margin-top: 6px; }
.cmp-table th, .cmp-table td { padding: 4px 14px 4px 0; text-align: right; white-space: nowrap; }
.cmp-table th { font: 600 10px var(--font-body); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cmp-table td:first-child, .cmp-table th:first-child { text-align: left; }
.cmp-table .delta { color: var(--muted); font-size: 11px; }
.cmp-table .delta.pos { color: var(--danger); }
.cmp-table .delta.neg { color: var(--success); }

/* ============ aging mini-plot ============ */
.aging-headline { font-size: 12px; margin-top: 6px; }
.aging-headline b { font-variant-numeric: tabular-nums; }
#agingSlopes .muted { color: var(--muted); font-size: 10.5px; }
.slope-tbl { border-collapse: collapse; margin-top: 3px; font-variant-numeric: tabular-nums; }
.slope-tbl td { padding: 1px 12px 1px 0; font-size: 11px; }
.slope-tbl td.pos { color: var(--danger); }
.slope-tbl td.neg { color: var(--success); }

/* ============ chart legend ============ */
.chart-legend { display: flex; gap: 16px; font-size: 11px; color: var(--muted); padding: 0 4px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 18px; height: 0; border-top: 2px solid var(--muted); display: inline-block; }
.legend-item i.dash { border-top-style: dashed; }
.legend-item i.faded { opacity: .45; border-top-style: dashed; }
.legend-item i.band { height: 8px; border: none; background: var(--muted); opacity: .2; }

/* ============ hull strip ============ */
.hull-strip {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 12px 16px;
}
.hull-timeline { position: relative; height: 54px; margin-top: 8px; }
.hull-axis { position: absolute; left: 0; right: 0; top: 26px; height: 1px; background: var(--grid-line); }
.hull-ev {
  position: absolute; top: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: default;
}
.hull-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.hull-dot.drydock { background: var(--danger); }
.hull-dot.hull_cleaning { background: var(--ballast); }
.hull-dot.prop_polish { background: var(--success); }
.hull-dot.inspection { background: var(--muted); }
.hull-lbl { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.hull-year { position: absolute; top: 0; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hull-legend { display: flex; gap: 12px; margin-top: 6px; font-size: 10.5px; color: var(--muted); }
.hull-legend span { display: inline-flex; align-items: center; gap: 4px; }
.hull-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ============ toast ============ */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--ink); color: var(--bg); border-radius: var(--radius);
  padding: 8px 18px; font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow); animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* chart internals (SVG classes) */
.axis-lbl { font: 500 10.5px var(--font-body); fill: var(--muted); font-variant-numeric: tabular-nums; }
.axis-title { font: 600 10px var(--font-body); fill: var(--muted); letter-spacing: .07em; text-transform: uppercase; }
.gridline { stroke: var(--grid-line); stroke-width: 1; }
.gridline.minor { opacity: .45; }
.curve { fill: none; stroke-width: 2.25; stroke-linecap: round; }
.curve.pinned { stroke-dasharray: 5 4; opacity: .55; stroke-width: 1.8; }
.curve.weather { stroke-dasharray: 7 5; opacity: .8; stroke-width: 1.8; }
.band { opacity: var(--band-opacity); }
.band.emp { opacity: calc(var(--band-opacity) * .7); }
.scatter-pt { opacity: var(--scatter-opacity); }
.vis-anchor { stroke-width: 1.5; fill: none; }
.crosshair-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; }

@media (prefers-reduced-motion: no-preference) {
  .curve.animate { stroke-dasharray: 2400; stroke-dashoffset: 2400; animation: draw .4s ease-out forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}
