/* ── Thema — light (standaard) ── */
:root {
  --bg:         #edf0f5;
  --bg2:        #ffffff;
  --bg3:        #ffffff;
  --bg4:        #e8ebf3;
  --border:     #d8dcea;
  --border2:    #c4cbdd;
  --text:       #1a1f36;
  --text2:      #4a5278;
  --text3:      #8a92b0;
  --accent:     #3d5ee0;
  --accent-dim: #dce4ff;
  --green:      #0e9e57;
  --green-dim:  #d4f5e4;
  --amber:      #c47d00;
  --amber-dim:  rgba(196,125,0,.1);
  --red:        #d63a3a;
  --red-dim:    rgba(214,58,58,.1);
  --sh:         0 2px 12px rgba(0,0,0,.07);
  --r:          6px;
  --rl:         10px;
  color-scheme: light;
}

/* ── Thema — dark ── */
[data-theme="dark"] {
  --bg:         #0a0c10;
  --bg2:        #0d1017;
  --bg3:        #13161d;
  --bg4:        #1a1e27;
  --border:     rgba(255,255,255,.08);
  --border2:    rgba(255,255,255,.13);
  --text:       #e5e9f0;
  --text2:      #94a3b8;
  --text3:      #64748b;
  --accent:     #4b91c2;
  --accent-dim: rgba(75,145,194,.15);
  --green:      #10b981;
  --green-dim:  rgba(16,185,129,.15);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245,158,11,.12);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.13);
  --sh:         0 8px 30px rgba(0,0,0,.25);
  --r:          6px;
  --rl:         10px;
  color-scheme: dark;
}

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

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  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 ── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

header h1 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  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 ── */
.theme-pills {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.tpill {
  padding: 4px 10px;
  border-radius: 5px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.tpill:hover { color: var(--text2); }

.tpill.on {
  background: var(--bg4);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

/* ── Tabnavigatie ── */
#tab-nav {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  gap: 2px;
}

.tab-btn {
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text3);
  font-family: inherit;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text2); }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

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

/* ── 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(--border2);
  border-radius: var(--r);
  color: var(--text2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

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

.uzone {
  border: 2px dashed var(--border2);
  border-radius: 12px;
  padding: 48px 40px;
  text-align: center;
  cursor: pointer;
  max-width: 480px;
  width: 100%;
  transition: border-color .2s, background .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

.uzone input { display: none; }

.uicon {
  width: 52px;
  height: 52px;
  background: var(--bg3);
  border-radius: 12px;
  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-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

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

.u-cta {
  display: inline-block;
  margin-top: 16px;
  padding: 7px 18px;
  background: var(--accent-dim);
  border: 1px solid rgba(75,145,194,.4);
  border-radius: var(--r);
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

#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: 7px;
}

#progress-label {
  font-size: 12px;
  color: var(--text2);
}

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

.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 {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
}

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

#summary-cards {
  display: flex;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  box-shadow: var(--sh);
  overflow: hidden;
}

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

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

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

.stat-value.ok    { color: var(--green); }
.stat-value.error { color: var(--red); }

.stat-label {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

.stat-filtered {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: -.02em;
}

/* ── 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: 999px;
  background: var(--bg4);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

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

.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(--accent-dim);
  border: 1px solid rgba(75,145,194,.4);
  border-radius: var(--r);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}

.btn-primary:hover { opacity: .8; }

/* ── Tabellen (gedeeld) ── */
#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; }

#results-table, #rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#results-table th, #rules-table th {
  padding: 7px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

#results-table th {
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}

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

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

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

.col-filter:focus {
  outline: none;
  border-color: var(--accent);
}

#results-table td, #rules-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

#results-table tr:last-child td,
#rules-table tr:last-child td { border-bottom: none; }

#results-table tbody tr:hover td { background: var(--bg4); }

/* ── Smalle kolommen ── */
#results-table th[data-col="Orderline"],
#results-table td[data-col="Orderline"],
#results-table th[data-col="Type"],
#results-table td[data-col="Type"],
#results-table th[data-col="Trans. code"],
#results-table td[data-col="Trans. code"],
#results-table th[data-col="Trans. type"],
#results-table td[data-col="Trans. type"],
#results-table th[data-col="Documentcode"],
#results-table td[data-col="Documentcode"] {
  width: 1px;
  white-space: nowrap;
}

