/* ── Thema — light (standaard) — Neele-Vat brand ── */
:root {
  --bg:         #F6F8FA;
  --bg2:        #ffffff;
  --bg3:        #ffffff;
  --bg4:        #EAF3F9;
  --border:     #E1E6EA;
  --border2:    #D9D9D9;
  --text:       #000000;
  --text2:      #2C3A45;
  --text3:      #878787;
  --accent:     var(--nv-blue);
  --accent-dim: #EAF3F9;
  --green:      var(--nv-success);
  --green-dim:  rgba(47,143,74,.12);
  --amber:      var(--nv-warning);
  --amber-dim:  rgba(197,138,26,.14);
  --red:        var(--nv-danger);
  --red-dim:    rgba(180,58,45,.1);
  --sh:         var(--nv-shadow-md);
  --r:          var(--nv-radius-2);
  --rl:         var(--nv-radius-2);
  color-scheme: light;
}

/* ── Thema — dark — Neele-Vat blue, no dark theme in the
   brandbook so this is derived from the NVX portal sidebar
   gradient (#1F567A → #163E5B) rather than a generic slate ── */
[data-theme="dark"] {
  --bg:         #0A1219;
  --bg2:        #0D1B26;
  --bg3:        #11212E;
  --bg4:        #1A2E3D;
  --border:     rgba(156,209,236,.12);
  --border2:    rgba(156,209,236,.20);
  --text:       #EAF2F7;
  --text2:      #9FB8C8;
  --text3:      #6C8494;
  --accent:     var(--nv-blue-mid);
  --accent-dim: rgba(52,155,214,.15);
  --green:      #3FAE63;
  --green-dim:  rgba(47,143,74,.18);
  --amber:      #D9A53C;
  --amber-dim:  rgba(197,138,26,.18);
  --red:        #E0574A;
  --red-dim:    rgba(180,58,45,.18);
  --sh:         0 8px 30px rgba(0,0,0,.35);
  --r:          var(--nv-radius-2);
  --rl:         var(--nv-radius-2);
  color-scheme: dark;
}

/* ── Reset / base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--nv-font-body);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.005em;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #80808040; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #80808066; background-clip: padding-box; }

.hidden { display: none !important; }

/* ── Header — fixed dark-navy app chrome, independent of the
   content theme (matches the header treatment used across the
   other Neele-Vat internal tools) ── */
header {
  position: relative;
  background: var(--nv-navy);
  border-bottom: 2px solid var(--nv-blue-mid);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nv-logo {
  height: 18px;
  width: auto;
  display: block;
}

.header-divider {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,.15);
}

header h1 {
  font-family: var(--nv-font-display);
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.version-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 6px;
  letter-spacing: .02em;
}

/* ── Thema-toggle — icon-only, lives in the dark header ── */
.theme-pills {
  display: flex;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--r);
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.tpill {
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--nv-radius-1);
  border: none;
  background: transparent;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  transition: all var(--nv-dur-base) var(--nv-ease);
}

.tpill svg { width: 14px; height: 14px; }

.tpill:hover { color: rgba(255,255,255,.85); }

.tpill.on {
  background: rgba(255,255,255,.16);
  color: #fff;
}

.icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  transition: all var(--nv-dur-base) var(--nv-ease);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.icon-btn.on { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.18); }

/* ── Main ── */
main {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Instellingen-popover (Claude API config), anchored under
   the header's settings gear ── */
.settings-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 14px 16px;
  box-shadow: var(--nv-shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 60;
}

.settings-popover-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.api-key-label {
  font-family: var(--nv-font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--nv-tracking-eyebrow);
  color: var(--accent);
  white-space: nowrap;
}

.api-key-input {
  flex: 1;
  min-width: 0;
  max-width: 340px;
  padding: 4px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 12px;
  font-family: monospace;
  background: var(--bg4);
  color: var(--text);
}
.api-key-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.api-key-status {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  white-space: nowrap;
}
.api-key-status.error { color: var(--red); }

.api-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}

.api-cost-estimate {
  font-size: 11px;
  color: var(--text3);
  white-space: nowrap;
}

/* ── Reset-balk ── */
.reset-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.reset-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 10px 16px;
  box-shadow: var(--sh);
  font-size: 12px;
  color: var(--text2);
}

.btn-secondary {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: var(--r);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--nv-font-display);
  cursor: pointer;
  transition: background var(--nv-dur-base) var(--nv-ease), color var(--nv-dur-base) var(--nv-ease);
}

.btn-secondary:hover {
  background: var(--accent-dim);
}

