:root {
  /* Chat als hoofdscherm, panelen schuiven in; rood uit de factuurhuisstijl als enige accent */
  --accent: #e5003a;
  --accent-soft: #fde4ea;
  --bg: #eef0f3;
  --surface: #ffffff;
  --ink: #18181b;
  --muted: #62626b;
  --line: #dcdde2;
  --user-bubble: #fbe2e8;
  --ok: #157f3b;
  --warn: #9a5b00;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #ff3d68; --accent-soft: #3a1520; --bg: #141317; --surface: #201e24; --ink: #f2f0f3;
    --muted: #a6a3ad; --line: #34313a; --user-bubble: #4a1a28; --ok: #4ccf7a; --warn: #f0b04a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Inloggen */
.login { min-height: 100%; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px 24px; }
.login-box { width: min(320px, 100%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.login h1 { margin: 10px 0 0; font-size: 22px; font-weight: 800; }
.login p { margin: 0; color: var(--muted); }
.dots { display: flex; gap: 14px; margin: 18px 0 6px; min-height: 16px; }
.dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); }
.dots span.on { background: var(--accent); }
.login-error { min-height: 22px; color: var(--accent) !important; font-size: 14px; font-weight: 600; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; margin-top: 8px; }
.pad button { height: 76px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pad button:active { background: var(--accent-soft); }
.pad button:disabled { opacity: .4; }

/* App */
.app { height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
header.bar { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.avatar.big { width: 64px; height: 64px; font-size: 22px; }
.who { flex: 1; min-width: 0; }
.who h1 { margin: 0; font-size: 15.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who p { margin: 0; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.live { background: transparent; color: var(--ok); border: 1px solid var(--ok); }
.iconbtn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 6px 10px; font-size: 14px; font-weight: 600; flex: none; }
.notice { margin: 10px 12px 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; background: var(--surface); border-left: 3px solid var(--warn); }

main#chat { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.msg { max-width: min(85%, 540px); padding: 8px 12px 6px; border-radius: 14px; background: var(--surface); box-shadow: 0 1px 0 rgba(0,0,0,.06); overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; border-top-left-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--user-bubble); border-top-right-radius: 4px; }
.msg .time { display: block; text-align: right; font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg img { display: block; max-width: 220px; max-height: 320px; border-radius: 8px; margin-bottom: 6px; }
.msg .buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.msg .buttons button { flex: 1 1 auto; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 9px 10px; font-weight: 700; color: var(--accent); }
.msg .buttons button:disabled { opacity: .45; cursor: default; }
.msg.typing { color: var(--muted); font-style: italic; }
.msg.error { border-left: 3px solid var(--accent); }
.empty-chat { margin: auto; text-align: center; color: var(--muted); max-width: 300px; font-size: 14.5px; }

.doc { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 6px 0 2px; }
.doc .ficon { width: 40px; height: 48px; border-radius: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; }
.doc strong { display: block; }
.doc small { color: var(--muted); font-variant-numeric: tabular-nums; }
.doc table { grid-column: 1 / -1; width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.doc td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.doc td.r { text-align: right; white-space: nowrap; padding-left: 10px; }
.doc tr.tot td { font-weight: 800; border-bottom: 0; padding-top: 6px; }
.doc a.dl { grid-column: 1 / -1; text-align: center; text-decoration: none; background: var(--accent); color: #fff; font-weight: 700; border-radius: 10px; padding: 10px; }

#preview { display: flex; gap: 8px; padding: 8px 12px 0; background: var(--surface); }
#preview:empty { display: none; }
#preview .thumb { position: relative; }
#preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
#preview button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--ink); color: var(--surface); font-size: 13px; line-height: 22px; padding: 0; }
form#composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
#text { flex: 1; resize: none; max-height: 140px; min-height: 44px; border: 1px solid var(--line); border-radius: 22px; padding: 10px 14px; background: var(--bg); font-size: 16px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); display: grid; place-items: center; flex: none; padding: 0; }
.round.send { background: var(--accent); border-color: var(--accent); color: #fff; }
.round:disabled { opacity: .5; cursor: default; }
.round svg { width: 20px; height: 20px; }

/* Panelen */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; justify-content: flex-end; z-index: 10; }
.overlay.left { justify-content: flex-start; }
.sheet { width: min(520px, 100%); height: 100%; overflow-y: auto; background: var(--surface); padding: max(16px, env(safe-area-inset-top)) 18px 28px; display: flex; flex-direction: column; gap: 16px; }
.sheet > header { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { margin: 0; font-size: 19px; font-weight: 800; }
.sheet h3 { margin: 0 0 8px; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sheet section { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 700; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13.5px; font-weight: 600; }
.field input, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: var(--bg); font-size: 16px; }
.field small, .check small { color: var(--muted); font-size: 12.5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.client { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.linkbtn { align-self: flex-start; border: 0; background: none; color: var(--accent); font-weight: 600; padding: 2px 0; }
.list { font-size: 14.5px; font-variant-numeric: tabular-nums; }
.list > div, .list > a, .list > button.row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; }
.list .row .t { min-width: 0; }
.list .row strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .row.active { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; padding-right: 8px; }
.list .amt { white-space: nowrap; font-weight: 700; }
.list .tag { font-size: 11px; font-weight: 700; color: var(--accent); }
.list .empty { color: var(--muted); border: 0; }
.primary { border: 0; background: var(--accent); color: #fff; border-radius: 10px; padding: 11px; font-weight: 700; }
.secondary { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 14px; font-weight: 600; }
.actions { display: flex; gap: 10px; position: sticky; bottom: -28px; background: var(--surface); padding: 12px 0; }
.actions .primary { flex: 1; }
.form-error { color: var(--accent); font-weight: 600; margin: 0; min-height: 1em; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } .msg { max-width: 92%; } .pad { grid-template-columns: repeat(3, 70px); } .pad button { height: 70px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
