:root {
  --bg: #0f1729;
  --panel: #ffffff;
  --ink: #1a2233;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #1e6fd9;
  --brand-dark: #1556ab;
  --accent: #0fb3a1;
  --warn: #d9831e;
  --danger: #d64545;
  --soft: #f6f8fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: #eef2f7;
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(120deg, #142544, #1e3a6b);
  color: #fff;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 26px;
  box-shadow: var(--shadow);
}
.topbar .brand { font-weight: 700; font-size: 17px; letter-spacing: .3px; }
.topbar .brand span { color: #6fb4ff; }
.topbar nav { display: flex; gap: 6px; margin-left: 8px; }
.topbar nav a {
  color: #cdd9ee; text-decoration: none; padding: 8px 14px; border-radius: 8px;
  font-weight: 500;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); color:#fff; }
.topbar nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #9fb3d4; font-size: 13px; }
.envbadge { font-size: 11px; font-weight: 800; letter-spacing: .5px; padding: 4px 10px; border-radius: 20px; }
.envbadge.env-test { background: #1e6fd9; color: #fff; }
.envbadge.env-production { background: #d64545; color: #fff; }
.envsel { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.envsel button { padding: 9px 18px; border: 1px solid var(--line); background: #fff; border-radius: 9px; cursor: pointer; font-weight: 700; color: #46536b; }
.envsel button.on { color: #fff; border-color: transparent; }
.envsel button.on.test { background: #1e6fd9; }
.envsel button.on.production { background: #d64545; }
.envsel .hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Layout ---------- */
.wrap { max-width: 1280px; margin: 22px auto; padding: 0 22px; }
.split { display: grid; grid-template-columns: 420px 1fr; gap: 22px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card .hd {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-weight: 700; display: flex; align-items: center; gap: 10px;
}
.card .hd .sub { font-weight: 400; color: var(--muted); font-size: 12px; }
.card .bd { padding: 16px 18px; }
.sticky { position: sticky; top: 22px; }

/* ---------- Wizard ---------- */
.q { margin-bottom: 14px; }
.q label.qlabel { display: block; font-weight: 600; margin-bottom: 6px; color: #2a3650; }
.q .qnum { color: var(--brand); font-weight: 700; margin-right: 6px; }
.q input, .q select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fff; color: var(--ink);
}
.q input:focus, .q select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,111,217,.12); }
.q .warn { color: var(--warn); font-size: 12.5px; margin-top: 5px; display: flex; gap: 6px; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 9px;
  cursor: pointer; font-weight: 600; color: #46536b; font-size: 13.5px;
}
.seg button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg button:hover:not(.on) { border-color: var(--brand); color: var(--brand); }

/* ---------- Quote ---------- */
.qsection { margin-bottom: 10px; }
.qsection h4 {
  margin: 0; font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--brand-dark); padding: 10px 0 4px; border-bottom: 2px solid var(--soft);
}
table.lines { width: 100%; border-collapse: collapse; }
table.lines td, table.lines th { padding: 6px 8px; font-size: 13px; }
table.lines th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; }
table.lines td.num, table.lines th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.lines tr.line td { border-top: 1px solid var(--line); }
table.lines tr.subtotal td { font-weight: 700; border-top: 2px solid var(--line); }
.code { color: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; }

.totals { margin-top: 14px; border-top: 2px solid var(--ink); padding-top: 10px; }
.totals .row { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 19px; font-weight: 800; color: var(--brand-dark); }
.totals .korting { color: var(--danger); }

.slabox { margin-top: 16px; background: var(--soft); border-radius: 10px; padding: 12px 14px; }
.slabox .sla-total { font-weight: 800; font-size: 16px; color: var(--accent); }

.margebox { margin-top: 16px; border: 1px dashed #c8b06a; background: #fffdf3; border-radius: 10px; padding: 12px 14px; }
.margebox .tag { font-size: 11px; font-weight: 700; color: #9a7b1e; text-transform: uppercase; letter-spacing: .5px; }
.margebox .row { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.margebox .row.tot { border-top: 1px solid #e3d39a; font-weight: 700; margin-top: 4px; padding-top: 6px; }

/* ---------- Buttons / meta ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 9px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 700;
  cursor: pointer; font-size: 14px; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.ghost:hover { background: var(--soft); }
.btn.gray { background:#fff; border-color: var(--line); color:#46536b; }
.btn:disabled { opacity:.5; cursor: not-allowed; }

.metagrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metagrid label { font-size: 12px; color: var(--muted); font-weight: 600; display:block; margin-bottom:3px; }
.metagrid input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }

.empty { color: var(--muted); text-align: center; padding: 30px 10px; }

/* ---------- AFAS ---------- */
.afas { background: #f0f7ff; border: 1px solid #cfe0fb; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.afas-lbl { font-size: 12px; font-weight: 700; color: #1556ab; display: block; margin-bottom: 6px; }
.afas-search { position: relative; }
.afas-search input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; }
.afas-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 9px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; display: none; }
.afas-results.show { display: block; }
.afas-results .item { padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--soft); }
.afas-results .item:hover { background: var(--soft); }
.afas-results .item .nm { font-weight: 600; }
.afas-results .item .meta { font-size: 12px; color: var(--muted); }
.afas-results .msg { padding: 10px 11px; color: var(--muted); font-size: 13px; }
.afas-picked { margin-top: 8px; font-size: 13px; background: #e6f6ee; border: 1px solid #b8e6cd; color: #1c7a4a; border-radius: 8px; padding: 8px 11px; display: flex; justify-content: space-between; align-items: center; }
.afas-picked button { background: none; border: 0; color: #1c7a4a; cursor: pointer; font-weight: 700; }

/* ---------- Login ---------- */
.loginwrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#142544,#1e3a6b); }
.logincard { width: 360px; background:#fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); padding: 30px; }
.logincard h1 { margin: 0 0 4px; font-size: 22px; }
.logincard h1 span { color: var(--brand); }
.logincard p { color: var(--muted); margin: 0 0 22px; }
.logincard label { font-size: 12px; font-weight: 600; color: var(--muted); }
.logincard input { width:100%; padding: 11px; border:1px solid var(--line); border-radius:9px; margin: 5px 0 14px; }
.logincard .err { background:#fdeaea; color:var(--danger); padding:9px 12px; border-radius:8px; font-size:13px; margin-bottom:14px; }
.logincard .btn { width:100%; justify-content:center; }

/* ---------- Admin ---------- */
.admin-section { margin-bottom: 22px; }
.admin-section h3 { margin: 0 0 8px; font-size: 15px; color: var(--brand-dark); }
.section-block { margin-bottom: 18px; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.section-head .sname { flex: 1; font-size: 15px; font-weight: 700; color: var(--brand-dark); padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- Modal (nieuwe klant) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,37,68,.45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { width: 640px; max-width: 100%; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.modal-hd { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-hd h3 { margin: 0; font-size: 17px; flex: 1; color: var(--brand-dark); }
.modal-x { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
.modal-bd { padding: 18px 20px; }
.modal-ft { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.nc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.nc-grid label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 3px; }
.nc-grid input, .nc-grid select { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.nc-grid .nc-full { grid-column: 1 / -1; }
.nc-grid .nc-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #46536b; margin-top: 20px; }
.nc-grid .nc-check input { width: auto; }
.nc-sep { grid-column: 1 / -1; font-weight: 700; color: var(--brand-dark); font-size: 13px; border-top: 1px solid var(--soft); padding-top: 12px; margin-top: 2px; }
.nc-hint { font-size: 12px; color: var(--muted); margin-top: 14px; line-height: 1.5; }

/* ---------- Wachtwoord wijzigen ---------- */
.pwform label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 4px; }
.pwform input { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; }
.pwform .btn { margin-top: 18px; }

/* ---------- Freshdesk-velden bij offerte ---------- */
.fdfields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin: 14px 0; padding: 12px 14px; background: #f7f5ff; border: 1px solid #ddd6f7; border-radius: 10px; }
.fdfields .fd-lbl { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: #5b3fb0; }
.fdfields label { font-size: 11px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 3px; }
.fdfields select, .fdfields input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; }

.section-head .btn { padding: 6px 12px; font-size: 13px; }
.btn.gray { background:#fff; border:1px solid var(--line); color:#46536b; }
table.prices { width: 100%; border-collapse: collapse; }
table.prices th, table.prices td { padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13px; text-align: left; }
table.prices th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing:.4px; }
table.prices td.num { text-align: right; }
table.prices input { width: 92px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; text-align: right; font-variant-numeric: tabular-nums; }
table.prices input.lbl { width: 100%; text-align: left; }
table.prices input.afascode { width: 110px; text-align: left; font-family: ui-monospace, monospace; }
table.prices select.vait { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.savebar { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 10px; align-items: center; border-radius: 0 0 var(--radius) var(--radius); }
.toast { padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.toast.ok { background: #e6f6ee; color: #1c7a4a; }
.toast.err { background: #fdeaea; color: var(--danger); }
.note { background:#eef5ff; border:1px solid #cfe0fb; color:#1556ab; padding:10px 14px; border-radius:9px; font-size:13px; margin-bottom:16px; }
