:root {
  --paper: #F7F5F0;
  --paper-2: #EFECE5;
  --card-bg: #FFFFFF;
  --card-border: #DEDAD1;
  --input-bg: #FFFFFF;
  --ink: #0F1720;
  --label: #0F1720;
  --muted: #5A6470;
  --caption: #9AA3AC;
  --blue: #1E7FD8;
  --blue-deep: #0F5FA8;
  --success: #178A4C;
  --success-bg: rgba(23, 138, 76, 0.08);
  --success-border: rgba(23, 138, 76, 0.25);
  --error: #C23B3B;
  --display: "Inter Tight", "Inter", system-ui, sans-serif;
  --text: "Inter", -apple-system, "Segoe UI", system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
}

body {
  font-family: var(--text);
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

.glow {
  position: absolute;
  top: -160px;
  left: 50%;
  transform: translateX(-50%);
  width: 640px;
  max-width: 160vw;
  height: 320px;
  background: radial-gradient(circle, rgba(30, 127, 216, 0.16) 0%, rgba(30, 127, 216, 0) 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

@keyframes bon-pop {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.page {
  max-width: 480px;
  margin-inline: auto;
  padding: max(56px, env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.logo-mark {
  width: 30px;
  height: 30px;
  flex: none;
  background: var(--blue);
  -webkit-mask-image: url("dnigl-icon-mask.png");
  mask-image: url("dnigl-icon-mask.png");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.logo-divider {
  width: 1px;
  height: 26px;
  background: var(--card-border);
  flex: none;
}

h1 {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--paper-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.tab-btn {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--text);
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tab-btn.active {
  color: var(--blue);
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 32, 0.08);
}

.tab-panel {
  animation: bon-pop 0.15s ease;
}

.filter-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--paper-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
}

.filter-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-toggle label {
  flex: 1;
  text-align: center;
  margin: 0;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--text);
  color: var(--muted);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.filter-toggle input[type="radio"]:checked + label {
  color: var(--blue);
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(15, 23, 32, 0.08);
}

.filter-toggle input[type="radio"]:focus-visible + label {
  outline: 2px solid rgba(30, 127, 216, 0.45);
  outline-offset: -2px;
}

.field-hint {
  margin: -14px 0 22px;
  font-size: 12px;
  color: var(--caption);
}

.pin-label {
  display: block;
  text-align: center;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 14px;
  color: var(--label);
}

.pin-invoer {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.pin-cijfer {
  width: 54px;
  height: 62px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  padding: 0;
  font-family: var(--text);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.pin-cijfer:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 127, 216, 0.15);
  transform: translateY(-1px);
}

.pin-cijfer[data-error="true"] {
  border-color: var(--error);
  animation: pin-shake 0.3s ease;
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.bon-lijst-acties {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font-family: var(--text);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  width: auto;
}

.link-btn:hover {
  color: var(--blue-deep);
}

.bon-lijst {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.bon-lijst-empty {
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.bon-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--card-border);
  cursor: pointer;
  font-weight: 400;
  margin: 0;
}

.bon-checkbox:last-child {
  border-bottom: none;
}

.bon-checkbox input[type="checkbox"] {
  margin-top: 2px;
  flex: none;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.bon-checkbox-main {
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}

.bon-checkbox-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 20px 50px -30px rgba(15, 23, 32, 0.18);
}

.field {
  margin-bottom: 22px;
}

.field:last-of-type {
  margin-bottom: 0;
}

label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 9px;
  color: var(--label);
}

select,
textarea,
input[type="text"],
input[type="email"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--text);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'><path d='M4 6l4 4 4-4' stroke='%235A6470' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select:focus,
textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="file"]:focus + .photo-hint {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 127, 216, 0.15);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

input[type="text"] {
  margin-top: 10px;
  animation: bon-pop 0.2s ease;
}

.photo-input {
  position: relative;
}

.photo-input input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.photo-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 76px;
  padding: 26px 16px;
  border: 1.5px dashed var(--card-border);
  border-radius: var(--radius);
  background: var(--paper-2);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.photo-input input[type="file"]:hover ~ .photo-hint {
  border-color: var(--blue);
  color: var(--ink);
}

.photo-confirm-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.photo-confirm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  animation: bon-pop 0.25s ease;
}

.photo-thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 8px;
  flex: none;
  background: var(--paper-2);
}

.photo-thumb-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.photo-check {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-filename {
  font-size: 14px;
  color: var(--success);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
}

.photo-remove {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.photo-remove:hover {
  color: var(--error);
}

button[type="submit"],
button#uitbetaalSubmitBtn {
  margin-top: 26px;
  width: 100%;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  font-family: var(--text);
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(30, 127, 216, 0.55);
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

button[type="submit"]:hover,
button#uitbetaalSubmitBtn:hover {
  background: var(--blue-deep);
  transform: translateY(-1px);
}

button[type="submit"]:disabled,
button#uitbetaalSubmitBtn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

.status-msg {
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  min-height: 1.2em;
  color: var(--muted);
}

.status-msg:not(:empty) {
  animation: bon-pop 0.25s ease;
}

.status-msg[data-state="success"] { color: var(--success); }
.status-msg[data-state="error"] { color: var(--error); }

.footer-note {
  margin-top: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--caption);
  line-height: 1.5;
}

/* --- Bon-wizard: croppen / laden / controleren --- */

.wizard-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 32, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.wizard-card {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px -20px rgba(15, 23, 32, 0.35);
  animation: bon-pop 0.2s ease;
}

/* Op bredere schermen (desktop/tablet) oogt een onderaan-vastgeplakte
   "bottom sheet" als per ongeluk verkeerd gepositioneerd -- daar centreren
   we 'm gewoon midden op het scherm, met ronde hoeken rondom. */
@media (min-width: 640px) {
  .wizard-overlay {
    align-items: center;
    padding: 24px;
  }

  .wizard-card {
    max-height: 85vh;
    border-radius: 24px;
    padding: 28px 24px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 32, 0.45);
  }
}

.wizard-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 16px;
}

.wizard-progress {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}

.wizard-close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  background: var(--paper-2);
  border-radius: 50%;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wizard-close:hover {
  background: var(--card-border);
  color: var(--ink);
}

.wizard-hint {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn-wizard-primary,
.btn-wizard-ghost {
  flex: 1;
  height: 48px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn-wizard-primary {
  border: none;
  background: var(--blue);
  color: #fff;
}

.btn-wizard-primary:hover {
  background: var(--blue-deep);
}

.btn-wizard-ghost {
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--muted);
}

.btn-wizard-ghost:hover {
  border-color: var(--muted);
  color: var(--ink);
}

/* Crop-stap */

.crop-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper-2);
  touch-action: none;
}