/* ── Upload ── */
#upload-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.uzone {
  border: 1px solid var(--border);
  border-radius: var(--rl);
  background: var(--bg2);
  box-shadow: var(--sh);
  padding: 48px 40px;
  text-align: center;
  cursor: pointer;
  max-width: 480px;
  width: 100%;
  transition: border-color var(--nv-dur-base) var(--nv-ease), background var(--nv-dur-base) var(--nv-ease);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.uzone:hover, .uzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.uzone input { display: none; }

.uicon {
  width: 52px;
  height: 52px;
  background: var(--bg3);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  border: 1px solid var(--border2);
}

.uicon svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.5;
}

.utitle {
  font-family: var(--nv-font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
}

.usub {
  font-size: 12px;
  color: var(--text3);
}

.uzone-cta { margin-top: 12px; }
.uzone-cta + .uzone-cta { margin-top: 8px; }

#file-name {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text3);
}

/* ── Progress ── */
#progress-section {
  max-width: 420px;
  margin: 80px auto 0;
}

.progress-wrap {
  padding: 10px 0 4px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

#progress-pct {
  font-family: var(--nv-font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}

#progress-label {
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 8px;
  display: block;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

.progress-fill.indeterminate {
  width: 35%;
  transition: none;
  animation: prog-slide 1.4s ease-in-out infinite;
}

@keyframes prog-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

#progress-rows {
  font-size: 12px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

/* ── Summary balk ── */
#summary-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#summary-cards {
  display: none;
}

.stat-item {
  flex: 1;
  padding: 16px 20px;
  border-right: 1px solid var(--border);
}

.stat-item:last-child { border-right: none; }

.stat-value {
  font-family: var(--nv-font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -.02em;
}

.stat-value.ok    { color: var(--green); }
.stat-value.warn  { color: var(--amber); }

.stat-label {
  font-family: var(--nv-font-display);
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: var(--nv-tracking-eyebrow);
  font-weight: 600;
}

/* ── Filter pills ── */
#filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--border2);
  border-radius: var(--nv-radius-pill);
  background: var(--bg4);
  color: var(--text2);
  font-family: var(--nv-font-display);
  font-weight: 600;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--nv-dur-fast) var(--nv-ease), color var(--nv-dur-fast) var(--nv-ease), border-color var(--nv-dur-fast) var(--nv-ease);
  white-space: nowrap;
}

.filter-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.filter-pill::before {
  content: '✓';
  margin-right: 4px;
  visibility: hidden;
}

.filter-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.filter-pill.active::before {
  visibility: visible;
}

/* ── Primaire knop ── */
.btn-primary {
  padding: 6px 14px;
  background: var(--nv-blue);
  border: 1px solid var(--nv-blue);
  border-radius: var(--r);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--nv-font-display);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--nv-dur-base) var(--nv-ease), border-color var(--nv-dur-base) var(--nv-ease);
}

.btn-primary:hover { background: #1F567A; border-color: #1F567A; }

/* ── Tabel ── */
#results-section {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 16px;
  box-shadow: var(--sh);
}

.table-wrap { overflow-x: auto; overflow-y: auto; max-height: calc(100vh - 280px); }

#results-table {
  min-width: 100%;
  width: max-content;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

#results-table th {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
  font-family: var(--nv-font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--nv-dur-base) var(--nv-ease);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 24px;
  position: relative;
}

/* JS drag-resize handle on right edge of th */
.col-resizer {
  position: absolute;
  right: 0; top: 0;
  width: 5px; height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 1;
}
.col-resizer:hover, .col-resizer.dragging { background: var(--accent); opacity: .45; }

/* Titelrij vastzetten bij verticaal scrollen */
#results-table thead th {
  position: sticky;
  top: 0;        /* label row default; filter row overridden by JS */
  z-index: 4;
  background: var(--bg3);
}
/* Filter row top is set dynamically by JS to = height of label row */
#results-table .filter-row th {
  z-index: 4;
  background: var(--bg3);
}

/* Eerste kolom (#) vastzetten */
#results-table th:first-child,
#results-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg3);
  text-align: right;
}

/* Tweede kolom (File name) vastzetten — left offset = breedte van # kolom (via JS var) */
#results-table th:nth-child(2),
#results-table td:nth-child(2) {
  position: sticky;
  left: var(--col0-w, 40px);
  z-index: 2;
  background: var(--bg3);
}

/* Hoekcel (eerste + tweede kolom in titelrij): hoogste z-index */
#results-table thead th:first-child  { z-index: 5; }
#results-table thead th:nth-child(2) { z-index: 5; }
#results-table th:first-child        { z-index: 3; }
#results-table th:nth-child(2)       { z-index: 3; }

#results-table tbody tr:hover td:first-child,
#results-table tbody tr:hover td:nth-child(2) { background: var(--bg4); }

#results-table th:hover { color: var(--accent); }

