:root {
  --bg: #f4f5f7; --panel: #fff; --ink: #111827; --muted: #6b7280; --line: #e5e7eb; --line2: #f0f1f3;
  --accent: #0f766e; --accent-ink: #fff; --danger: #dc2626; --warn: #b45309;
  --hour: 48px; --radius: 10px;
  --shadow: 0 10px 30px rgba(17,24,39,.14), 0 2px 6px rgba(17,24,39,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); cursor: pointer; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); width: min(380px, 100%); padding: 32px; border-radius: 14px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card .brand { font-size: 22px; }
.alert { background: #fef2f2; color: #991b1b; padding: 10px 12px; border-radius: 8px; }

/* ---------- form controls */
label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid #d1d5db; border-radius: 8px; padding: 7px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
input[type=color] { padding: 2px; height: 36px; width: 48px; }
input[type=checkbox] { width: auto; }
.btn { font: inherit; font-weight: 600; border: 1px solid #d1d5db; background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 13px; }
.btn.icon { padding: 6px 9px; }

/* ---------- top bar */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.logo { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); position: relative; display: inline-block; }
.logo::after { content: ""; position: absolute; left: 10px; top: 5px; width: 2px; height: 7px; background: #fff; box-shadow: 2px 5px 0 -0px #fff; border-radius: 1px; }
#nav { display: flex; gap: 2px; height: 100%; }
#nav a { display: flex; align-items: center; padding: 0 12px; color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 2px solid transparent; }
#nav a:hover { color: var(--ink); }
#nav a.active { color: var(--ink); border-bottom-color: var(--accent); }
.who { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
@media (max-width: 760px) {
  .top { gap: 10px; padding: 0 10px; overflow-x: auto; }
  .who { display: none; }
  #nav a { padding: 0 8px; }
}

main#app { padding: 16px 20px 40px; max-width: 1600px; margin: 0 auto; }
@media (max-width: 760px) { main#app { padding: 12px 10px 40px; } }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar h1 { font-size: 18px; margin: 0 10px 0 4px; letter-spacing: -.01em; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid #d1d5db; border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { font: inherit; border: 0; background: transparent; padding: 6px 10px; cursor: pointer; font-weight: 600; }
.seg button + button { border-left: 1px solid #e5e7eb; }
.seg button:hover { background: #f9fafb; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.notice { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; }

/* ---------- summary chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 8px; font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- week grid */
.cal { display: grid; grid-template-columns: 52px 1fr; overflow: hidden; }
.cal-head { display: grid; grid-template-columns: 52px repeat(7, 1fr); border-bottom: 1px solid var(--line); background: var(--panel); position: relative; z-index: 3; }
.cal-head .dh { padding: 8px 8px 6px; border-left: 1px solid var(--line2); min-width: 0; }
.cal-head .dh .d { font-weight: 700; font-size: 13px; }
.cal-head .dh .t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal-head .dh.today .d { color: var(--accent); }
.cal-head .dh .allday { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cal-head .dh .allday span { font-size: 11px; padding: 0 5px; border-radius: 4px; background: #f3f4f6; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-scroll { height: calc(100vh - 230px); min-height: 420px; overflow-y: auto; overflow-x: hidden; position: relative; }
.cal-body { display: grid; grid-template-columns: 52px repeat(7, 1fr); position: relative; height: calc(var(--hour) * 24); }
.gutter { position: relative; }
.gutter span { position: absolute; right: 6px; transform: translateY(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col { position: relative; border-left: 1px solid var(--line2); touch-action: none; user-select: none; -webkit-user-select: none;
  background-image: repeating-linear-gradient(to bottom, var(--line2) 0 1px, transparent 1px var(--hour)); cursor: crosshair; }
.col.weekend { background-color: #fafafa; }
.col.today { background-color: color-mix(in srgb, var(--accent) 3%, transparent); }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: #ef4444; z-index: 6; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }

.ev { position: absolute; border-radius: 6px; padding: 3px 6px; font-size: 11px; line-height: 1.25; overflow: hidden;
  border: 1px dashed color-mix(in srgb, var(--c) 55%, transparent); background: color-mix(in srgb, var(--c) 10%, transparent);
  color: color-mix(in srgb, var(--c) 75%, #374151); z-index: 1; cursor: copy; }
.ev:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }
.ev .tt { font-weight: 700; }
.ev .cn { opacity: .85; }

.trip { position: absolute; right: 1px; width: 7px; border-radius: 3px; z-index: 4; cursor: pointer; background: repeating-linear-gradient(135deg, var(--c) 0 3px, color-mix(in srgb, var(--c) 55%, #fff) 3px 6px); opacity: .9; min-height: 4px; }
.trip.unassigned { --c: #9ca3af; }
.trip:hover { width: 12px; opacity: 1; }

.entry { position: absolute; border-radius: 7px; padding: 4px 7px; font-size: 12px; line-height: 1.25; color: #fff; z-index: 3; overflow: hidden;
  background: var(--c); box-shadow: 0 1px 2px rgba(0,0,0,.18); cursor: grab; border: 1px solid color-mix(in srgb, var(--c) 70%, #000); }
.entry.nocl { --c: #6b7280; }
.entry .tt { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .ds { opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .tm { opacity: .85; font-variant-numeric: tabular-nums; font-size: 11px; }
.entry .rs { position: absolute; left: 0; right: 0; bottom: 0; height: 8px; cursor: ns-resize; }
.entry .rs::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 18px; height: 3px; margin-left: -9px; border-radius: 2px; background: rgba(255,255,255,.6); opacity: 0; }
.entry:hover .rs::after { opacity: 1; }
.entry.dragging { opacity: .85; cursor: grabbing; box-shadow: var(--shadow); z-index: 8; }
.sel { position: absolute; left: 2px; right: 10px; border-radius: 7px; background: color-mix(in srgb, var(--c, var(--accent)) 30%, transparent); border: 2px solid var(--c, var(--accent)); z-index: 7; pointer-events: none; font-size: 12px; padding: 3px 6px; font-weight: 700; color: color-mix(in srgb, var(--c, var(--accent)) 80%, #000); }

/* ---------- popover */
.pop { position: fixed; z-index: 50; width: 330px; max-width: calc(100vw - 20px); background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; display: grid; gap: 10px; }
.pop { grid-template-columns: minmax(0, 1fr); max-height: calc(100vh - 20px); overflow-y: auto; }
.pop > * { min-width: 0; }
.pop .row3 > *, .pop .row > * { min-width: 0; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; }
.pop h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.pop .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pop .row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.pop .acts { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.pop .acts .left { margin-right: auto; }
.hint { font-size: 12px; background: #ecfdf5; color: #065f46; border-radius: 6px; padding: 5px 8px; }
.hint.grey { background: #f3f4f6; color: var(--muted); }
.backdrop { position: fixed; inset: 0; z-index: 40; }

/* ---------- tables */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafafa; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.tbl tr.day td { background: #f9fafb; font-weight: 700; font-size: 13px; }
.tbl tr:hover td { background: #fcfcfd; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl .nw { white-space: nowrap; }
.tbl select { padding: 4px 8px; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--ink); }
.route { max-width: 520px; }
.route .a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route .a small { color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.badge.auto { background: #ecfdf5; color: #047857; }
.badge.manual { background: #eff6ff; color: #1d4ed8; }
.badge.src { background: #f5f3ff; color: #6d28d9; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) { .hide-sm { display: none; } }

.drop { border: 2px dashed #d1d5db; border-radius: var(--radius); padding: 14px; text-align: center; color: var(--muted); background: #fff; cursor: pointer; }
.drop.over { border-color: var(--accent); background: #f0fdfa; color: var(--accent); }

/* ---------- cards (klanten / instellingen) */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; align-content: start; }
.card h3 { margin: 0; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.card .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.card.archived { opacity: .6; }
.plist { display: flex; flex-wrap: wrap; gap: 6px; }
.plist span { background: #f3f4f6; border-radius: 6px; padding: 2px 4px 2px 8px; font-size: 13px; display: inline-flex; align-items: center; gap: 2px; }
.plist span button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 0 4px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 24px 0 8px; }
.help { font-size: 12px; color: var(--muted); font-weight: 400; }
.stack { display: grid; gap: 12px; max-width: 760px; }

#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 9px 16px; border-radius: 10px; font-weight: 600; opacity: 0; transition: .2s; z-index: 100; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

/* ---------- projecten in klantkaart */
.ptitle { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 4px; border-top: 1px solid var(--line2); padding-top: 10px; }
.plist2 { display: grid; gap: 6px; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) 96px auto auto; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; }
.prow .pName { grid-column: 1 / -1; font-weight: 600; font-size: 14px; padding: 6px 9px; background: #fff; }
.prow select, .prow .pRate { padding: 5px 8px; font-size: 13px; min-width: 0; }
.prow .pDel { color: var(--muted); font-size: 16px; padding: 2px 8px; }
.prow.done { background: #f3f4f6; }
.prow.done .pName { color: var(--muted); }
.padd { display: flex; gap: 6px; }
.padd input { padding: 6px 9px; flex: 1; min-width: 0; }
[hidden] { display: none !important; }
@media (max-width: 480px) { .prow { grid-template-columns: minmax(0, 1fr) 80px; } }

/* ---------- bewerk-blok + ritten in editor */
.sel.editing { z-index: 45; pointer-events: auto; cursor: grab; box-shadow: 0 0 0 3px rgba(255,255,255,.8), var(--shadow); left: 2px; right: 10px; }
.sel.editing:active { cursor: grabbing; }
.sel.editing .gl { pointer-events: none; }
.gh { position: absolute; left: 0; right: 0; height: 10px; cursor: ns-resize; }
.gh-t { top: -5px; } .gh-b { bottom: -5px; }
.gh::after { content: ""; position: absolute; left: 50%; top: 3px; width: 26px; height: 4px; margin-left: -13px; border-radius: 3px; background: var(--c, var(--accent)); }
.pop.wide { width: 420px; }
.pop textarea { resize: vertical; min-height: 40px; }
.tl-h { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.tl-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; max-height: 190px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.tl { min-width: 0; display: flex !important; flex-direction: row !important; align-items: center; gap: 6px !important; font-size: 12px !important; font-weight: 400 !important; color: var(--ink) !important; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.tl:hover { background: #f9fafb; }
.tl input { width: auto; }
.tl-r { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #374151; }
.tl-sum { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: right; }
