/* J&J Consultancy portaal — mobile-first */
:root {
  --navy: #14213d; --navy-2: #1f3260; --accent: #0e7c7b; --accent-2: #0b6463; --accent-soft: #e3f3f2;
  --bg: #f4f6f9; --card: #fff; --line: #e3e7ee; --text: #1d2433; --muted: #646c7a;
  --ok: #1a7f45; --ok-soft: #e4f4ea; --warn: #a15c00; --warn-soft: #fdf1dd; --bad: #b42318; --bad-soft: #fdeceb;
  --info-soft: #e8eefb; --radius: 12px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 4px 14px rgba(20,33,61,.05);
  --tabbar: 64px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; line-height: 1.25; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.hide-m { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.app { min-height: 100vh; padding-bottom: calc(var(--tabbar) + var(--safe-b) + 16px); }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--navy); color: #fff; display: flex; align-items: center;
  gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; letter-spacing: .2px; }
.brand:hover { text-decoration: none; }
.mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; flex: none; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: .8; }
.side { display: none; }
main { padding: 16px; max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin: 4px 0 16px; }
.page-head h1 { flex: 1 1 auto; min-width: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; margin-bottom: 6px; color: var(--muted); }

/* bottom tab bar (mobiel) */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b); }
.tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; color: var(--muted); background: none; border: 0; font-family: inherit; cursor: pointer; padding: 0; }
.tabbar a:hover { text-decoration: none; }
.tabbar svg { width: 23px; height: 23px; }
.tabbar .on { color: var(--accent); font-weight: 600; }
.tabbar .fab { position: relative; }
.tabbar .fab span.circle { width: 48px; height: 48px; margin-top: -22px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(14,124,123,.35); }
.tabbar .fab svg { width: 26px; height: 26px; }

.sheet-bg { position: fixed; inset: 0; background: rgba(10,16,30,.45); z-index: 50; display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; background: #fff; border-radius: 18px 18px 0 0;
  padding: 10px 12px calc(14px + var(--safe-b)); transform: translateY(105%); transition: transform .22s ease; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 8px; }
body.sheet-open .sheet { transform: none; }
body.sheet-open .sheet-bg { display: block; }
.sheet a, .sheet button { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 10px; color: var(--text);
  font-size: 16px; border: 0; background: none; border-radius: 10px; font-family: inherit; text-align: left; cursor: pointer; }
.sheet a:hover, .sheet button:hover { background: var(--bg); text-decoration: none; }
.sheet svg { width: 22px; height: 22px; color: var(--muted); }

/* ---------- componenten ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card > .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card > .card-head h2 { margin: 0; }
.card.flush > .card-head { padding: 14px 16px 0; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.bad .v { color: var(--bad); }
.kpi.accent { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpi.accent .l { color: rgba(255,255,255,.7); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--text); font: 600 14px/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #c9d0dc; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--bg); color: var(--muted); }
.badge.concept { background: #eef0f4; color: #4a5263; }
.badge.definitief { background: var(--info-soft); color: #2c4a8c; }
.badge.open { background: var(--info-soft); color: #2c4a8c; }
.badge.vervallen { background: var(--bad-soft); color: var(--bad); }
.badge.deels { background: var(--warn-soft); color: var(--warn); }
.badge.betaald, .badge.gecrediteerd { background: var(--ok-soft); color: var(--ok); }

.flash { background: var(--navy); color: #fff; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; background: var(--warn-soft); color: #6b3d00; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: #23407c; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }

/* lijsten (werken op mobiel én desktop) */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; color: var(--text); }
a.row:hover { background: #fafbfd; text-decoration: none; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* tabellen: op mobiel als kaartjes */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
@media (max-width: 699px) {
  .tbl.stack thead { display: none; }
  .tbl.stack, .tbl.stack tbody, .tbl.stack tr, .tbl.stack td, .tbl.stack tfoot { display: block; width: 100%; }
  .tbl.stack tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .tbl.stack td { border: 0; padding: 3px 2px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .tbl.stack td::before { content: attr(data-l); color: var(--muted); font-size: 13px; text-align: left; }
  .tbl.stack td.first { font-weight: 600; text-align: left; display: block; }
  .tbl.stack td.first::before { display: none; }
}

/* filters / tabs */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 14px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 14px; white-space: nowrap; }
.chip:hover { text-decoration: none; border-color: #c9d0dc; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input, .searchbar select { flex: 1; min-width: 0; }
.searchbar select { flex: 0 0 auto; width: auto; }

/* formulieren */
label { display: block; font-size: 13px; font-weight: 600; color: #3c4456; margin-bottom: 5px; }
.field { margin-bottom: 14px; min-width: 0; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel],
input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* voorkomt inzoomen op iOS */ color: var(--text); background: #fff;
  border: 1px solid #cfd5df; border-radius: 9px; padding: 10px 12px; min-height: 44px; appearance: none; -webkit-appearance: none; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23646c7a' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,124,123,.18); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); vertical-align: middle; margin: 0 8px 0 0; }
.check { display: flex; align-items: center; font-weight: 500; font-size: 14px; color: var(--text); cursor: pointer; }
.cols { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
.cols-2 { display: grid; gap: 0 12px; grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar) + var(--safe-b)); z-index: 20; background: rgba(244,246,249,.96);
  backdrop-filter: blur(6px); margin: 0 -16px; padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; }
.sticky-actions .btn { flex: 1; }
input[type=file] { font-size: 14px; max-width: 100%; }

/* factuurregels */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 8px;
  grid-template-columns: 1fr 1fr; grid-template-areas: "desc desc" "qty unit" "price vat" "total rm"; position: relative; }
.line .f-desc { grid-area: desc; } .line .f-qty { grid-area: qty; } .line .f-unit { grid-area: unit; }
.line .f-price { grid-area: price; } .line .f-vat { grid-area: vat; }
.line .f-total { grid-area: total; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.line .f-rm { grid-area: rm; justify-self: end; }
.line label { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); margin-bottom: 3px; }
.line textarea { min-height: 44px; height: 44px; }
.lines-head { display: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--bad); border-color: var(--bad-soft); }
.icon-btn svg { width: 18px; height: 18px; }
.totals { margin-left: auto; max-width: 340px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; gap: 20px; }
.totals .grand { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 8px; font-size: 18px; font-weight: 700; color: var(--navy); }