.crop-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.crop-poly {
  fill: rgba(30, 127, 216, 0.18);
  stroke: var(--blue);
  stroke-width: 2;
}

.crop-handle {
  position: absolute;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  margin-top: -15px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 32, 0.35);
  touch-action: none;
  cursor: grab;
}

.crop-handle:active {
  cursor: grabbing;
  transform: scale(1.1);
}

/* Laad-stap */

.wizard-step#stepLoading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 0;
}

.wizard-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--card-border);
  border-top-color: var(--blue);
  animation: wizard-spin 0.8s linear infinite;
}

@keyframes wizard-spin {
  to { transform: rotate(360deg); }
}

.wizard-loading-text {
  margin: 18px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
}

/* Controleer-stap */

.confirm-thumb {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--paper-2);
  /* "contain" i.p.v. "cover": laat de hele foto zien, ongeacht de
     verhouding (lange smalle bon of brede factuur) -- geen bijgesneden/
     ingezoomde weergave meer. De wizard-kaart zelf blijft scrollbaar
     (zie .wizard-card, max-height: 92vh) dus zelfs bij een erg lange
     foto blijven de velden en knoppen eronder gewoon bereikbaar. */
}

.confirm-thumb-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.confirm-thumb-wrap {
  position: relative;
}

.zoom-btn-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* --- Zoomweergave (foto/PDF-voorbeeld groter bekijken) --- */

.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(10, 10, 10, 0.94);
  display: flex;
  flex-direction: column;
}

.zoom-toolbar {
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
}

.zoom-ctrl-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.zoom-close-btn {
  margin-left: 10px;
  font-size: 22px;
}

.zoom-stage {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pinch-zoom pan-x pan-y;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.zoom-image {
  max-width: 100%;
  max-height: 100%;
  touch-action: pinch-zoom pan-x pan-y;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.zoom-hint {
  flex: none;
  text-align: center;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  padding: 4px 14px 14px;
}

.confirm-amount-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}

.confirm-amount-input {
  font-family: var(--display);
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  border: none;
  background: transparent;
  text-align: right;
  width: 8ch;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.confirm-currency-input {
  font-family: var(--text);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  background: transparent;
  width: 3.5ch;
  padding: 2px 4px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.confirm-amount-input:focus,
.confirm-currency-input:focus {
  outline: none;
  background: var(--paper-2);
  box-shadow: 0 0 0 2px rgba(30, 127, 216, 0.25);
}

.confirm-rows {
  margin-top: 18px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--card-border);
  font-size: 14px;
}

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

.confirm-row label {
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  margin: 0;
  flex: none;
}

.confirm-row input,
.confirm-row select {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--text);
  font-size: 14px;
  text-align: right;
  border: none;
  background: transparent;
  padding: 4px 6px;
  border-radius: 8px;
  flex: 1;
  min-width: 0;
  transition: background 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.confirm-row select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none'><path d='M4 6l4 4 4-4' stroke='%235A6470' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 24px;
}

.confirm-row input:focus,
.confirm-row select:focus {
  outline: none;
  background: var(--paper-2);
  box-shadow: 0 0 0 2px rgba(30, 127, 216, 0.25);
}

/* Toelichting is een vrije-tekst-veld i.p.v. een korte waarde --
   daarom onder het label i.p.v. ernaast, net als in het hoofdformulier. */
#confirmToelichtingWrap {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

#confirmToelichtingWrap label {
  text-align: left;
}

#confirmToelichtingInput {
  width: 100%;
  text-align: left;
  font-weight: 500;
  font-size: 14px;
  font-family: var(--text);
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 10px;
  resize: vertical;
}

#confirmToelichtingInput:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(30, 127, 216, 0.25);
}

/* Foto maken + kiezen naast elkaar */
.photo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.photo-actions .photo-hint {
  min-height: 76px;
  padding: 16px 10px;
}

/* Toegangscode (bovenop de wizard) */
.toegang-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 32, 0.6);
}

.toegang-card {
  width: 100%;
  max-width: 360px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--card-bg);
  border: 1px solid var(--card-border);
}

.toegang-card h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 20px;
  color: var(--ink);
}

.toegang-uitleg {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}

.toegang-card input[type="password"] {
  width: 100%;
}

.toegang-card .btn-wizard-primary {
  width: 100%;
  margin-top: 12px;
}

/* Waarschuwing bij een mogelijk dubbele bon (boven de wizard en de toegangscode) */
.dubbel-overlay {
  z-index: 450;
}

.dubbel-overlay .wizard-actions {
  margin-top: 16px;
}