/* ── Rijnummer ── */
td.row-num {
  color: var(--text3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: left;
  width: 48px;
  min-width: 48px;
  user-select: none;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  margin: 2px 2px 2px 0;
}

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

/* ── 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: 360px;
  line-height: 1.6;
}

.gtip-item + .gtip-item { margin-top: 2px; }

.badge-tip { cursor: help; }

/* ── Instellingenpagina ── */
.ptitle {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .34em;
  margin-bottom: 8px;
}

.settings-intro {
  font-size: 12px;
  color: var(--text2);
  max-width: 600px;
  line-height: 1.55;
}

.settings-intro strong { color: var(--text); }

.del-btn {
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: var(--r);
  transition: color .15s, background .15s;
  line-height: 1;
}

.del-btn:hover {
  color: var(--red);
  background: var(--red-dim);
}

/* ── Validatieregels ── */
.rule-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-align: center;
  width: 28px;
  min-width: 28px;
}

.rule-msg {
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
}

.rule-criteria {
  font-size: 12px;
  color: var(--text);
}

#rules-table tbody tr:hover td { background: var(--bg4); }

.rule-scope-txt {
  font-size: 12px;
  color: var(--text);
}

code {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--text2);
  white-space: nowrap;
  display: inline-block;
  margin: 2px 2px 2px 0;
}

/* ── Instellingen two-col layout ── */
.settings-two-col {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .settings-two-col { grid-template-columns: 1fr; }
}

.settings-panel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 16px;
  box-shadow: var(--sh);
}

.settings-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

/* ── MRN criteria blok ── */
.mrn-block {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.mrn-block-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 8px;
}

.mrn-block-legend {
  font-size: 11px;
  color: var(--text2);
  margin: 8px 0 0;
  line-height: 1.5;
}

.mrn-detail-table {
  width: 100%;
  border-collapse: collapse;
}

.mrn-detail-table td {
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.mrn-detail-table tr:last-child td { border-bottom: none; }

.mrn-code {
  white-space: nowrap;
  width: 52px;
  text-align: center;
  color: var(--accent);
}

.mrn-pos {
  font-weight: 500;
  color: var(--text2);
  white-space: nowrap;
  width: 110px;
}

/* ── Kolom-configurator ── */
.col-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.col-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg4);
  border: 1px solid var(--border);
  border-radius: var(--r);
  cursor: default;
  user-select: none;
  transition: background .1s, border-color .1s;
}

.col-item:hover { border-color: var(--border2); }

.col-drag {
  color: var(--text3);
  cursor: grab;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.col-drag:active { cursor: grabbing; }

.col-label {
  flex: 1;
  font-size: 12px;
  color: var(--text2);
  font-family: ui-monospace, monospace;
}

.col-item.col-dragging {
  opacity: .45;
  border-style: dashed;
}

.col-item.col-fixed {
  background: var(--red-dim);
  border-color: rgba(214,58,58,.3);
}

.col-item.col-fixed .col-label {
  color: var(--red);
  font-family: inherit;
  font-size: 12px;
}

.col-item.col-fixed .col-drag {
  color: var(--red);
  opacity: .5;
}

.col-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.col-add-row select {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid var(--border2);
  border-radius: var(--r);
  font-size: 12px;
  font-family: inherit;
  background: var(--bg4);
  color: var(--text);
}

.col-add-row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: transparent;
}

/* ── Instructie ── */
.instructie-wrap {
  display: grid;
  grid-template-columns: 1fr 600px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 960px) {
  .instructie-wrap { grid-template-columns: 1fr; }
}

.instructie-panel { max-width: 100%; }

.instructie-steps {
  list-style: none;
  counter-reset: step;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.instructie-steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.instructie-steps li:last-child { border-bottom: none; }

.instructie-steps li::before {
  content: counter(step);
  grid-row: 1 / 3;
  width: 24px;
  height: 24px;
  background: var(--accent-dim);
  border: 1px solid rgba(75,145,194,.35);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 1px;
  flex-shrink: 0;
}

.istep-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.istep-body {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.6;
}

.instructie-rules-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.instructie-rules-table th {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border2);
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.instructie-rules-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text2);
  vertical-align: top;
  line-height: 1.5;
}

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

.irule-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.irule-list li {
  padding-left: 12px;
  position: relative;
  line-height: 1.5;
}

.irule-list li::before {
  content: '·';
  position: absolute;
  left: 2px;
  color: var(--text3);
  font-weight: 700;
}

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