/* ========== Aanneem — design tokens ========== */
:root {
  --primary: #1E3A5F;
  --on-primary: #FFFFFF;
  --accent: #059669;
  --on-accent: #FFFFFF;
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --fg: #0F172A;
  --fg-muted: #55657A;
  --border: #E4E7EB;
  --danger: #DC2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #7FA8D9;
    --on-primary: #0B1726;
    --accent: #34D399;
    --on-accent: #052E1F;
    --bg: #0F172A;
    --surface: #1B2537;
    --fg: #EDF2F9;
    --fg-muted: #9BA9BD;
    --border: #2C394E;
    --danger: #F87171;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.hidden { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ========== layout ==========
   App-shell: top- en bottombar staan vast, alleen .content scrolt.
   (position:sticky is op iOS onbetrouwbaar in de PWA-modus) */
html, body { height: 100%; }
body { overflow: hidden; }

.view {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--bg);
  flex: none;
}

.topbar h1 { font-size: 22px; font-weight: 700; }

.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; }
.topbar-spacer { width: 48px; }

.content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bottombar {
  flex: none;
  padding: 10px 16px calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}
.bottombar .btn { flex: 1; }

/* ========== knoppen ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform .15s ease, opacity .15s ease, background .2s ease;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 22px; height: 22px; flex: none; }

.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-outline {
  background: var(--surface);
  color: var(--primary);
  border: 2px solid var(--border);
}
.btn-ghost { background: transparent; color: var(--fg-muted); }
.btn-big { min-height: 60px; font-size: 19px; width: 100%; }
.btn-small { min-height: 44px; font-size: 15px; padding: 8px 14px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: background .2s ease;
}
.icon-btn:active { background: var(--border); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.danger { color: var(--danger); }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ========== velden ========== */
.field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.field-label { font-size: 15px; font-weight: 600; color: var(--fg-muted); }
.field-label em { font-style: normal; font-weight: 400; opacity: .75; }