/* ── Kolomfilters ── */
.filter-row th {
  padding: 3px 4px;
  border-bottom: 1px solid var(--border2);
  cursor: default;
  resize: none;
  overflow: hidden;
}

.filter-row th:hover { color: var(--text3); }

.col-filter {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--border2);
  border-radius: var(--nv-radius-1);
  font-size: 11px;
  font-family: inherit;
  background: var(--bg4);
  color: var(--text);
  transition: border-color var(--nv-dur-base) var(--nv-ease);
  min-width: 0;
}

.col-filter:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

#results-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 0;
}

#results-table tr:last-child td { border-bottom: none; }
#results-table tbody tr:hover td { background: var(--bg4); }

/* Compacte kolommen */
#results-table td.compact, #results-table th.compact {
  white-space: nowrap;
  width: 1px;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: var(--nv-font-body);
  padding: 2px 8px;
  border-radius: var(--nv-radius-pill);
  font-size: 11px;
  font-weight: 600;
  margin: 1px 2px 1px 0;
  white-space: nowrap;
}

.badge-hazard {
  background: var(--accent-dim);
  color: var(--accent);
}

.badge-nonadr {
  background: var(--bg4);
  color: var(--text3);
  border: 1px solid var(--border2);
}

.badge-marine {
  background: var(--green-dim);
  color: var(--green);
}

.badge-h {
  background: var(--red-dim);
  color: var(--red);
}

.badge-p {
  background: var(--amber-dim);
  color: var(--amber);
}

/* ── Trainpaneel ── */
.train-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 100;
}

.train-panel {
  position: fixed;
  top: 0; right: 0;
  width: min(1100px, 92vw);
  height: 100vh;
  background: var(--bg2);
  border-left: 1px solid var(--border2);
  box-shadow: -4px 0 32px rgba(0,0,0,.18);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--nv-dur-slow) var(--nv-ease);
}

.train-panel.open {
  transform: translateX(0);
}

.train-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
  gap: 12px;
}

.train-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.train-label {
  font-family: var(--nv-font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--nv-tracking-eyebrow);
  color: var(--accent);
  white-space: nowrap;
}

#train-filename {
  font-family: var(--nv-font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.train-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.train-close {
  width: 28px; height: 28px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  background: transparent;
  color: var(--text3);
  font-size: 14px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, border-color .15s;
}
.train-close { transition: color var(--nv-dur-base) var(--nv-ease), border-color var(--nv-dur-base) var(--nv-ease); }
.train-close:hover { color: var(--text); border-color: var(--text2); }

.train-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.train-raw-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.train-fields-pane {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.train-pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  font-family: var(--nv-font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}

.train-search {
  padding: 3px 8px;
  border: 1px solid var(--border2);
  border-radius: var(--nv-radius-1);
  font-size: 11px;
  font-family: inherit;
  background: var(--bg2);
  color: var(--text);
  width: 140px;
  transition: border-color var(--nv-dur-base) var(--nv-ease), box-shadow var(--nv-dur-base) var(--nv-ease);
}
.train-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

#train-raw-text {
  flex: 1;
  overflow: auto;
  padding: 12px;
  font-family: var(--nv-font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--text2);
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

mark.train-highlight {
  background: rgba(255,220,0,.45);
  color: inherit;
  border-radius: 2px;
}

#train-field-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.train-field-row {
  display: flex;
  flex-direction: column;
  padding: 5px 12px;
  border-bottom: 1px solid var(--border);
  gap: 2px;
}

.train-field-row:last-child { border-bottom: none; }

.train-field-label {
  font-family: var(--nv-font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.train-field-input {
  width: 100%;
  padding: 4px 7px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg3);
  color: var(--text);
  transition: border-color var(--nv-dur-base) var(--nv-ease), background var(--nv-dur-base) var(--nv-ease), box-shadow var(--nv-dur-base) var(--nv-ease);
}
.train-field-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.train-field-input.corrected {
  border-color: var(--amber);
  background: var(--amber-dim);
}

.train-note-wrap {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

.train-note {
  width: 100%;
  height: 80px;
  padding: 6px 8px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: var(--bg3);
  color: var(--text);
  resize: vertical;
}
.train-note:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.train-save-row {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.train-saved-msg {
  font-size: 12px;
  color: var(--green);
  font-weight: 600;
}

/* ── Footer ── */
footer {
  padding: 10px 20px;
  font-size: 11px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  background: var(--bg2);
  text-align: center;
}

/* ── Global tooltip ── */
.global-tip {
  position: fixed;
  z-index: 9999;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  box-shadow: var(--sh);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text2);
  pointer-events: none;
  max-width: 420px;
  line-height: 1.6;
}
