/* Werkbon Basten – opmaak.
   Opzet: één smalle kolom voor de telefoon; zwarte kopbalken net als op de papieren werkbon,
   betongrijze achtergrond, staalblauw voor knoppen en aangevinkte keuzes. */
:root {
  --bg: #e9e8e4;          /* betongrijs */
  --surface: #ffffff;
  --ink: #16171a;         /* tekst en kopbalken */
  --muted: #5d5f66;
  --line: #cfcdc6;
  --bar: #16171a;         /* zwarte balk zoals op papier */
  --bar-ink: #ffffff;
  --accent: #1f4e8c;      /* staalblauw */
  --accent-ink: #ffffff;
  --accent-soft: #dfe7f3;
  --warn: #a33a12;
  --warn-soft: #fbe6dc;
  --ok: #2d6a3e;
  --ok-soft: #dff0e3;
  --font-head: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-body: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  /* Kopbalk is altijd wit (ook in donkere stand), zodat het logo er net zo uitziet als op de werkbon */
  --head-bg: #ffffff;
  --head-ink: #16171a;
  --head-line: #1f6fc0;   /* blauw uit het logo */
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141517; --surface: #1f2023; --ink: #ececea; --muted: #a3a5ab; --line: #393b40;
    --bar: #000000; --bar-ink: #ffffff; --accent: #6f9fe0; --accent-ink: #0b1626; --accent-soft: #1d2b40;
    --warn: #f08a5d; --warn-soft: #3a2017; --ok: #7cc48f; --ok-soft: #1b3122; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141517; --surface: #1f2023; --ink: #ececea; --muted: #a3a5ab; --line: #393b40;
  --bar: #000000; --bar-ink: #ffffff; --accent: #6f9fe0; --accent-ink: #0b1626; --accent-soft: #1d2b40;
  --warn: #f08a5d; --warn-soft: #3a2017; --ok: #7cc48f; --ok-soft: #1b3122; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 10; background: var(--head-bg);
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Kop */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--head-bg); color: var(--head-ink);
  border-bottom: 3px solid var(--head-line);
  padding-block: 8px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 12px;
}
/* iPad en groter: kopbalk netjes boven de kolom uitlijnen */
@media (min-width: 760px) {
  .top { padding-left: calc((100% - 720px) / 2 + 16px); padding-right: calc((100% - 720px) / 2 + 16px); }
}
.brand { display: block; height: 48px; width: auto; max-width: 45vw; }
.brand.small { height: 34px; }
.top .spacer { flex: 1; }
.top .nr { font-family: var(--font-head); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 1px; }
.top button.back { background: none; border: 1px solid var(--head-ink); color: var(--head-ink); white-space: nowrap; border-radius: 8px; padding: 6px 10px; }

main {
  max-width: 720px; margin: 0 auto;
  padding-block: 12px 120px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; flex-direction: column; gap: 16px;
}

