:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1b1f27;
  --muted: #5d6573;
  --line: #e2e5ea;
  --accent: #2457d6;
  --accent-soft: #e8eefc;
  --error: #b42318;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b1f27;
    --text: #e8eaee;
    --muted: #9aa3b2;
    --line: #2d333d;
    --accent: #6d95ff;
    --accent-soft: #1e2a47;
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 960px; margin: 0 auto; padding: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); position: relative; }
.logo::after { content: ""; position: absolute; inset: 6px 8px; background: #fff; border-radius: 2px; }
.lang select {
  font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
}

main { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }

.intro h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); text-align: center; margin: 24px auto 12px; max-width: 760px; }
.lead { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }

.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 48px 16px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.drop-icon { font-size: 2rem; color: var(--accent); }
.drop-title { font-size: 1.15rem; font-weight: 600; margin: 8px 0 4px; }
.drop p { margin: 0; }

.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: 8px; }
.error { color: var(--error); text-align: center; font-weight: 600; }

.features {
  list-style: none; padding: 0; margin: 32px 0 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 900px) { .features { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 480px) { .features { grid-template-columns: 1fr; } }
.features li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.features strong { display: block; margin-bottom: 4px; }
.features span { color: var(--muted); font-size: 0.925rem; }

.faq { margin-top: 48px; }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 8px 0 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 16px; }
.spacer { flex: 1; }
.btn {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: #fff; text-decoration: none; display: inline-block;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 0.875rem; }

.invoice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.invoice h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 8px; }
.invoice section { margin-top: 24px; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
.inv-head h2 { margin: 0 0 4px; font-size: 1.5rem; }
.inv-head p { margin: 0; }
.due { text-align: right; }
.due strong { display: block; font-size: 1.6rem; }

.parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.party p { margin: 0; }
.party-name { font-weight: 700; font-size: 1.05rem; }

.kvs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 24px; margin: 24px 0 0; }
.party .kvs { grid-template-columns: 1fr; gap: 2px; margin-top: 10px; }
.kv dt { font-size: 0.8rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.party .kv { display: flex; gap: 6px; }
.party .kv dt::after { content: ":"; }

.table-wrap { overflow-x: auto; margin-top: 24px; }
.lines { width: 100%; border-collapse: collapse; }
.lines th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); padding: 8px; }
.lines td { border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
.lines .num { text-align: right; white-space: nowrap; }
.lines.compact td { padding: 6px 8px; }
.item { font-weight: 600; display: block; }
.sub { display: block; color: var(--muted); font-size: 0.85rem; }
.unit { color: var(--muted); font-size: 0.85rem; }

.allowances { list-style: none; padding: 0; margin: 12px 0 0; color: var(--muted); }

.bottom { display: grid; grid-template-columns: 1fr minmax(260px, 340px); gap: 24px; align-items: start; }
.bottom > section { margin-top: 24px; }
.bottom > section .table-wrap { margin-top: 0; }
.totals { width: 100%; border-collapse: collapse; margin-top: 24px; }
.totals th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 0; }
.totals td { text-align: right; padding: 6px 0; white-space: nowrap; }
.totals .grand th, .totals .grand td { border-top: 2px solid var(--text); font-weight: 700; color: var(--text); font-size: 1.15rem; padding-top: 10px; }

