/* Sengers Europe BV — offerte / bestelbon
   Compacte opmaak: alles moet op één A4 passen. */

:root {
  --primary: #003366;
  --primary-soft: #0055a4;
  --line: #d8dde3;
  --ink: #1f2933;
  --muted: #6b7280;
  --bg: #eef1f5;
  --danger: #b91c1c;
  --sheet-font: 9pt;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------------ login */
.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #00223f 0%, #014a86 55%, #0b6bb5 100%);
  padding: 20px;
  z-index: 50;
}
.login-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  padding: 26px 26px 18px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-logo { height: 40px; width: auto; margin-bottom: 14px; }
.login-card h1 { font-size: 18px; margin: 0 0 18px; color: var(--primary); }
.login-card label { display: block; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--primary-soft); border-color: transparent; }
.login-banner { width: 100%; margin-top: 18px; border-radius: 8px; display: block; }
.error { color: var(--danger); font-size: 12px; min-height: 16px; margin: 6px 0; }

/* ------------------------------------------------------------------ shell */
.app { padding: 10px 12px 40px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
  margin-bottom: 10px;
  position: sticky;
  top: 8px;
  z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-brand img { height: 26px; width: auto; background: var(--primary); padding: 3px 6px; border-radius: 6px; }
.topbar-title { font-weight: 600; font-size: 13px; color: var(--primary); white-space: nowrap; }
.badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #e8eef6;
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
}
.badge.margins { background: #fde8e8; color: #9b1c1c; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .topbar-actions { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .btn { padding: 6px 9px; font-size: 11.5px; }
}

.btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 7px 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-soft); }
.btn-ghost { background: #f3f5f8; color: #334155; border-color: var(--line); }
.btn-ghost:hover { background: #e7ebf1; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ layout */
.layout {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sheet-wrap { justify-content: center; }
}

.config { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 64px; max-height: calc(100vh - 74px); overflow-y: auto; padding-right: 2px; }
@media (max-width: 1100px) { .config { position: static; max-height: none; } }

.panel {
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.field-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 7px;
}
select, input[type="text"], input[type="number"], input[type="search"], textarea {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 9px;
  width: 100%;
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--primary-soft); outline-offset: -1px; }
.check-tools { margin-bottom: 6px; }
.check-list { display: flex; flex-direction: column; gap: 1px; }
.check-list.scroll { max-height: 340px; overflow-y: auto; padding-right: 4px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 3px 4px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.25;
  cursor: pointer;
}
.check-row:hover { background: #f4f7fb; }
.check-row input { margin: 2px 0 0; flex: none; }
.check-row .nm { flex: 1; }
.check-row .pr { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; font-size: 11.5px; }
.check-row .mx { font-size: 10px; color: #9b1c1c; white-space: nowrap; }
.custom-row { display: grid; grid-template-columns: 1fr 78px 82px auto auto; gap: 5px; align-items: center; }
.custom-row .tiny { font-size: 10px; color: var(--muted); display: flex; align-items: center; gap: 3px; white-space: nowrap; }

/* --------------------------------------------------------------- margins */
.margin { border: 1px solid #f3c6c6; background: #fff7f7; }
.margin-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 11px; color: #9b1c1c; }
.margin-totals { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: 7px 0; font-size: 11.5px; }
.margin-totals div { display: flex; justify-content: space-between; gap: 6px; }
.margin-totals span { color: var(--muted); }
.margin-lines { max-height: 260px; overflow: auto; font-size: 10.5px; }
.margin-lines table { width: 100%; border-collapse: collapse; }
.margin-lines th, .margin-lines td { padding: 2px 3px; text-align: right; border-bottom: 1px solid #f0dada; }
.margin-lines th:first-child, .margin-lines td:first-child { text-align: left; }
.margin-lines input { width: 62px; padding: 2px 4px; font-size: 10.5px; text-align: right; }
.margin-lines .unk { color: #b45309; }

/* ------------------------------------------------------------------ sheet */
.sheet-wrap { display: flex; justify-content: center; overflow-x: auto; }
.sheet {
  width: 210mm;
  flex: 0 0 auto;
  min-height: 297mm;
  background: #fff;
  color: #111;
  font-size: var(--sheet-font);
  line-height: 1.3;
  padding: 10mm 11mm;
  box-shadow: 0 6px 24px rgba(16, 24, 40, .14);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
}
body.density-compact .sheet { font-size: 8pt; line-height: 1.22; padding: 8mm 9mm; }

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--primary);
  color: #fff;
  padding: 3.5mm 4mm;
  border-radius: 1mm;
}
.sheet-logo { height: 14mm; width: auto; }
.sheet-company { text-align: right; font-size: .8em; color: #cfd9e6; line-height: 1.35; }
.sheet-company strong { display: block; color: #fff; font-size: 1.05em; letter-spacing: .04em; }

.doc-title {
  text-align: center;
  font-size: 1.9em;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 4mm 0 3mm;
  font-weight: 700;
}

.meta {
  display: grid;
  grid-template-columns: 25mm 1fr 18mm 1fr;
  gap: 1.2mm 2mm;
  align-items: center;
  margin-bottom: 3mm;
  font-size: .92em;
}
.meta label { color: var(--muted); font-weight: 600; }
.meta input[type="text"] {
  width: 100%;
  border: none;
  border-bottom: 1px solid #c9d2dc;
  border-radius: 0;
  padding: 1px 2px;
  font-size: 1em;
  background: transparent;
}
.meta input:focus { outline: none; border-bottom-color: var(--primary-soft); }

.doc-groups { flex: 0 0 auto; min-height: 30mm; }
.doc-group { margin-bottom: 2.5mm; break-inside: avoid; }
.doc-group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #eff3f8;
  border-left: 2.5px solid var(--primary);
  padding: 1.2mm 2mm;
  font-weight: 700;
  color: var(--primary);
}
.doc-group-head .sub { font-weight: 400; color: var(--muted); font-size: .88em; }
table.lines { width: 100%; border-collapse: collapse; }
table.lines td { padding: .9mm 1.5mm; border-bottom: .2mm solid #e6eaef; vertical-align: middle; }
table.lines td.nm { line-height: 1.25; }
table.lines td.p { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lines tr.opt td.nm { padding-left: 6mm; }
table.lines tr.opt td.nm::before { content: '·'; margin-right: 1.5mm; color: #9aa5b1; }
.qty-label { font-size: .85em; color: #475569; margin-left: 1.5mm; }
.row-del {
  border: none;
  background: none;
  color: var(--danger);
  cursor: pointer;
  font-size: .85em;
  padding: 0 0 0 2mm;
}
table.lines input.qty-inline { width: 10mm; padding: 0 1mm; font-size: .9em; text-align: right; border: .2mm solid var(--line); border-radius: 1mm; }
.empty-hint { color: var(--muted); font-size: .9em; padding: 6mm 0; text-align: center; }

.totals { margin: 3mm 0 0 auto; width: 88mm; }
.totals-row { display: flex; justify-content: space-between; gap: 4mm; padding: .9mm 0; border-bottom: .2mm solid #eef1f5; }
.totals-row.strong { border-top: .3mm solid var(--line); border-bottom: .3mm solid var(--line); font-weight: 600; }
.totals-row.grand { border-top: .5mm solid var(--primary); color: var(--primary); font-size: 1.15em; font-weight: 700; padding-top: 1.5mm; }
.totals-row .input-inline { display: inline-flex; align-items: center; gap: 1mm; white-space: nowrap; }
.totals-row input[type="number"] { width: 18mm; text-align: right; padding: 0 1mm; font-size: 1em; border: .2mm solid var(--line); border-radius: 1mm; }
.totals-row input.vat-input { width: 11mm; text-align: center; padding: 0 .5mm; }

.notes-block { margin-top: 4mm; }
.notes-block label { display: block; font-weight: 700; font-size: .9em; color: var(--primary); margin-bottom: 1mm; }
.notes-block textarea { width: 100%; resize: vertical; font-size: .92em; line-height: 1.35; padding: 2mm; border: .2mm solid var(--line); border-radius: 1mm; }

.order-block { margin-top: 3mm; }
.order-fields { display: grid; grid-template-columns: 40mm 1fr; gap: 1mm 2mm; align-items: center; font-size: .92em; }
.order-fields label { color: var(--muted); font-weight: 600; }
.order-fields input { border: none; border-bottom: .2mm solid #c9d2dc; border-radius: 0; background: transparent; padding: 1px 2px; }

.sign-block { display: flex; gap: 6mm; margin-top: 5mm; padding-top: 2mm; }
.sign-col { flex: 1; }
.sign-col.wide { flex: 1.7; }
.sign-line { border-bottom: .3mm solid #333; height: 12mm; }
.sign-caption { font-size: .82em; color: var(--muted); padding-top: 1mm; }

.sheet-foot { margin-top: auto; padding-top: 4mm; }
.sheet-foot img { width: 100%; height: auto; display: block; max-height: 17mm; object-fit: contain; }
.foot-text { text-align: center; font-size: .75em; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 1mm; }

/* ------------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; background: rgba(10, 20, 30, .45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-card { background: #fff; border-radius: 12px; padding: 18px 20px; width: 100%; max-width: 460px; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.modal-card h2 { font-size: 15px; margin: 0 0 12px; color: var(--primary); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.saved-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.saved-item .meta2 { color: var(--muted); font-size: 11px; }
.saved-list { max-height: 52vh; overflow: auto; }
.saved-empty { color: var(--muted); font-size: 12.5px; padding: 10px 0; }
.link-box { width: 100%; font-size: 11.5px; font-family: ui-monospace, monospace; }

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 70;
}

/* ------------------------------------------------------------------ print */
@page { size: A4; margin: 8mm; }

@media print {
  html, body { background: #fff; font-size: 8pt; }
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .topbar, .config, .toast, .modal { display: none !important; }
  .app { padding: 0; }
  .layout { display: block; }
  .sheet-wrap { display: block; overflow: visible; }
  .sheet {
    width: 100%;
    min-height: 0;
    padding: 0;
    box-shadow: none;
    border-radius: 0;
    font-size: var(--print-font, 8pt);
    line-height: 1.25;
  }
  body.density-compact .sheet { padding: 0; }
  .doc-group, .totals, .notes-block, .sign-block, .sheet-foot { break-inside: avoid; }
  .meta input, .totals-row input, .notes-block textarea, .order-fields input {
    border-color: #d0d6dc !important;
  }
  .notes-block textarea { border: .2mm solid #c9d2dc !important; resize: none !important; }
  .totals-row input[type="number"], .order-fields input { border: none !important; border-bottom: .2mm solid #d0d6dc !important; border-radius: 0 !important; }
  table.lines td { padding: .8mm 1.2mm; }
  .qty-label { display: inline !important; }
  table.lines tr { break-inside: avoid; }
  .row-del, .qty-inline { display: none !important; }
}