/* Secties met zwarte kopbalk */
.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.section > h2 {
  margin: 0; background: var(--bar); color: var(--bar-ink);
  font-family: var(--font-head); font-weight: 700; font-size: 19px; letter-spacing: .3px;
  padding: 6px 12px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.section > h2 small { font-family: var(--font-body); font-weight: 400; font-size: 13px; opacity: .75; }
.section .body { padding: 12px; display: flex; flex-direction: column; gap: 12px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 420px) { .grid2.stack { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; min-width: 0; border: 1px solid var(--line); background: var(--surface);
  border-radius: 8px; padding: 10px; font-size: 16px; /* 16px voorkomt inzoomen op iPhone */
}
.field textarea { min-height: 80px; resize: vertical; }
.unit { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.unit input { border: 0; border-radius: 8px; flex: 1; min-width: 0; }
.unit em { font-style: normal; color: var(--muted); padding-right: 10px; font-size: 14px; }
.upper input { text-transform: uppercase; }

/* Werkregels (boren, zagen, sleuven) */
.row { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.row-head { display: flex; justify-content: space-between; align-items: center; }
.row-head b { font-family: var(--font-head); font-size: 17px; }
.row-sum { font-size: 14px; color: var(--muted); }
.label { font-size: 13px; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 12px; font-size: 15px; cursor: pointer; min-height: 38px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip.need { border-color: var(--warn); background: var(--warn-soft); }

.btn {
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink);
  border-radius: 10px; padding: 12px 16px; font-weight: 600; cursor: pointer; min-height: 46px;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--warn); border-color: var(--warn); }
.btn.small { padding: 6px 10px; min-height: 36px; font-size: 14px; }
.btn.wide { width: 100%; }
.linkbtn { background: none; border: 0; color: var(--warn); padding: 4px; font-size: 14px; cursor: pointer; }

/* WKA dagen */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.days .chip { padding: 6px 0; text-align: center; border-radius: 8px; font-size: 14px; }

/* Regie-uren */
.regie { display: grid; grid-template-columns: 1fr 110px; gap: 8px 10px; align-items: center; }
.regie label { font-size: 15px; }
.regie .total { font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.regie .total.v { text-align: right; padding-right: 10px; font-variant-numeric: tabular-nums; }

/* Foto's */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; max-width: 100%; border-radius: 8px; overflow: hidden; background: var(--bg); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 999px; width: 30px; height: 30px; background: rgba(0,0,0,.65); color: #fff; font-size: 18px; line-height: 1; }
.filebtn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Handtekeningvak: altijd wit met zwarte inkt, ook in donkere modus, zodat het op de pdf goed staat */
.sig { position: relative; background: #ffffff; border: 2px solid var(--line); border-radius: var(--radius); }
.sig canvas { display: block; width: 100%; height: 220px; touch-action: none; cursor: crosshair; border-radius: var(--radius); }
@media (min-width: 760px) { .sig canvas { height: 260px; } }
.sig-line { position: absolute; left: 16px; right: 16px; bottom: 40px; border-bottom: 1px solid #b9b7b0; color: #8a8880; font-size: 18px; line-height: 1; pointer-events: none; }
.sig-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.sig-img { max-width: 260px; width: 100%; height: auto; display: block; }
.terms { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* Meldingen */
.notice { border-radius: var(--radius); padding: 10px 12px; font-size: 15px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice ul { margin: 6px 0 0; padding-left: 20px; }

/* Lijst */
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center;
  text-align: left; width: 100%; cursor: pointer;
}
.card .no { font-family: var(--font-head); font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; grid-row: span 2; }
.card .who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .meta { font-size: 14px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; padding: 3px 8px; border-radius: 999px; grid-row: span 2; }
.pill.concept { background: var(--accent-soft); color: var(--accent); }
.pill.klaar { background: var(--ok-soft); color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.hint { font-size: 13px; color: var(--muted); }

/* Onderbalk met acties */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; gap: 10px; justify-content: center;
}
.actions .btn { flex: 1; max-width: 340px; }
.saved { font-size: 12px; color: var(--muted); text-align: center; }

/* Voorbeeld van de werkbon zoals de klant hem krijgt */
.sheet { background: #fff; color: #111; border-radius: 6px; padding: 16px; font-size: 14px; border: 1px solid var(--line); }
.sheet h3 { font-family: var(--font-head); background: #111; color: #fff; margin: 14px -4px 6px; padding: 3px 8px; font-size: 16px; }
.sheet table { width: 100%; border-collapse: collapse; }
.sheet td { padding: 3px 4px; vertical-align: top; border-bottom: 1px dotted #bbb; }
.sheet td.k { color: #555; width: 40%; }
.sheet .head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sheet-logo { display: block; width: 210px; max-width: 100%; height: auto; margin-bottom: 8px; }
.sheet .head b { font-family: var(--font-head); font-style: italic; font-weight: 800; font-size: 30px; }
.sheet .wbnr { border: 1px solid #111; padding: 4px 10px; font-family: var(--font-head); font-size: 20px; font-variant-numeric: tabular-nums; align-self: flex-start; }
.sheet .addr { font-size: 12px; color: #333; }
.sheet .terms { color: #555; }
.sheet .photos img { border-radius: 4px; }

/* Klant zoeken */
.klant-zoek { position: relative; }
.suggesties {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 4; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; display: flex; flex-direction: column;
}
.suggestie {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; cursor: pointer; min-height: 48px;
}
.suggestie:last-child { border-bottom: 0; }
.suggestie:hover, .suggestie:focus-visible { background: var(--accent-soft); }
.suggestie small { color: var(--muted); font-size: 13px; }

/* Onderaan de lijst en inloggen */
.footer-info { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.footer-info span { min-width: 0; overflow-wrap: anywhere; }
.login { display: flex; flex-direction: column; gap: 12px; }