.payment { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 20px; }
.payment .kvs { margin-top: 0; }
.payment > div:first-child { flex: 1; min-width: 240px; }
.qr { width: 180px; text-align: center; }
.qr:empty { display: none; }
.qr svg { width: 160px; height: 160px; background: #fff; border-radius: 6px; }
.qr-title { font-weight: 600; margin: 0 0 6px; }
.qr p { margin: 4px 0 0; }
.note { white-space: pre-line; margin: 0 0 6px; }

.attachments { list-style: none; padding: 0; margin: 0; }
.attachments li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.footer { text-align: center; color: var(--muted); font-size: 0.875rem; padding: 24px 16px 40px; }

@media (max-width: 640px) {
  .invoice { padding: 16px; }
  .parties, .bottom { grid-template-columns: 1fr; }
  .due { text-align: left; }
  .toolbar .spacer { display: none; }
}

@media print {
  :root { --bg: #fff; --surface: #fff; --text: #000; --muted: #444; --line: #ccc; }
  body { background: #fff; font-size: 11pt; }
  .no-print { display: none !important; }
  main { padding: 0; max-width: none; }
  .invoice { border: 0; padding: 0; }
  .table-wrap { overflow: visible; }
  tr { break-inside: avoid; }
}

/* ---------- Factuurkit hub ---------- */
.langs { display: flex; gap: 4px; }
.langs a, .langs span { padding: 4px 8px; border-radius: 6px; font-size: 0.875rem; font-weight: 600; text-decoration: none; }
.langs a { color: var(--muted); }
.langs a:hover { background: var(--accent-soft); color: var(--accent); }
.langs span { background: var(--accent); color: #fff; }

.tool-grid { list-style: none; padding: 0; margin: 24px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.tool-grid a { display: block; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s; }
.tool-grid a:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-grid strong { display: block; margin: 6px 0 4px; }
.tool-grid span:not(.tool-icon) { color: var(--muted); font-size: 0.9rem; }
.tool-icon { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 6px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.95rem; }
.more { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.more h2 { font-size: 1.1rem; }
.small-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 8px; }
.small-grid a { padding: 12px; }
.small-grid span:not(.tool-icon) { display: none; }
.small-grid strong { margin: 0; display: inline; margin-left: 8px; font-size: 0.95rem; }

.prose { max-width: 720px; }
.prose p { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.field small { color: var(--muted); font-size: 0.8rem; }
.checkbox { display: flex; gap: 8px; align-items: center; font-size: 0.95rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.big-input { font-size: 1.15rem !important; padding: 12px 14px !important; }

.result { margin-top: 16px; }
.result:empty { display: none; }
.status { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); margin-top: 10px; }
.status .dot { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 0.9rem; }
.status.ok .dot { background: #1a7f37; }
.status.bad .dot { background: #c62828; }
.status.warn .dot { background: #b26a00; }
.status p { margin: 2px 0 0; color: var(--muted); }
.status strong { display: block; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .02em; }
.big-value { font-size: 1.6rem; font-weight: 700; margin: 4px 0; overflow-wrap: anywhere; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.result-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 6px 0; }
.result-table td { text-align: right; padding: 6px 0; font-weight: 600; }
.result-table tr + tr th, .result-table tr + tr td { border-top: 1px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font: inherit; font-size: 0.9rem; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.qr-box { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.qr-box .qr-img svg { width: 220px; height: 220px; background: #fff; border-radius: 8px; padding: 4px; }
.holiday-list { list-style: none; padding: 0; margin: 8px 0 0; columns: 2; column-gap: 24px; }
.holiday-list li { break-inside: avoid; padding: 4px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; }
.lines-editor { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lines-editor th { text-align: left; font-size: 0.8rem; color: var(--muted); padding: 4px; }
.lines-editor td { padding: 4px; vertical-align: top; }
.lines-editor input, .lines-editor select { font: inherit; padding: 7px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); width: 100%; }
.lines-editor .num input { text-align: right; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.1rem; padding: 6px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0 0; }
legend { font-weight: 700; padding: 0 6px; }
@media (max-width: 640px) {
  .holiday-list { columns: 1; }
  .lines-editor thead { display: none; }
  .lines-editor tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .lines-editor td:first-child { grid-column: 1 / -1; }
}

/* Elements with display rules must still honour the hidden attribute. */
[hidden] { display: none !important; }

/* A checkbox row inside a form grid stays horizontal. */
.field.checkbox { flex-direction: row; align-items: center; }
/* Invoice lines: give the description room; scroll sideways on narrow screens instead of squeezing it. */
.lines-wrap { overflow-x: auto; }
.lines-editor td:first-child { min-width: 14em; }
.lines .num, .lines td:nth-child(3) { white-space: nowrap; }
@media (max-width: 640px) { .lines-editor td:first-child { min-width: 0; } }
.field.checkbox input { width: auto; }
.field.checkbox > span { font-size: 0.95rem; font-weight: 400; color: var(--text); }

/* ---------- AI converter & pricing ---------- */
.badge { display: inline-block; margin-top: 16px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.8rem; }
.intro .badge + h1 { margin-top: 8px; }
.intro:has(.badge) { text-align: center; }
.quota { text-align: right; }
.drop.disabled { opacity: .5; pointer-events: none; }
.busy { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 16px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.pricing { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.plan { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.plan h2 { margin: 0; font-size: 1.1rem; }
.plan .price { font-size: 2rem; font-weight: 800; margin: 8px 0; }
.plan ul { padding-left: 18px; color: var(--muted); }
.plan.pro { border: 2px solid var(--accent); }
.pricing.is-pro .plan.pro .btn { display: none; }
.ai-notice { border: 2px solid var(--accent); }
@media (max-width: 640px) { .pricing { grid-template-columns: 1fr; } .quota { text-align: left; } }

/* ---------- Guides ---------- */
.guide-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.guide-grid a span { display: block !important; }
.article { max-width: 760px; margin: 0 auto; }
.article h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); margin: 24px 0 8px; }
.article .meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 24px; }
.article h2 { margin-top: 32px; }
.article p, .article li { line-height: 1.65; }
.article table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.95rem; }
.article th, .article td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.article th { color: var(--muted); font-weight: 600; }
.cta { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 18px 20px; margin: 28px 0; }
.cta strong { display: block; font-size: 1.1rem; margin-bottom: 6px; }
.cta .btn { margin-top: 10px; }
.callout { border-left: 4px solid var(--accent); padding: 4px 0 4px 14px; margin: 16px 0; color: var(--muted); }
.sources { font-size: 0.85rem; color: var(--muted); }
