:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #16233a;
  --muted: #6b7280;
  --line: #e3dfd6;
  --accent: #e0902a;
  --accent-ink: #ffffff;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --bad: #c0392b;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 24px 16px; }
.small { font-size: 13px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.logo { background: var(--accent); color: var(--ink); border-radius: 8px; padding: 2px 7px; font-size: 14px; }
.top-actions { display: flex; gap: 8px; }
.chip {
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: inherit;
  border-radius: 999px; padding: 5px 12px; font-size: 14px; cursor: pointer;
}

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 16px; margin: 18px 0 8px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfc9bd; border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 12px 16px; min-height: 48px;
  font: inherit; font-weight: 700; cursor: pointer; background: var(--ink); color: #fff;
}
.btn.full { width: 100%; margin-top: 16px; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid #cfc9bd; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #e6b8b2; }
.btn.sm { min-height: 36px; padding: 6px 10px; font-size: 14px; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: default; }

.workers { display: grid; gap: 8px; }
.worker {
  display: grid; grid-template-columns: 1fr 96px; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px;
}
.worker input { text-align: center; font-weight: 700; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); overflow-x: auto;
}
.nav button {
  flex: 1 1 0; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 8px 6px 10px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.nav button .ic { font-size: 20px; line-height: 1; }
.nav button.on { color: var(--ink); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.bad { background: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.scroll { overflow-x: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); }

.list-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #eee; flex: none; cursor: pointer; }
.thumb.pdf { display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); font-size: 13px; text-decoration: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; background: #eee; }
.gallery figcaption { font-size: 12px; color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eee; }
.badge.nieuw { background: #fde8cc; color: #8a5300; }
.badge.in_billit { background: #d8f0e1; color: var(--ok); }
.badge.wacht_peppol { background: #e1e8f7; color: #2b4a8a; }
.badge.twijfel { background: #f8dcd8; color: var(--bad); }
.badge.snelle_invoer { background: #e9e1f7; color: #5a3a8a; }
.badge.prive { background: #e5e5e5; color: #444; }

.preview { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.warn { background: #fff5e0; border: 1px solid #f0d199; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }

.lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 96vw; max-height: 90vh; }
.lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; color: #fff; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: 1px solid #cfc9bd; background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 14px; cursor: pointer; }
.tabs button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
