:root {
  --navy: #1c2e44;
  --navy-deep: #132234;
  --ink: #223247;
  --muted: #56687c;
  --teal: #0f6f66;
  --blue: #155e9b;
  --sienna: #b2582e;
  --violet: #6d3fa0;
  --line: #cad4df;
  --surface: #e9eef3;
  --white: #ffffff;
  --sidebar-width: 232px;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--surface);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; border-radius: 3px; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid #1976c2;
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: #f3f6f9;
  border-right: 1px solid #b9c5d3;
  overflow-y: auto;
}
.brand {
  height: 46px;
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  color: #fff;
  background: var(--navy);
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.5px;
  border-bottom: 1px solid var(--navy-deep);
}
.brand-light { font-weight: 400; color: #7ce2d4; }
.explorer-title {
  background: #e6ecf2;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 650;
  color: #3f5169;
}
.upload-box { padding: 10px; border-bottom: 1px solid var(--line); }
.upload-zone {
  position: relative;
  display: grid;
  grid-template-columns: 23px 1fr;
  gap: 3px 8px;
  padding: 10px;
  border: 1px dashed #9fb2c7;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--teal); background: #ecf8f6; }
.upload-zone svg { grid-row: span 2; width: 22px; height: 22px; stroke: var(--teal); fill: none; stroke-width: 1.7; }
.upload-zone strong { font-size: 12px; font-weight: 600; }
.upload-zone span { font: 10px var(--mono); color: var(--muted); }
.upload-zone small { grid-column: 1/-1; font-size: 10px; color: var(--muted); margin-top: 2px; }
.upload-zone input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
.upload-zone:focus-within { outline: 2px solid #1976c2; }

.delimiter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  font-size: 10px;
  color: var(--muted);
}
.delimiter-row select { width: 100%; font-size: 11px; padding: 5px 6px; }

.source-group { border-bottom: 1px solid var(--line); }
.source-group > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  background: #e6ecf2;
  color: #3f5169;
  list-style: none;
}
.count-pill { font: 10px var(--mono); padding: 1px 6px; background: #d5e0ec; border-radius: 2px; color: #2d4968; }
.source-list { padding: 4px 0; }
.source-button {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: none;
  color: var(--ink);
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 8px 10px 8px 14px;
  line-height: 1.35;
}
.source-button strong { font-size: 11px; font-weight: 550; }
.source-button small { font-size: 10px; color: var(--muted); }
.source-button:hover { background: #e6edf5; }
.source-button.active { background: #daf0ed; border-left-color: var(--teal); }
.source-button.active strong { color: #0b514a; font-weight: 650; }

.run-browser { display: flex; flex-direction: column; min-height: 110px; flex: 1; }
.run-browser h2 {
  font-size: 11px;
  font-weight: 600;
  padding: 9px 12px;
  background: #e6ecf2;
  border-bottom: 1px solid var(--line);
}
#series-browser { overflow-y: auto; max-height: 36vh; padding: 4px 0; }
#series-browser > .quiet { padding: 0 12px; }
.run-entry {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px 8px 14px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
}
.run-entry strong { display: block; font-size: 10px; font-weight: 500; line-height: 1.5; overflow-wrap: anywhere; }
.run-entry small { display: block; font: 9px var(--mono); margin-top: 2px; color: var(--muted); }
.run-entry:hover { background: #e6edf5; }
.run-entry[aria-pressed="true"] { background: #dff1ef; border-left-color: var(--teal); color: #0c4d46; }
.run-entry[aria-pressed="true"] strong { font-weight: 650; }

.side-bottom {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: #506379;
  background: #ecf0f5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
}
.side-bottom p { width: 100%; margin: 0; font-size: 9px; line-height: 1.45; }
.version { font: 9px var(--mono); }
.local-indicator { display: inline-flex; align-items: center; gap: 5px; }
.local-indicator:before { content: ""; width: 6px; height: 6px; background: #1e876b; border-radius: 50%; }

main { margin-left: var(--sidebar-width); min-width: 0; }
.topbar {
  min-height: 46px;
  height: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 6px 14px;
  background: var(--navy);
  color: #e6edf5;
  border-bottom: 1px solid var(--navy-deep);
}
h1 { font-size: 13px; font-weight: 500; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
h2 { font-size: 13px; font-weight: 600; line-height: 1.45; margin: 0; }

.project-toolbar { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.project-open { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.project-open input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
body.mode-v04 .top-actions { margin-left: auto; }

.lang-switch { display: inline-flex; border: 1px solid #4e647f; border-radius: 3px; overflow: hidden; }
.lang-btn {
  border: 0;
  border-radius: 0;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 600;
  background: #253b54;
  color: #c7d6e8;
}
.lang-btn[aria-pressed="true"] { background: #7ce2d4; color: #122738; }

.primary-button, .small-button {
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
  border: 1px solid #b5c3d2;
}
.primary-button { background: var(--teal); border-color: #0b5a52; color: #fff; font-weight: 550; }
.primary-button:hover { background: #0b5851; }
.primary-button .arrow { margin-left: 6px; }
.small-button { background: #f8fbfd; color: #2f4b68; }
.small-button:hover { border-color: #6d94b8; background: #e8f1fa; }
.text-button { background: none; border: 0; color: #2f5b82; padding: 6px 3px; font-size: 11px; }
.text-button:hover { color: #143a61; text-decoration: underline; }
.topbar .text-button { color: #e2edf8; }
.topbar .small-button { color: #e2edf8; background: #293f5a; border-color: #4f6580; }
.topbar .primary-button { background: #d6f2ee; border-color: #d6f2ee; color: #133836; }
.topbar .primary-button:hover { background: #ffffff; }

.workspace { padding: 0 12px 14px; max-width: 1920px; margin: auto; }
#status { margin: 8px 0; font-size: 11px; line-height: 1.55; color: var(--muted); }
#status:empty { display: none; }
#status.error { background: #fff0e9; border: 1px solid #ecc6b2; padding: 9px 11px; color: #8a3a18; border-radius: 3px; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 3px; }
.selection-row { display: flex; align-items: center; gap: 16px; padding: 9px 12px; }
.series-field { flex: 1; min-width: 120px; }
.series-field > label, .condition > span {
  display: block;
  font-size: 9px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .3px;
  margin-bottom: 3px;
}
.series-field select { width: 100%; border: 0; padding: 0 14px 0 0; min-height: 20px; font-size: 11px; font-weight: 600; background: #fff; }
.condition { border-left: 1px solid #dce3eb; padding-left: 13px; flex-shrink: 0; }
.condition strong { font: 11px var(--mono); }

.run-heading { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 10px 2px 8px; }
.run-heading > div { min-width: 0; }
.run-heading strong { font-size: 12px; font-weight: 600; }
.run-heading p { margin: 3px 0 0; font-size: 10px; color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.run-kind {
  font: 10px var(--mono);
  color: #14534d;
  background: #daf0ed;
  border: 1px solid #b5ded8;
  padding: 2px 7px;
  border-radius: 2px;
  white-space: nowrap;
}

.analysis-overview { display: grid; grid-template-columns: minmax(0,1fr) 252px; gap: 9px; align-items: start; }
.chart-panel { padding: 0; display: flex; flex-direction: column; min-width: 0; }
.chart-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #f5f7fa;
}
.chart-heading p { margin: 3px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.chart-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 11px; }

.view-pills { display: inline-flex; border: 1px solid #bac8d8; border-radius: 3px; overflow: hidden; }
.pill-btn {
  border: 0;
  border-right: 1px solid #bac8d8;
  border-radius: 0;
  background: #fff;
  color: #465d75;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 550;
}
.pill-btn:last-child { border-right: 0; }
.pill-btn[aria-pressed="true"] { background: var(--navy); color: #fff; }

.toggle-check { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; font-size: 10px; }
.toggle-check input { accent-color: var(--teal); margin: 0; }
.toggle-check i { height: 2px; width: 12px; display: inline-block; }
.swatch-raw { background: #8c9eb0; }
.swatch-base { background: var(--sienna); }
.swatch-peak { background: var(--blue); }

#chart-wrapper { position: relative; padding: 6px 8px 2px; }
#chart { display: block; width: 100%; height: auto; overflow: visible; font-family: inherit; min-height: 310px; }

.zoom-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 7px 12px;
  border-top: 1px solid #e1e8ef;
  background: #fafbfd;
  font-size: 10px;
  color: var(--muted);
}
.zoom-bar label { display: inline-flex; align-items: center; gap: 5px; }
.zoom-bar input { width: 78px; padding: 4px 6px; font-size: 10px; }
.zoom-note { margin-left: auto; font-size: 9px; color: #67798d; }

.plot-status {
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  background: #f5f7fa;
  min-height: 29px;
  font: 10px/1.5 var(--mono);
  color: #425970;
  overflow-wrap: anywhere;
}

.result-rail { background: #f9fafc; border: 1px solid var(--line); border-radius: 3px; min-width: 0; }
.rail-heading { background: #e6ecf3; border-bottom: 1px solid var(--line); padding: 9px 11px; font-size: 11px; font-weight: 650; }
.results-heading { border-top: 1px solid var(--line); }
.chart-controls { padding: 10px 11px; display: flex; flex-direction: column; gap: 9px; }
.chart-controls label, .mapping-grid label, .interval-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  color: #4b6077;
}
select, input {
  border: 1px solid #bac8d7;
  background: #fff;
  padding: 6px 8px;
  color: var(--ink);
  font-size: 11px;
  max-width: 100%;
}
input[type="number"] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chart-controls select, .chart-controls input { width: 100%; min-width: 0; }

.sub-controls {
  padding: 8px;
  background: #eef3f8;
  border: 1px solid #d1dce7;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; align-items: end; }
.apply-wrap { display: flex; align-items: flex-end; }
.full-w { width: 100%; }
.align-left { text-align: left; padding-left: 0; }

.metrics { padding: 2px 11px 6px; }
.metric {
  padding: 7px 0;
  border-bottom: 1px solid #dce3eb;
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 6px;
  align-items: baseline;
}
.metric:last-child { border-bottom: 0; }
.metric-label { font-size: 10px; color: #4b6077; }
.metric-value { font: 600 13px var(--mono); color: #193a5c; text-align: right; white-space: nowrap; }
.metric-value span { font-size: 10px; font-weight: 400; color: #54687d; }
.metric-note { grid-column: 1/-1; font-size: 9px; line-height: 1.45; color: #5d7085; margin-top: 2px; }

.details-panel { margin-top: 10px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); background: #e7edf4; overflow-x: auto; }
.tabs button {
  border: 0;
  border-right: 1px solid var(--line);
  border-top: 2px solid transparent;
  border-radius: 0;
  padding: 9px 14px;
  background: none;
  font-size: 11px;
  color: #4f647c;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] {
  background: #fff;
  color: #0e5851;
  border-top-color: var(--teal);
  font-weight: 600;
}
.tabs span[id] {
  font: 9px var(--mono);
  background: #d3e1ef;
  color: #2b4c6e;
  padding: 1px 5px;
  margin-left: 4px;
  border-radius: 2px;
}
.tab-panel { padding: 14px; }

.findings-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.findings-head span { font-size: 10px; color: var(--muted); }
#interpretation { list-style: none; counter-reset: finding; margin: 8px 0 14px; padding: 0; }
#interpretation li {
  position: relative;
  padding: 6px 0 6px 28px;
  font-size: 11px;
  line-height: 1.65;
  color: #3d526a;
  border-bottom: 1px solid #edf0f4;
  counter-increment: finding;
}
#interpretation li:before {
  position: absolute;
  left: 0;
  top: 7px;
  content: counter(finding, decimal-leading-zero);
  font: 9px var(--mono);
  color: var(--teal);
}

.interval-form {
  border: 1px solid #d1dce7;
  background: #f3f6fa;
  padding: 12px;
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  border-radius: 3px;
}
.interval-form > div { flex: 1; min-width: 180px; }
.interval-form strong { font-size: 11px; }
.interval-form small { display: block; color: var(--muted); font-size: 10px; margin-top: 3px; }
.interval-form input { width: 106px; }
.interval-form output { width: 100%; font: 11px/1.6 var(--mono); color: #164f6d; }
.interval-form output:empty { display: none; }

#warnings { margin: 12px 0; padding: 0; list-style: none; }
#warnings li {
  border-left: 3px solid #bd8d38;
  background: #fbf8ef;
  padding: 8px 12px;
  margin-bottom: 7px;
  font-size: 11px;
  line-height: 1.6;
  color: #6b5328;
  overflow-wrap: anywhere;
}

.quiet { font-size: 11px; color: var(--muted); line-height: 1.6; margin: 5px 0 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; max-height: 390px; border: 1px solid var(--line); margin: 10px 0; }
table { border-collapse: collapse; width: 100%; font-size: 11px; font-variant-numeric: tabular-nums; }
th {
  position: sticky;
  top: 0;
  text-align: left;
  background: #eaf0f6;
  color: #415873;
  font-size: 10px;
  font-weight: 600;
}
td, th { border-bottom: 1px solid #dce4ec; border-right: 1px solid #e4e9f0; padding: 6px 9px; white-space: nowrap; }
td:last-child, th:last-child { border-right: 0; }
tr:nth-child(even) { background: #f7f9fc; }
tbody tr:hover { background: #ebf5f4; }
#data-table td, #peaks-table td { font-family: var(--mono); font-size: 10px; }
#peaks-table tbody tr { cursor: pointer; }
#peaks-table tbody tr.selected-peak { background: #d8efec; font-weight: 600; }

dl { display: grid; grid-template-columns: 190px 1fr; gap: 8px 12px; font-size: 11px; line-height: 1.65; }
dt { color: var(--muted); font-weight: 550; }
dd { margin: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 10px; }
dd a { color: var(--blue); }
pre { font: 10px/1.65 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; background: #f1f5f9; padding: 11px; border-radius: 3px; }
summary { cursor: pointer; font-size: 11px; color: #39587a; line-height: 1.55; margin-top: 8px; padding-block: 3px; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  font-size: 9px;
  color: #536881;
  padding: 12px 2px 0;
  line-height: 1.6;
}

.mapping-panel { padding: 16px; margin-top: 10px; }
.mapping-panel p { font-size: 11px; color: var(--muted); line-height: 1.65; }
.mapping-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.mapping-grid .wide { grid-column: span 2; }
.mapping-actions { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
#mapping-file { font: 11px var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.describe-box {
  margin: 10px 0;
  padding: 10px 12px;
  background: #edf6f5;
  border: 1px solid #b6dcd7;
  border-radius: 3px;
  font: 11px/1.6 var(--mono);
  color: #164844;
}

.busy #analysis-surface { opacity: .65; pointer-events: none; }
.analysis-notice {
  margin: 0;
  background: #fff7e6;
  color: #795626;
  border-bottom: 1px solid #e1c99f;
  font-size: 10px;
  line-height: 1.55;
  padding: 8px 12px;
}

/* Biomass Reading DB (SCIE) Controls & Tab Styles */
.kb-controls-box {
  padding: 8px 9px;
  background: #edf4f4;
  border: 1px solid #c2dbd8;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.kb-sub-controls {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.toggle-row {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink) !important;
  font-size: 11px !important;
}
.toggle-row input { width: auto !important; accent-color: var(--teal); margin: 0; }
.compact-toggle { padding-bottom: 5px; font-size: 10px !important; }

.kb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-bottom: 10px;
}
.kb-meta-line {
  margin: 4px 0 0;
  font: 10px/1.5 var(--mono);
  color: #2f5469;
}
.kb-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.kb-scope-banner {
  background: #eef5fb;
  border: 1px solid #c4d8ea;
  border-left: 3px solid var(--blue);
  color: #244563;
  padding: 8px 11px;
  font-size: 11px;
  line-height: 1.55;
  border-radius: 3px;
  margin-bottom: 12px;
}
.kb-section-title {
  font-size: 12px;
  font-weight: 650;
  color: #1f3952;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #dce5ee;
}
.kb-alerts-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.kb-alert {
  padding: 8px 11px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.55;
}
.kb-alert-high {
  background: #fff1ed;
  border: 1px solid #e7bfb4;
  border-left: 3px solid #b53f24;
  color: #6b2413;
}
.kb-alert-medium {
  background: #fdf8ec;
  border: 1px solid #e4cfa2;
  border-left: 3px solid #b9821f;
  color: #654713;
}
.kb-alert-ok {
  background: #ecf7f5;
  border: 1px solid #bde0da;
  border-left: 3px solid var(--teal);
  color: #134c46;
}
.kb-alert-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 650;
  margin-bottom: 3px;
}
.kb-alert-detail {
  font: 10px/1.5 var(--mono);
  margin-top: 3px;
  opacity: .9;
}

.corr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.corr-chip {
  padding: 8px 10px;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: #f8fafc;
  font-size: 10px;
  line-height: 1.5;
}
.corr-corroborated {
  background: #e9f6f4;
  border-color: #9ed4cc;
  border-left: 3px solid var(--teal);
}
.corr-partial {
  background: #fcf8ee;
  border-color: #e4d1a7;
  border-left: 3px solid #b9821f;
}
.corr-none {
  background: #f6f8fa;
  border-color: #d8e0e8;
  color: var(--muted);
}
.corr-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
}
.corr-head strong { font-size: 11px; color: var(--ink); }
.corr-count {
  font: 600 9px var(--mono);
  padding: 1px 5px;
  border-radius: 2px;
  background: #e1e9f1;
  color: #294661;
  white-space: nowrap;
}
.corr-corroborated .corr-count { background: #bfe5df; color: #0c4b44; }
.corr-partial .corr-count { background: #f2dfb2; color: #67470f; }
.corr-wns { font: 9px var(--mono); color: #465d75; margin-bottom: 2px; }

.cand-cell { white-space: normal !important; min-width: 240px; max-width: 460px; }
.caveat-cell { white-space: normal !important; min-width: 190px; max-width: 340px; font-size: 10px; color: #43576d; line-height: 1.45; }
.wrap-cell { white-space: normal !important; }
#kb-indices-table table th, #kb-indices-table table td { padding: 6px 7px; }
#kb-matches-table, #kb-indices-table, #kb-enc-table { max-height: 480px; }
.cand-item {
  padding: 4px 0;
  border-bottom: 1px dashed #dde5ee;
  line-height: 1.45;
}
.cand-item:last-child { border-bottom: 0; padding-bottom: 0; }
.cand-item:first-child { padding-top: 0; }
.cand-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}
.cand-desc { font-size: 10px; color: #42576c; margin-top: 2px; }
.cand-caution { font-size: 9px; color: #7e4b1d; margin-top: 2px; }
.cand-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.kb-badge {
  display: inline-block;
  font: 600 9px var(--mono);
  padding: 1px 5px;
  border-radius: 2px;
  background: #dce9f5;
  color: #1c476e;
  white-space: nowrap;
}
.kb-badge-core { background: #d5efeb; color: #0d5149; }
.kb-badge-margin { background: #efe6d5; color: #6c4b14; }
.kb-badge-cross { background: #e8e1f4; color: #4d2c78; }
.kb-badge-artifact { background: #fbdcd4; color: #8c2712; }
.kb-badge-d2 { background: #e8def5; color: #532c84; }
.kb-badge-peak { background: #d9eaf7; color: #154d7d; }
.kb-badge-rel { background: #d4eee9; color: #0e4e47; }

.doi-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font: 9px var(--mono);
  padding: 1px 5px;
  border-radius: 2px;
  background: #f0f4f8;
  border: 1px solid #cdd9e5;
  color: #155387;
  text-decoration: none;
  white-space: nowrap;
}
.doi-pill:hover { background: #e1edf7; border-color: #84add1; text-decoration: underline; }
.tier-tag {
  font-weight: 700;
  font-size: 8px;
  padding: 0 3px;
  border-radius: 2px;
}
.tier-ft { background: #0f6f66; color: #fff; }
.tier-pmc { background: #1d5fa3; color: #fff; }
.tier-mc { background: #5a728a; color: #fff; }

.emp-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  margin-top: 3px;
  font: 9px var(--mono);
  color: #20495d;
}
.emp-pill {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 2px;
  background: #e5f3f1;
  border: 1px solid #b8ddd7;
  color: #114b45;
  white-space: nowrap;
}
.emp-pill-shift {
  background: #eef3fa;
  border-color: #c2d4e8;
  color: #1f4870;
}
.emp-obs-details {
  margin-top: 4px;
  font-size: 9px;
}
.emp-obs-details summary {
  cursor: pointer;
  color: #1c5882;
  font-weight: 600;
}
.emp-obs-list {
  margin-top: 4px;
  padding: 5px 7px;
  background: #f6f9fc;
  border: 1px solid #d7e2ec;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.emp-obs-row {
  font-size: 9px;
  line-height: 1.4;
  color: #32485e;
  border-bottom: 1px dotted #d7e2ec;
  padding-bottom: 3px;
}
.emp-obs-row:last-child { border-bottom: 0; padding-bottom: 0; }
.audit-box {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 2px solid #e2cfc7;
}
#kb-audit-table { max-height: 400px; }
#kb-audit-table td { vertical-align: top; white-space: normal; }
.audit-claim {
  font-family: var(--mono);
  font-size: 9px;
  color: #7c2614;
  background: #fff3ef;
  padding: 2px 5px;
  border-radius: 2px;
  display: inline-block;
}

.inline-kb-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.inline-kb-btn:hover { text-decoration: underline; }

.trans-guard-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 9px 12px;
  background: #fff5e5;
  border: 1px solid #e4c694;
  border-left: 3px solid #b97518;
  color: #6d4309;
  font-size: 11px;
  border-radius: 3px;
  margin-bottom: 8px;
}
.atr-pill {
  display: inline-block;
  font: 600 9px var(--mono);
  padding: 1px 5px;
  border-radius: 2px;
}
.atr-low { background: #ddf2ee; color: #0e524a; }
.atr-moderate { background: #f8ebcf; color: #6e4a0d; }
.atr-high { background: #fae0d8; color: #8b2a15; }
.row-muted { opacity: .68; }
.companion-line {
  font: 9px var(--mono);
  color: #3f5870;
  margin-top: 3px;
}

.kb-refs-details { margin-top: 12px; }
.kb-refs-list {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ref-item {
  padding: 7px 10px;
  border: 1px solid #dce4ec;
  background: #f9fbfd;
  border-radius: 3px;
  font-size: 10px;
  line-height: 1.5;
}
.ref-excl {
  margin-top: 3px;
  padding: 3px 6px;
  background: #fff5eb;
  border-left: 2px solid #c26525;
  color: #6e3711;
  font-size: 9px;
}

.enc-box {
  margin-top: 18px;
  padding-top: 10px;
  border-top: 2px solid #d2dce7;
}
.enc-title { margin-top: 0; border-bottom: 0; padding-bottom: 0; }
.enc-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(170px, 1fr) minmax(150px, 1fr);
  gap: 8px;
  margin: 10px 0 8px;
}
.enc-toolbar input, .enc-toolbar select { width: 100%; }
#kb-matches-table td, #kb-indices-table td, #kb-enc-table td { vertical-align: top; }
.mono-cell { font-family: var(--mono); font-size: 10px; }

@media (max-width: 1050px) {
  .enc-toolbar { grid-template-columns: 1fr; }
}

@media (min-width: 1450px) {
  :root { --sidebar-width: 248px; }
  .workspace { padding-inline: 16px; }
  .analysis-overview { grid-template-columns: minmax(0, 1fr) 276px; }
}
@media (max-width: 1050px) {
  .topbar h1 { display: none; }
  .analysis-overview { grid-template-columns: minmax(0, 1fr); }
  .mapping-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .sidebar { position: relative; width: 100%; }
  main { margin-left: 0; }
  .topbar { height: auto; min-height: 44px; padding: 6px 10px; flex-wrap: wrap; gap: 8px; }
  .selection-row { flex-wrap: wrap; gap: 10px; }
  .condition { border-left: 0; padding-left: 0; }
  .mapping-grid { grid-template-columns: 1fr; }
  .mapping-grid .wide { grid-column: span 1; }
  dl { grid-template-columns: 1fr; gap: 4px; }
  .zoom-note { margin-left: 0; width: 100%; }
  footer { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ========================================================================= */
/* EZFTIR v0.4.1 — 1-2 Click Quick Interpret, DB Explorer & Table Auditor    */
/* ========================================================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body.mode-v04 .sidebar { display: none; }
body.mode-v04 main { margin-left: 0; }
body.mode-v04 .adv-only-control { display: none; }

.topbar-brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.topbar-brand {
  display: inline-flex;
  align-items: center;
  color: #fff;
  background: var(--navy);
  padding: 4px 10px;
  border-radius: 3px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.4px;
}
body:not(.mode-v04) .topbar-brand { display: none; }
.topbar-ver {
  font: 600 10px var(--mono);
  color: #165e56;
  background: #dff2ef;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #b5dfd9;
}

.v04-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.v04-nav-btn {
  border: 1px solid #48627f;
  background: #253b54;
  color: #dce8f5;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border-radius: 3px;
}
.v04-nav-btn:hover { background: #314d6c; color: #fff; }
.v04-nav-btn[aria-selected="true"] {
  background: #7ce2d4;
  color: #122738;
  border-color: #7ce2d4;
}

.v04-status {
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 3px;
  font-size: 12px;
  background: #e7f4f2;
  border: 1px solid #a8d8d2;
  color: #0f4f48;
}
.v04-status.error {
  background: #fdf0ed;
  border-color: #e4a79b;
  color: #8b2412;
}

.v04-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Quick Interpret Hero */
.qi-hero {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.qi-hero-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.qi-hero-head h2 { margin: 0 0 4px; font-size: 16px; color: var(--navy); }
.qi-hero-head p { margin: 0; font-size: 12px; }
.qi-db-pill {
  font: 600 10px var(--mono);
  padding: 4px 9px;
  border-radius: 3px;
  background: #eef4fa;
  border: 1px solid #c9d8e7;
  color: #1f4469;
  white-space: nowrap;
}

.qi-input-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) minmax(260px, 1fr);
  gap: 12px;
  align-items: stretch;
}
.qi-drop-zone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px dashed #82a7bf;
  border-radius: 4px;
  background: #f8fbfd;
  cursor: pointer;
}
.qi-drop-zone:hover, .qi-drop-zone.dragging {
  border-color: var(--teal);
  background: #eaf8f6;
}
.qi-drop-zone svg {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  stroke: var(--teal);
  fill: none;
  stroke-width: 1.8;
}
.qi-drop-zone strong { display: block; font-size: 13px; color: var(--navy); }
.qi-drop-zone small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.qi-drop-zone input { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); }

.qi-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}
.qi-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}
.qi-controls select { padding: 6px 8px; width: 100%; }

.qi-presets-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid #e1e8f0;
}
.qi-presets-label { font-size: 11px; font-weight: 600; color: #3a5168; }
.qi-presets-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.qi-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #bfd0e0;
  background: #fff;
  color: #1f3b56;
  border-radius: 16px;
}
.qi-preset-chip:hover { border-color: var(--teal); background: #eaf7f5; }
.qi-preset-chip.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.qi-preset-tag {
  font: 600 9px var(--mono);
  padding: 1px 5px;
  border-radius: 10px;
  background: #e6eff7;
  color: #274868;
}
.qi-preset-chip.active .qi-preset-tag { background: rgba(255,255,255,0.22); color: #fff; }

/* Quick Interpret Results */
.qi-results { display: flex; flex-direction: column; gap: 12px; }
.qi-summary-card { padding: 14px 16px; }
.qi-summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.qi-summary-top h3 { margin: 0 0 4px; font-size: 15px; color: var(--navy); }
.qi-meta-strip {
  font: 11px var(--mono);
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.qi-export-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.qi-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 8px;
}
.qi-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #cbd7e3;
  background: #f2f6fa;
  color: #253d54;
}
.qi-badge-teal { background: #e1f4f1; border-color: #a6dbd3; color: #0c524b; }
.qi-badge-blue { background: #e3f0fb; border-color: #accbe7; color: #124878; }
.qi-badge-amber { background: #fdf3dc; border-color: #e4c686; color: #74490a; }
.qi-badge-red { background: #fce6e1; border-color: #e3a79a; color: #8c2210; }

.qi-warning-banner {
  padding: 8px 11px;
  margin: 8px 0;
  border-radius: 3px;
  background: #fff4e4;
  border: 1px solid #e5be84;
  border-left: 4px solid #c26518;
  color: #6b3808;
  font-size: 12px;
  line-height: 1.45;
}
.qi-exec-prose { margin: 8px 0 4px; font-size: 13px; line-height: 1.55; color: var(--ink); }
.qi-caveat { margin: 4px 0 0; font-size: 11px; color: var(--muted); font-style: italic; }

/* Visuals Dual Grid */
.qi-visuals-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  gap: 12px;
}
.qi-plot-card, .qi-simplex-card, .qi-matches-card, .qi-indices-card, .qi-peaks-card {
  padding: 12px 14px;
}
.qi-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.qi-card-head h3, .qi-matches-card h3, .qi-indices-card h3, .qi-peaks-card h3 {
  margin: 0 0 3px;
  font-size: 13px;
  color: var(--navy);
}
.qi-card-head p { margin: 0; font-size: 11px; }
.qi-plot-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.qi-fresnel-check {
  background: #fff4ec;
  border: 1px solid #e2b89d;
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 600;
  color: #873a13;
}
.qi-svg-wrap {
  width: 100%;
  border: 1px solid #d5dfe9;
  border-radius: 3px;
  background: #fff;
  overflow: hidden;
}
.qi-svg-wrap svg { display: block; width: 100%; height: auto; }
.qi-overlay-legend, .qi-simplex-readout {
  margin-top: 6px;
  font-size: 11px;
  color: #3d546b;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.dot-user { background: #0f6f66; }
.dot-fresnel { background: #b2582e; }
.dot-ref { background: #155e9b; }
.dot-star { background: #d4380d; }

/* Top-5 Match Cards */
.qi-matches-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.qi-match-card {
  border: 1px solid #cfdbe6;
  border-radius: 4px;
  padding: 9px 10px;
  background: #f9fbfd;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.qi-match-card.overlay-active {
  border-color: var(--blue);
  background: #edf5fc;
}
.qi-match-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}
.qi-match-score { font: 700 13px var(--mono); color: var(--teal); }
.qi-match-title { font-size: 11px; font-weight: 600; color: var(--navy); line-height: 1.35; }
.qi-match-meta { font-size: 10px; color: var(--muted); line-height: 1.35; }
.qi-match-actions {
  margin-top: auto;
  padding-top: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
}

/* LOI* & Dark Matter Grid */
.qi-loi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 10px;
}
.qi-kpi-box {
  padding: 9px 10px;
  border: 1px solid #d5dfe9;
  border-radius: 3px;
  background: #f7fafc;
}
.qi-kpi-box span { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.qi-kpi-box strong { display: block; font: 700 16px var(--mono); color: var(--navy); margin: 2px 0; }
.qi-kpi-box small { display: block; font-size: 10px; color: #4c6278; }

.qi-dm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.qi-dm-item {
  padding: 7px 9px;
  border: 1px solid #d7e2ec;
  border-radius: 3px;
  font-size: 11px;
  background: #fff;
}
.qi-dm-item.present { border-left: 3px solid var(--teal); background: #f2faf8; }
.qi-dm-item.zombie { border-left: 3px solid #c26518; background: #fff9f2; }

/* Database Explorer */
.db-header-panel { padding: 14px 16px; }
.db-exports-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.db-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.db-subtabs { margin-top: 6px; }
.db-view { padding: 12px 14px; }
.db-filter-bar {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(5, minmax(95px, 1fr)) auto;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
.db-filter-bar.compact-filter {
  grid-template-columns: minmax(220px, 420px) 1fr;
}
.db-filter-bar input, .db-filter-bar select { width: 100%; padding: 6px 8px; }
.db-pager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
  flex-wrap: wrap;
}
.db-pager-btns { display: flex; gap: 6px; }
.db-sp-preview {
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #bcd2e5;
  background: #f5f9fd;
  border-radius: 4px;
}
.db-sp-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

/* Table Auditor */
.aud-panel { padding: 14px 16px; }
.aud-panel h2 { margin: 0 0 4px; font-size: 16px; color: var(--navy); }
.aud-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.aud-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 1fr) auto auto;
  gap: 8px;
  align-items: end;
}
.aud-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.aud-controls select { padding: 6px 8px; width: 100%; }
.aud-textarea {
  width: 100%;
  font: 12px/1.5 var(--mono);
  padding: 10px;
  border: 1px solid #b9c8d8;
  border-radius: 3px;
  background: #fbfdff;
  color: var(--ink);
  resize: vertical;
}
.aud-results { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.aud-kpi-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

/* Responsive Breakpoints for v0.4 */
@media (max-width: 1180px) {
  .qi-visuals-grid { grid-template-columns: 1fr; }
  .qi-matches-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .db-filter-bar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .qi-input-grid { grid-template-columns: 1fr; }
  .qi-controls { grid-template-columns: 1fr; }
  .qi-loi-grid, .db-kpi-strip, .aud-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .aud-controls { grid-template-columns: 1fr; }
  .qi-matches-grid { grid-template-columns: 1fr; }
  .db-filter-bar { grid-template-columns: 1fr; }
}