input[type="text"], input[type="tel"], input[type="email"], input[type="password"], textarea, select {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  font-size: 17px;
  font-family: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .2s ease;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
input::placeholder, textarea::placeholder { color: var(--fg-muted); opacity: .6; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

.section-title { font-size: 16px; font-weight: 700; color: var(--fg-muted); margin-top: 8px; text-transform: uppercase; letter-spacing: .03em; }

.intro {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 16px;
}

/* ========== segmented (btw) ========== */
.segmented {
  display: flex;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
}
.segmented button {
  flex: 1;
  min-height: 46px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.segmented button[aria-checked="true"] {
  background: var(--primary);
  color: var(--on-primary);
}

/* ========== regels ========== */
.regels { display: flex; flex-direction: column; gap: 10px; }

.regel {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
.regel-info { flex: 1; min-width: 0; cursor: pointer; }
.regel-oms { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.regel-detail { font-size: 15px; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.regel-bedrag { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.regel-del {
  width: 44px; height: 44px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; border-radius: 10px;
  color: var(--fg-muted); cursor: pointer;
}
.regel-del:active { color: var(--danger); background: var(--border); }
.regel-del svg { width: 20px; height: 20px; }

/* quick add chips */
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .2s ease;
}
.chip:active { border-color: var(--primary); }

/* ========== totalen ========== */
.totals-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.totals-row { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; color: var(--fg-muted); }
.totals-main { font-size: 22px; font-weight: 800; color: var(--fg); border-top: 2px solid var(--border); padding-top: 10px; }

/* ========== offerte-lijst home ========== */
.quote-list { display: flex; flex-direction: column; gap: 10px; }

.quote-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 17px;
  color: var(--fg);
  cursor: pointer;
  transition: transform .15s ease;
}
.quote-card:active { transform: scale(.98); }
.qc-main { flex: 1; min-width: 0; }
.qc-naam { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qc-sub { font-size: 14px; color: var(--fg-muted); }
.qc-right { text-align: right; }
.qc-bedrag { font-weight: 700; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-concept { background: var(--border); color: var(--fg-muted); }
.badge-verzonden { background: #DBEAFE; color: #1D4ED8; }
.badge-geaccepteerd { background: #D1FAE5; color: #047857; }
@media (prefers-color-scheme: dark) {
  .badge-verzonden { background: #1E3A8A; color: #BFDBFE; }
  .badge-geaccepteerd { background: #064E3B; color: #A7F3D0; }
}

.empty-state {
  text-align: center;
  color: var(--fg-muted);
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.empty-state svg { width: 56px; height: 56px; opacity: .4; }

/* ========== bottom sheet ========== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 10px 20px calc(20px + var(--safe-bottom));
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: sheet-up .25s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 2px;
}
.sheet-buttons { display: flex; gap: 10px; }
.sheet-buttons .btn { flex: 1; }

.sheet-top { z-index: 60; }

/* ========== regelboek-kiezer ========== */
.rb-zoek-row { position: relative; }
.rb-zoek-row svg {
  position: absolute; left: 14px; top: 50%;
  width: 20px; height: 20px;
  transform: translateY(-50%);
  color: var(--fg-muted);
  pointer-events: none;
}
.rb-zoek-row input { padding-left: 44px; }

.rb-lijst {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 48dvh;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.rb-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rb-kies {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px 8px 14px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 16px;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
}
.rb-kies:active { background: var(--border); border-radius: 12px; }
.rb-oms { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.rb-prijs { color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.rb-btw {
  font-size: 11px; font-weight: 700;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 5px;
}
.rb-count {
  min-width: 26px; height: 26px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px;
}
.rb-edit {
  width: 48px; height: 56px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  border-left: 1px solid var(--border);
  color: var(--fg-muted); cursor: pointer;
}
.rb-edit:active { color: var(--primary); }
.rb-edit svg { width: 18px; height: 18px; }

.rb-nieuw {
  min-height: 56px;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: 12px;
  font-family: inherit; font-size: 16px; font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  text-align: left;
}
.rb-nieuw svg { width: 20px; height: 20px; flex: none; }
.rb-leeg { text-align: center; color: var(--fg-muted); padding: 16px; font-size: 15px; }

/* ========== stepper ========== */
.stepper {
  display: flex;
  align-items: stretch;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.stepper button {
  width: 48px;
  border: none;
  background: transparent;
  font-size: 24px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  flex: none;
}
.stepper button:active { background: var(--border); }
.stepper input {
  border: none;
  border-radius: 0;
  text-align: center;
  min-width: 0;
  flex: 1;
  padding: 12px 4px;
}
.stepper input:focus { border: none; }

/* ========== klant-rij met contactknop ========== */
.klant-row { display: flex; gap: 8px; }
.klant-row input { flex: 1; min-width: 0; }
.icon-btn-boxed {
  width: 52px; height: 52px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--primary);
  cursor: pointer;
}
.icon-btn-boxed:active { border-color: var(--primary); }
.icon-btn-boxed svg { width: 24px; height: 24px; }

.field-hint { font-size: 13px; color: var(--fg-muted); }
.danger-text { color: var(--danger); }

/* 4-keuze segmented mag over 2 rijen */
.segmented-wrap { flex-wrap: wrap; }
.segmented-wrap button { flex: 1 1 40%; }

/* ========== account ========== */
.account-hint { margin-bottom: 4px; }
#account-uit { display: flex; flex-direction: column; gap: 14px; }
.account-knoppen { display: flex; gap: 10px; }
.account-knoppen .btn { flex: 1; }
.account-status {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  word-break: break-all;
}
.account-status svg { width: 22px; height: 22px; flex: none; color: var(--accent); }

/* ========== menu ========== */
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--surface);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  font-family: inherit;
  font-size: 17px;
  color: var(--fg);
  cursor: pointer;
  text-align: left;
  transition: transform .15s ease;
}
.menu-item:active { transform: scale(.98); }
.menu-item .mi-icon { width: 26px; height: 26px; color: var(--primary); flex: none; }
.menu-item-tekst { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.menu-item-tekst strong { font-size: 17px; }
.menu-item-tekst span {
  font-size: 14px; color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-item .mi-chevron { width: 20px; height: 20px; color: var(--fg-muted); flex: none; }

/* ========== limiet-sheet ========== */
.limiet-inhoud { text-align: center; padding: 8px 8px 4px; }
.limiet-inhoud svg { width: 48px; height: 48px; color: var(--fg-muted); opacity: .5; margin-bottom: 8px; }
.limiet-inhoud h2 { font-size: 20px; margin-bottom: 8px; }
.limiet-inhoud p { color: var(--fg-muted); font-size: 15px; }

/* toelichting bij regel op offertescherm */
.regel-note {
  font-size: 13px; color: var(--fg-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-oms-blok { margin-bottom: 18px; white-space: pre-line; }

/* ========== status select ========== */
.status-select select {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 10px;
  width: auto;
}

/* ========== logo instellingen ========== */
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); }

/* ========== offerte-document ========== */
.doc {
  background: #FFFFFF;
  color: #0F172A;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  font-size: 15px;
  line-height: 1.55;
}
.doc-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; }
.doc-header > div:first-child { min-width: 0; }
.doc-header > div:last-child { flex: none; }
.doc-bedrijf, .doc-bedrijf-info { overflow-wrap: anywhere; }
.doc-logo { max-width: 110px; max-height: 64px; object-fit: contain; }
.doc-bedrijf { font-size: 20px; font-weight: 800; color: #1E3A5F; }
.doc-bedrijf-info { font-size: 13px; color: #55657A; white-space: pre-line; }
.doc-title { font-size: 26px; font-weight: 800; color: #1E3A5F; letter-spacing: .01em; }
.doc-meta { font-size: 13px; color: #55657A; text-align: right; }

.doc-klant { margin-bottom: 20px; }
.doc-klant-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #55657A; font-weight: 700; }
.doc-klant-naam { font-weight: 700; font-size: 17px; }

.doc-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.doc-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #55657A;
  padding: 8px 6px;
  border-bottom: 2px solid #1E3A5F;
}
.doc-table th.num, .doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-table td { padding: 10px 6px; border-bottom: 1px solid #E4E7EB; vertical-align: top; }
.doc-sub { font-size: 13px; color: #55657A; }

.doc-totals { margin-left: auto; width: 240px; max-width: 100%; display: flex; flex-direction: column; gap: 6px; margin-bottom: 24px; }
.doc-totals div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.doc-totals .doc-grand {
  font-size: 19px; font-weight: 800;
  border-top: 2px solid #1E3A5F;
  padding-top: 8px;
  color: #1E3A5F;
}

.doc-footer { font-size: 13px; color: #55657A; border-top: 1px solid #E4E7EB; padding-top: 14px; white-space: pre-line; }

/* ========== toast ========== */
.toast {
  position: fixed;
  bottom: calc(90px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
  animation: toast-in .25s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
