:root {
  --ink: #0f0d17;
  --accent: #6161c1;
  --accent-dark: #4d4da8;
  --muted: #6b6878;
  --line: #e3e2ea;
  --surface: #f5f4fa;
  --bg: #fbfbfd;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --warn-bg: #fff6e0;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 14px/1.45 "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

h1 { font-size: 22px; line-height: 1.2; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px 0; }
p { margin: 0 0 8px 0; }
a { color: var(--accent-dark); }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Indeling */

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.side {
  background: var(--ink);
  color: #fff;
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side .brand { font-weight: 700; letter-spacing: 0.04em; padding: 0 10px 2px; }
.side .tenant { color: #b8b8e3; font-size: 12px; padding: 0 10px 20px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  color: #d9d8e6;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}
.side nav a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.side nav a.active { background: var(--accent); color: #fff; font-weight: 600; }
.side .who { margin-top: auto; font-size: 12px; color: #b8b8e3; padding: 0 10px; }
.side .who strong { display: block; color: #fff; font-weight: 600; }
.side .who button { margin-top: 8px; background: none; border: 0; color: #b8b8e3; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

main { padding: 28px 36px 60px; max-width: 1280px; min-width: 0; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head .sub { color: var(--muted); margin-top: 4px; }
.head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head .actions select, .head .actions input { width: auto; }
.back { display: inline-block; margin-bottom: 10px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--ink); }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
.card.flush > h2 { padding: 16px 20px 0; }
.card > .card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card > .card-head h2 { margin: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cols.wide-left { grid-template-columns: minmax(0, 11fr) minmax(0, 9fr); }

/* Knoppen */

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}
button:hover, .btn:hover { border-color: #c9c7d6; background: var(--surface); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover, .btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.danger { color: var(--bad); }
button.small { padding: 3px 9px; font-size: 12.5px; }
button.link { border: 0; background: none; padding: 0; color: var(--accent-dark); font-weight: 600; }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Formulieren */

form.grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 14px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 4px; }
.field.w3 { grid-column: span 3; }
.field.w1 { grid-column: span 1; }
.field.w2 { grid-column: span 2; }
.field.w4 { grid-column: span 4; }
.field label, .field .label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--bad); }
.section-title { grid-column: span 6; font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

input, select, textarea {
  font: inherit;
  color: var(--ink);
  border: 1px solid #cfcdda;
  border-radius: 6px;
  padding: 7px 9px;
  background: #fff;
  width: 100%;
  min-width: 0;
}
input[type="color"] { padding: 2px; height: 34px; width: 60px; }
input[type="checkbox"] { width: auto; }
input:disabled, select:disabled { background: var(--surface); color: var(--muted); }
textarea { min-height: 70px; resize: vertical; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; padding: 6px 0; }
.checks label { font-size: 14px; font-weight: 400; color: var(--ink); display: flex; gap: 6px; align-items: center; }
.form-actions { grid-column: span 6; display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input, .inline select { width: auto; }

/* Tabellen */

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list th:first-child, table.list td:first-child { padding-left: 20px; }
table.list th:last-child, table.list td:last-child { padding-right: 20px; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface); }
table.list .right { text-align: right; }
table.list td.strong { font-weight: 600; }
.empty { padding: 22px 20px; color: var(--muted); }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--surface); color: var(--muted); white-space: nowrap; }
.chip.draft { background: #eeeef2; color: #4b4857; }
.chip.final, .chip.sent { background: #e9e9fa; color: var(--accent-dark); }
.chip.paid, .chip.ok { background: #e3f4ea; color: var(--ok); }
.chip.credited { background: #f3e9e9; color: #7a4a47; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.notice { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 14px; }
.notice.warn { background: var(--warn-bg); color: #5c3a00; }
.notice.bad { background: var(--bad-bg); color: #6d1711; }
.notice.info { background: var(--surface); }
.notice ul { margin: 4px 0 0 0; padding-left: 18px; }
.notice strong { display: block; }

/* Factuur */

.totals { margin-left: auto; width: 320px; max-width: 100%; border-collapse: collapse; }
.totals td { padding: 3px 20px 3px 0; text-align: right; }
.totals td:first-child { text-align: left; color: var(--muted); padding-left: 20px; }
.totals tr.total td { font-size: 17px; font-weight: 700; color: var(--ink); padding-top: 9px; padding-bottom: 16px; }
.preview { width: 100%; height: calc(100vh - 150px); min-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; position: sticky; top: 20px; }
td .line-desc { font-weight: 600; }
td .line-detail { color: var(--muted); font-size: 13px; }

/* Uren */

table.days { width: 100%; border-collapse: collapse; }
table.days th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.days td { padding: 3px 12px; border-bottom: 1px solid #f0eff5; }
table.days th:first-child, table.days td:first-child { padding-left: 20px; }
table.days tr.weekend td { background: #fafafc; color: var(--muted); }
table.days tr.week-start td { border-top: 1px solid var(--line); }
table.days input { width: 84px; text-align: right; padding: 4px 8px; }
table.days tfoot td { font-weight: 700; padding: 10px 12px; border-top: 1px solid var(--ink); border-bottom: 0; }
table.days tfoot td:first-child { padding-left: 20px; }

/* Inloggen */

.login { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 20px; }
.login .box { background: #fff; border-radius: 12px; padding: 30px 32px; width: 380px; max-width: 100%; }
.login h1 { margin-bottom: 6px; }
.login p { color: var(--muted); margin-bottom: 18px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .or { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0; }
.login button { width: 100%; padding: 9px 13px; }
.login .code { font-size: 22px; letter-spacing: 0.3em; text-align: center; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; }
#toast div { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 24px rgba(15, 13, 23, 0.25); max-width: 560px; }
#toast div.bad { background: var(--bad); }

dialog { border: 0; border-radius: 12px; padding: 24px 26px; width: 520px; max-width: calc(100vw - 40px); color: var(--ink); }
dialog::backdrop { background: rgba(15, 13, 23, 0.45); }
dialog h2 { font-size: 17px; }
dialog .form-actions { justify-content: flex-end; margin-top: 18px; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .tenant { padding-bottom: 0; }
  .side .who { margin: 0 0 0 auto; }
  main { padding: 20px 16px 50px; }
  .cols, .cols.wide-left { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; height: 80vh; }
}

/* De omschrijving van een factuurregel krijgt de ruimte; de getallen blijven smal. */
table.list td:has(.line-desc) { width: 48%; min-width: 220px; }

/* Koppelingen */
.switches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 24px; padding: 12px 20px 8px; }
.switch { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.token { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre-wrap;
  word-break: break-all; background: var(--surface); padding: 10px 12px; border-radius: 8px; margin: 8px 0 14px; }
ul.plain { margin: 8px 0 0; padding-left: 18px; color: var(--muted); }
ul.plain li { margin: 3px 0; }
.switches .field { grid-column: auto; margin: 0; }
.checks.consent { flex-direction: column; align-items: flex-start; gap: 8px; margin: 14px 0 18px; text-align: left; }
.login .notice { text-align: left; margin: 12px 0; }
.checks.consent input { flex: none; }

/* Versturen en betalingen */
.chip.bad { background: var(--bad-bg); color: var(--bad); }
table.list tr.bad td { background: var(--bad-bg); }
.field > label.switch { font-size: 14px; color: var(--ink); margin-top: auto; padding: 7px 0; }
ul.signals { margin: 0; padding: 0; list-style: none; }
ul.signals li { padding: 7px 0 7px 12px; border-left: 3px solid var(--line); margin: 4px 0; }
ul.signals li.warn { border-left-color: var(--warn); }
ul.signals li.bad { border-left-color: var(--bad); }
.recipient { margin: 2px 0; word-break: break-all; }
.recipient .detail { font-size: 12px; color: var(--bad); }
dialog:has(.mail-preview) { width: 720px; }
.checks.recipients { flex-direction: column; gap: 6px; }
.checks.recipients input { flex: none; }
.mail-preview { margin-top: 14px; }
table.mail-head { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
table.mail-head th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 12px 4px 0; width: 110px; vertical-align: top; white-space: nowrap; }
table.mail-head td { padding: 4px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.mail-body { font: inherit; white-space: pre-wrap; background: var(--surface); padding: 12px 14px; border-radius: 8px; margin: 0; max-height: 40vh; overflow-y: auto; }