/* factuur-weergave */
.doc { background: #fff; }
.doc-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; font-size: 14px; }
.doc-meta .l { color: var(--muted); font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { padding: 6px 0 6px 18px; position: relative; border-left: 2px solid var(--line); margin-left: 4px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }

/* grafiek */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 150px; padding-top: 6px; }
.bars .m { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .pair { display: flex; gap: 2px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .b { width: 42%; max-width: 16px; border-radius: 3px 3px 0 0; background: var(--accent); min-height: 2px; }
.bars .b.k { background: #c7cfdc; }
.bars .m.future .b { opacity: .35; }
.bars .lbl { font-size: 10px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--accent); margin-right: 5px; vertical-align: -1px; }
.legend i.k { background: #c7cfdc; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 600; font-size: 14px; }
.tabs a.on { color: var(--navy); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.vat-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 6px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.vat-grid .h { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.vat-grid .r { text-align: right; white-space: nowrap; }
.vat-grid .sum { font-weight: 700; border-top: 2px solid var(--line); padding-top: 8px; }

/* inlogschermen */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px 16px; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 55%, #24507a 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 28px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .brand { color: var(--navy); margin-bottom: 18px; font-size: 18px; }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card p.lead { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-family: Consolas, "SF Mono", monospace; font-weight: 700; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; flex-wrap: wrap; gap: 8px; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

details.more summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 14px; list-style: none; padding: 4px 0; }
details.more summary::-webkit-details-marker { display: none; }

/* ---------- tablet ---------- */
@media (min-width: 560px) {
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .cols { grid-template-columns: 1fr 1fr; }
  .cols .full { grid-column: 1 / -1; }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  .hide-m { display: initial !important; }
  .hide-d { display: none !important; }
  .app { display: grid; grid-template-columns: 236px 1fr; padding-bottom: 0; }
  .topbar { display: none; }
  .tabbar, .sheet, .sheet-bg { display: none !important; }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--navy); color: #fff; padding: 18px 12px; }
  .side .brand { padding: 4px 8px 20px; }
  .side nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: rgba(255,255,255,.78); font-weight: 500; margin-bottom: 2px; }
  .side nav a:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
  .side nav a.on { background: rgba(255,255,255,.12); color: #fff; }
  .side nav a svg { width: 19px; height: 19px; opacity: .9; }
  .side .new { margin: 0 4px 16px; }
  .side .foot { margin-top: auto; font-size: 13px; color: rgba(255,255,255,.65); padding: 0 8px; }
  .side .foot button { background: none; border: 0; color: rgba(255,255,255,.8); padding: 6px 0; cursor: pointer; font: inherit; }
  .side .foot button:hover { color: #fff; text-decoration: underline; }
  main { padding: 26px 32px 40px; width: 100%; }
  h1 { font-size: 26px; }
  .grid.two { grid-template-columns: 1.5fr 1fr; align-items: start; }
  .grid.half { grid-template-columns: 1fr 1fr; align-items: start; }
  .cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .sticky-actions { position: static; background: none; border: 0; margin: 0; padding: 0; backdrop-filter: none; }
  .sticky-actions .btn { flex: 0 0 auto; }
  .lines-head { display: grid; grid-template-columns: 1fr 80px 80px 110px 112px 100px 40px; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); font-weight: 600; padding: 0 2px; }
  .lines-head .r { text-align: right; }
  .line { grid-template-columns: 1fr 80px 80px 110px 112px 100px 40px; grid-template-areas: "desc qty unit price vat total rm"; padding: 0; border: 0; background: none; align-items: start; }
  .line label { display: none; }
  .line .f-total { text-align: right; align-self: center; }
  .line + .line { padding-top: 2px; }
  .doc-meta { grid-template-columns: repeat(4, 1fr); }
  .card { padding: 20px; }
}
@media print {
  .side, .topbar, .tabbar, .sheet, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}
.totals #t-vat { display: block; padding: 0; }
.badge.verrekend { background: var(--ok-soft); color: var(--ok); }
.doc-meta { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.doc-meta > div { min-width: 0; overflow-wrap: anywhere; }
.grid > * { min-width: 0; }
@media (min-width: 900px) { .doc-meta { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
