:root {
    --primary: #b03232;
    --primary-hover: #8d2929;
    --primary-soft: rgba(176, 50, 50, 0.10);
    --bg: #f4f4f5;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success: #16a34a;
    --success-soft: rgba(22, 163, 74, 0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.15);
    --danger: #b03232;
    --danger-soft: rgba(176, 50, 50, 0.12);
    --info: #0369a1;
    --info-soft: rgba(3, 105, 161, 0.12);
    --radius: 0.5rem;
    --topbar-h: 80px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    line-height: 1.5;
}

a { color: inherit; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    background: var(--card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

/* Logo-veld even hoog als de topbar (gewone weergave) */
@media (min-width: 901px) {
    .brand { height: var(--topbar-h); padding: 0 1.25rem; }
}

.brand-logo {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 0.6rem;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.3rem;
    flex-shrink: 0;
}

.brand-logo img { width: 100%; height: 100%; object-fit: contain; }

.brand-name {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.nav {
    flex: 1;
    padding: 0.75rem;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    margin-bottom: 0.125rem;
}

.nav-link svg { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--primary); color: #fff; border-radius: 9999px; font-size: 0.68rem; font-weight: 700; padding: 0.05rem 0.45rem; line-height: 1.3; }

.nav-link:hover { background: #f1f5f9; color: var(--text); }

.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.875rem 1rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.625rem;
}

.sidebar-avatar,
.topbar-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 9999px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sidebar-user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.sidebar-user-meta strong { font-weight: 600; color: var(--text); font-size: 0.85rem; }
.sidebar-user-meta span { color: var(--text-muted); font-size: 0.75rem; }

.logout-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: background 0.15s ease, color 0.15s ease;
}

.logout-link svg { width: 1rem; height: 1rem; }

.logout-link:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Main ---------- */
.main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    min-height: var(--topbar-h);
    position: sticky;
    top: 0;
    z-index: 40;
}

.page-title h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.page-title p { color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }

.topbar-actions { display: flex; align-items: center; gap: 0.625rem; }

.content {
    padding: 1.5rem;
    flex: 1;
}

/* ---------- Cards ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.card-pad { padding: 1.25rem; }

.grid { display: grid; gap: 1rem; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.status-knoppen { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.status-knop {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    background: #fff;
    color: var(--text);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.status-knop:hover { border-color: var(--primary); color: var(--primary); }
.status-knop.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* Volgorde in de bestelling-detail: producten links, reacties rechts */
.card-producten { order: 1; }
.card-reacties { order: 2; }
.mt-4 { margin-top: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }

/* ---------- Stat cards ---------- */
.stat-card {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 1.125rem;
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 1.35rem; height: 1.35rem; }

.stat-icon.red { background: var(--danger-soft); color: var(--primary); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.orange { background: var(--warning-soft); color: var(--warning); }
.stat-icon.blue { background: var(--info-soft); color: var(--info); }

.stat-meta { min-width: 0; }

.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }
.stat-desc { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.1rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    background: #fff;
    color: var(--text);
}

.btn svg { width: 1rem; height: 1rem; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline { border-color: #d1d5db; background: #fff; color: var(--text); }
.btn-outline:hover { background: #f8fafc; border-color: #9ca3af; }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

.btn-danger { background: var(--primary); color: #fff; }
.btn-danger:hover { background: var(--primary-hover); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

/* ---------- Icoonknoppen (acties) ---------- */
.actie-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.actie-btn svg { width: 1rem; height: 1rem; }
.actie-btn:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.actie-btn:active { transform: scale(0.95); }
.actie-btn.actie-btn-leeg { border-color: transparent; background: transparent; }

/* Productlijn-acties: op desktop inline, op mobiel inklapbaar via de opties-knop */
.rij-opties-btn { display: none; }
.rij-acties { display: inline-flex; align-items: center; gap: 0.4rem; }
.rij-acties form { display: inline-flex; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-open { background: var(--danger-soft); color: var(--primary); }
.badge-gepland { background: var(--info-soft); color: var(--info); }
.badge-behandeling { background: var(--warning-soft); color: #b45309; }
.badge-onderdeel { background: #f3e8ff; color: #6b21a8; }
.badge-klant { background: #e0e7ff; color: #3730a3; }
.badge-afgerond { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-factureren { background: #fde68a; color: #92400e; }
.badge-geannuleerd { background: #e2e8f0; color: #475569; }

.badge-rol-admin { background: var(--danger-soft); color: var(--primary); }
.badge-rol-backoffice { background: var(--warning-soft); color: #b45309; }
.badge-rol-technieker { background: var(--info-soft); color: var(--info); }

.badge-prio-laag { background: #e2e8f0; color: #475569; }
.badge-prio-normaal { background: var(--info-soft); color: var(--info); }
.badge-prio-hoog { background: var(--warning-soft); color: #b45309; }
.badge-prio-urgent { background: var(--danger-soft); color: var(--primary); }

/* Ticket categorieen */
.badge-cat-mfp { background: var(--info-soft); color: var(--info); }
.badge-cat-it { background: #e0e7ff; color: #3730a3; }
.badge-cat-interne-herstelling { background: #fce7f3; color: #9d174d; }
.badge-cat-levering-machine { background: var(--success-soft); color: var(--success); }
.badge-cat-levering-winkel { background: #fde68a; color: #92400e; }
.badge-cat-toners { background: #f3e8ff; color: #6b21a8; }
.badge-cat-kopiecenter { background: var(--warning-soft); color: #b45309; }
.badge-cat-bestellingen { background: #ffe4e6; color: #9f1239; }
.badge-cat-algemeen { background: #e2e8f0; color: #475569; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

table.table { width: 100%; border-collapse: collapse; }

.table thead th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    background: #fff;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

.table .link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}
.table .link:hover { color: var(--primary); }

.muted { color: var(--text-muted); }
.strong { font-weight: 600; }

/* Rode bol voor een nieuwe reactie */
.dot-nieuw {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 9999px;
    background: var(--primary);
    margin-right: 0.4rem;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ---------- Forms ---------- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text);
}

/* Label in de stijl van de detailpagina (klein, hoofdletters, grijs) */
.label-detail {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.input, .select, .textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    background: #fff;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea { resize: vertical; min-height: 6rem; }

/* ---------- Telefoonrijen (meerdere nummers per klant) ---------- */
.tel-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.tel-row .select { width: 110px; flex-shrink: 0; }
.tel-row .input { flex: 1; }

.tel-primair {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
}

.tel-primair input { accent-color: var(--primary); }

.loc-row { flex-wrap: wrap; }
.loc-row .input { flex: 1; min-width: 130px; }
.loc-row .loc-small { flex: 0 0 90px; min-width: 90px; }

/* ---------- Combobox (doorzoekbare selectie) ---------- */
.combo { position: relative; }

.combo-input.combo-fout { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 60;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.combo-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.combo-item .muted { font-size: 0.75rem; white-space: nowrap; }

.combo-item:hover,
.combo-item.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.combo-empty {
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-actions {
    display: flex;
    gap: 0.625rem;
    margin-top: 1rem;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.alert-success { background: var(--success-soft); color: #155724; border-color: rgba(22,163,74,0.2); }
.alert-error { background: var(--danger-soft); color: var(--primary); border-color: rgba(176,50,50,0.2); }

/* ---------- Detail rows ---------- */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.25rem;
}

.detail-item .detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.detail-item .detail-value { color: var(--text); font-weight: 500; }

/* ---------- Werkorder detail ---------- */
.wo-description {
    white-space: pre-wrap;
    color: var(--text);
    line-height: 1.6;
}

.timeline { display: flex; flex-direction: column; gap: 0.875rem; }

.timeline-item {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
}

.timeline-avatar {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.timeline-body { flex: 1; min-width: 0; }
.timeline-meta { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.timeline-meta strong { font-weight: 600; }
.timeline-date { color: var(--text-muted); font-size: 0.75rem; }
.timeline-text { margin-top: 0.3rem; color: var(--text); white-space: pre-wrap; }

/* ---------- Calendar ---------- */
.cal-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
    gap: 0.75rem;
}
.plan-nav-kolom { display: flex; flex-direction: column; gap: 0.75rem; flex: 1 1 auto; min-width: 0; }
.plan-agenda { min-width: 0; }
.plan-agenda-kop { padding-bottom: 0.6rem; min-height: 6.75rem; box-sizing: border-box; }
.plan-tech-kies-rij { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.plan-seg-print { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-left: auto; }
.plan-goto { min-width: 6.5rem; justify-content: center; }
.plan-datum { padding: 0.28rem 0.5rem; font-size: 0.8rem; }
.plan-inplannen { display: flex; flex-direction: column; flex: 0 0 330px; }
.plan-inplannen > div:last-child { flex: 1 1 auto; }
.plan-inplannen.drag-over { outline: 2px dashed var(--primary); outline-offset: -2px; }

/* Segmented toggle (week/dag), zoals Outlook */
.segmented {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}
.segmented-opt {
    padding: 0.35rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.segmented-opt + .segmented-opt { border-left: 1px solid var(--border); }
.segmented-opt:hover { background: #f1f5f9; color: var(--text); }
.segmented-opt.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.875rem;
}

.day-card { display: flex; flex-direction: column; min-height: 120px; }

.day-card.today { border-color: var(--primary); }

.day-head {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-head .day-num { font-size: 0.8rem; color: var(--text-muted); }
.day-head .day-name { font-size: 0.9rem; }

.day-items { padding: 0.6rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }

.cal-item {
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    border-radius: 0.35rem;
    padding: 0.45rem 0.6rem;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text);
    display: block;
}

.cal-item .cal-item-time { font-weight: 600; }
.cal-item .cal-item-title { color: var(--text-muted); }
.cal-item:hover { background: rgba(176, 50, 50, 0.18); }

/* ---------- Planning board (weekpertechnieker) ---------- */
.plan-board th, .plan-board td { border-right: 1px solid var(--border); vertical-align: top; }
.plan-board th:last-child, .plan-board td:last-child { border-right: none; }
.plan-board thead th { text-align: center; }
.plan-board tbody td { padding: 0.3rem 0.4rem; }
.plan-timeline { table-layout: fixed; width: 100%; }
.plan-timeline .plan-uur { width: 52px; }

/* Tijdlijn (uren als rijen) */
.plan-timeline .plan-uur {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    vertical-align: top;
    background: #fbfbfc;
}
.plan-timeline .plan-cell { padding: 0.25rem 0.35rem !important; }
.plan-timeline .plan-cel-inhoud { height: 24px; overflow: hidden; display: flex; flex-direction: column; gap: 0.15rem; }
.plan-timeline .plan-cel-inhoud .pc-chip { overflow: hidden; padding: 0.15rem 0.4rem; font-size: 0.72rem; line-height: 1.15; }
.plan-timeline .plan-cel-inhoud .pc-chip + .pc-chip { margin-top: 0; }
.plan-timeline tr.plan-heel-uur td.plan-cell { border-top: 1px solid var(--border); }

.plan-board tr, .plan-board tbody tr:hover { background: transparent; }

.plan-tech { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; }
.plan-tech-avatar {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 9999px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.tech-kies {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.2rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: 9999px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: 0.8rem;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.tech-kies .plan-tech-avatar { width: 1.6rem; height: 1.6rem; font-size: 0.68rem; }
.tech-kies:hover { border-color: var(--primary); }
.tech-kies.active { background: var(--primary-soft); border-color: var(--primary); font-weight: 600; }

/* ---------- Planning board: absolute kolommen met duur ---------- */
.plan2-wrap { overflow-x: auto; }
.plan2 { width: 100%; }
.plan2-kop-rij { display: flex; align-items: flex-end; }
.plan2-kop-uur {
    flex: 0 0 52px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.4rem 0 0.3rem 0.35rem;
}
.plan2-kop {
    flex: 1 1 var(--plan-col);
    min-width: var(--plan-col);
    position: relative;
    text-align: center;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.4rem 0.3rem 0.3rem;
    border-left: 1px solid var(--border);
}
.plan-print {
    position: absolute;
    top: 2px;
    right: 4px;
    display: inline-flex;
    padding: 2px;
    border-radius: 4px;
    color: var(--text-muted);
}
.plan-print:hover { color: var(--primary); background: var(--primary-soft); }
.plan-print svg { width: 14px; height: 14px; display: block; }
.plan2-kop.plan-today { background: var(--primary-soft); }
.plan2-body { display: flex; }
.plan2-uren {
    position: relative;
    flex: 0 0 52px;
    background: #fbfbfc;
}
.plan2-uur-label {
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    line-height: 1;
}
.plan2-kolom {
    position: relative;
    flex: 1 1 var(--plan-col);
    min-width: var(--plan-col);
    border-left: 1px solid var(--border);
    background-image:
        repeating-linear-gradient(to bottom, var(--border) 0 1px, transparent 1px, transparent 52px),
        repeating-linear-gradient(to bottom, rgba(15, 23, 42, 0.07) 0 1px, transparent 1px, transparent 26px);
}
.plan2-kolom.plan-today { background-color: var(--primary-soft); }
.plan2-kolom.plan-tech-actief { background-color: rgba(176, 50, 50, 0.06); }
.plan2-kolom.drag-over { background-color: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }

.plan-item {
    position: absolute;
    left: 3px;
    width: calc(100% - 6px);
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    line-height: 1.15;
    overflow: hidden;
    box-sizing: border-box;
    z-index: 1;
}
.plan-item.pc-sleepbaar { cursor: grab; }
.plan-item.pc-sleepbaar:active { cursor: grabbing; }
.plan-item .pc-title { font-weight: 600; color: var(--text); text-decoration: none; }
.plan-item .pc-title:hover { color: var(--primary); }
.plan-item-resize {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 6px;
    cursor: ns-resize;
}
.plan-item-resize:hover { background: rgba(15, 23, 42, 0.1); }

.plan-item.geselecteerd { outline: 2px solid var(--primary); outline-offset: -1px; }
.item-menu {
    position: fixed;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    padding: 0.25rem;
    min-width: 9rem;
}
.item-menu button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text);
}
.item-menu button:hover { background: var(--primary-soft); color: var(--primary); }

.agenda-kleuren { display: flex; flex-wrap: wrap; gap: 0.25rem; margin: 0.35rem 0 0 1.6rem; }
.agenda-kleur { width: 1.1rem; height: 1.1rem; border-radius: 4px; border: 2px solid transparent; padding: 0; cursor: pointer; }
.agenda-kleur.actief { border-color: var(--text); }
.agenda-kleur:hover { transform: scale(1.15); }
.agenda-kleur-toggle { width: 1.4rem; height: 1.4rem; border-radius: 9999px; border: 2px solid var(--border); cursor: pointer; padding: 0; flex-shrink: 0; }
.agenda-kleur-toggle:hover { border-color: var(--text); }

.plan-cell { min-height: 90px; padding-top: 0.6rem !important; vertical-align: top; }
.plan-cell .pc-chip + .pc-chip { margin-top: 0.35rem; }
.plan-today { background-color: var(--primary-soft); }

.pc-chip {
    background: #fff;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: 0.4rem;
    padding: 0.4rem 0.5rem;
    font-size: 0.78rem;
}
.pc-chip.pc-gepland { border-left-color: var(--info); }
.pc-chip.pc-in-behandeling { border-left-color: var(--warning); }
.pc-chip.pc-wacht-op-onderdeel { border-left-color: #6b21a8; }
.pc-chip.pc-wacht-op-klant { border-left-color: #3730a3; }
.pc-chip.pc-afgerond { border-left-color: var(--success); }
.pc-chip.pc-open { border-left-color: var(--primary); }
.pc-chip.pc-interventie { border-left-color: #0891b2; }
.pc-chip.pc-sleepbaar { cursor: grab; }
.pc-chip.pc-sleepbaar:active { cursor: grabbing; }
.plan-cell.drag-over { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }

.pc-line1 { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; }
.pc-titel-groep { display: flex; align-items: baseline; gap: 0.3rem; min-width: 0; overflow: hidden; }
.pc-titel-groep .pc-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-titel-groep .pc-klant { white-space: nowrap; }
.pc-title { font-weight: 600; color: var(--text); text-decoration: none; }
.pc-title:hover { color: var(--primary); }
.pc-klant { color: var(--text-muted); font-size: 0.73rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pc-acties { display: inline-flex; gap: 0.2rem; flex-shrink: 0; }
.pc-form { display: inline; }
.pc-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-muted);
    border-radius: 0.3rem;
    width: 1.55rem;
    height: 1.55rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}
.pc-btn:hover { background: var(--danger-soft); color: var(--primary); }

.plan-add {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border: 1px dashed #cbd5e1;
    background: transparent;
    color: var(--text-muted);
    border-radius: 0.4rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}
.plan-add svg { width: 0.85rem; height: 0.85rem; }
.plan-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Planningsmodal */
.plan-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.plan-modal { width: 100%; max-width: 460px; padding: 1.25rem; }
.plan-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.5rem; }
.plan-modal-head .pc-btn { width: 1.9rem; height: 1.9rem; }

/* ---------- Login ---------- */
body.login-body {
    background:
        linear-gradient(rgba(128, 26, 26, 0.35), rgba(70, 12, 12, 0.45)),
        url('../scr/background.jpg') center / cover no-repeat fixed;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 2rem;
    margin: 1rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
}

.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand .login-logo {
    width: 5.5rem; height: 5.5rem;
    border-radius: 1rem;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.5rem;
    margin: 0 auto 1rem;
}
.login-brand .login-logo img { width: 100%; height: 100%; object-fit: contain; }
.login-brand h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.login-brand p { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

.login-card .label { margin-top: 0.75rem; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 1.25rem; padding: 0.65rem; }

.login-error {
    background: var(--danger-soft);
    color: var(--primary);
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(176,50,50,0.2);
}

/* ---------- Filters / toolbar ---------- */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem 1rem;
}

/* ---------- Contracten ---------- */
.contract-toestellen {
    border: 1px solid var(--border);
    background: var(--bg);
    border-radius: var(--radius);
    max-height: 320px;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.contract-toestel {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
}

.contract-toestel:hover { background: rgba(176, 50, 50, 0.05); }
.contract-toestel input { width: auto; }

.contract-toestellen .contract-toestel-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.contract-toestellen .contract-toestel-row:last-child { margin-bottom: 0; }

.contract-billing {
    display: none;
    padding: 0.75rem;
    border-top: 1px dashed var(--border);
    background: #fbfbfc;
}

.contract-billing.open { display: block; }

.billing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.billing-grid .label { font-size: 0.72rem; margin-bottom: 0.25rem; }
.billing-grid .input { padding: 0.45rem 0.6rem; font-size: 0.85rem; }

.contract-toestel strong { display: block; font-size: 0.85rem; font-weight: 600; }
.contract-toestel small { color: var(--text-muted); font-size: 0.75rem; }

/* ---------- Sorteerbare tabelkoppen ---------- */
.sort-btn {
    background: none;
    border: none;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color 0.15s ease;
}
.sort-btn:hover { color: var(--primary); }
.sort-btn .sort-ind { font-size: 0.6rem; color: var(--primary); min-width: 0.6rem; }

/* ---------- Kolommen zichtbaar/onzichtbaar ---------- */
.col-hidden { display: none !important; }

.col-toolbar { position: relative; }

.col-panel {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 60;
    min-width: 220px;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

.col-panel.open { display: block; }

.col-panel label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 0.35rem;
}

.col-panel label:hover { background: #f1f5f9; }
.col-panel input { accent-color: var(--primary); }

.col-item { display: flex; align-items: center; gap: 0.35rem; }
.col-item > label { flex: 1; }
.col-move { display: flex; gap: 2px; }
.col-move button {
    width: 22px; height: 22px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: #fff; color: var(--text-muted);
    border-radius: 4px; cursor: pointer; font-size: 0.55rem; line-height: 1;
}
.col-move button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.col-move button:disabled { opacity: 0.3; cursor: default; }

/* ---------- Copy knop (klembord) ---------- */
.copy-btn {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 0.3rem;
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.copy-btn svg { width: 1rem; height: 1rem; }
.copy-btn:hover { background: var(--primary-soft); color: var(--primary); }
.copy-btn:active { transform: translateY(-50%) scale(0.95); }

/* Wachtwoord toggle (eye) & copy knop: uniforme icon-knop variante */
.icon-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    width: 1.9rem;
    height: 1.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn svg { width: 1.05rem; height: 1.05rem; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.icon-btn:active { transform: scale(0.95); }

/* ---------- Wachtwoord toggle ---------- */
.pw-mask { font-family: monospace; }

/* ---------- Mobiele navigatie (PWA) ---------- */
html { -webkit-text-size-adjust: 100%; }

body { -webkit-tap-highlight-color: transparent; }

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.menu-toggle svg { width: 1.25rem; height: 1.25rem; }
.menu-toggle:hover { background: #f1f5f9; }
.menu-toggle:active { transform: scale(0.96); }

/* Terug-knop in de topbar (i.p.v. de hamburger) */
.topbar-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    text-decoration: none;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.topbar-back svg { width: 1.25rem; height: 1.25rem; }
.topbar-back:hover { background: #f1f5f9; }
.topbar-back:active { transform: scale(0.96); }

/* Op desktop: titel direct naast de terug-knop (links uitgelijnd) */
@media (min-width: 901px) {
    .topbar-back + .page-title { margin-right: auto; }
}

.menu-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    margin-left: auto;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.menu-close svg { width: 1.25rem; height: 1.25rem; }
.menu-close:hover { background: #f1f5f9; }
.menu-close:active { transform: scale(0.96); }

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 45;
}

.sidebar-overlay.show { opacity: 1; visibility: visible; }

body.menu-open { overflow: hidden; }

/* Voorkom dat brede content (tabellen) de layout breder duwt dan het scherm */
.layout, .main, .content { min-width: 0; }
.grid, .grid-2, .grid-3, .grid-stats, .form-grid, .detail-grid { min-width: 0; }
.grid > *, .detail-grid > *, .form-grid > * { min-width: 0; }
.table-wrap { max-width: 100%; }

@media (max-width: 900px) {
    .menu-toggle { display: inline-flex; }
    .menu-close { display: inline-flex; }

    /* Menu als overlay over het volledige scherm */
    .sidebar {
        width: 100%;
        max-width: 100%;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay { display: none; }

    .brand { padding: 1rem 1.25rem; }
    .nav { padding: 0.75rem; }
    .nav-link { padding: 0.85rem 0.9rem; font-size: 0.95rem; margin-bottom: 0.25rem; }
    .nav-link svg { width: 1.3rem; height: 1.3rem; }
    .sidebar-footer { padding: 1rem 1.25rem; }

    .main { margin-left: 0; }

    /* Topbar: module titel gecentreerd over de volledige schermbreedte */
    .topbar {
        position: sticky;
        flex-wrap: wrap;
        row-gap: 0.5rem;
        padding: 0.7rem 1rem;
        padding-top: calc(0.7rem + env(safe-area-inset-top));
        gap: 0.5rem;
    }

    .page-title {
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3.75rem;
        text-align: center;
        pointer-events: none;
    }

    .page-title h1 {
        font-size: 1.1rem;
        line-height: 2.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .page-title p { display: none; }

    .topbar-actions {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        justify-content: center;
        flex-wrap: nowrap;
        padding: 0.6rem 1rem 0;
    }

    .topbar.topbar-has-actions + .content {
        padding-top: 3.75rem;
    }

    .content {
        padding: 1rem;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }

    .login-card { padding: 1.5rem; }

    /* Kolommen verbergen op mobiel */
    .mob-verberg { display: none !important; }

    /* Kaarten (o.a. reacties/producten) onder elkaar op mobiel */
    .grid-2 { grid-template-columns: 1fr; }

    /* Status-/categorie-filter als overlay op mobiel */
    .filter-toolbar .col-panel {
        position: fixed;
        left: 50%;
        top: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        z-index: 200;
        min-width: 260px;
        max-height: 80vh;
        overflow-y: auto;
        box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.45), 0 12px 32px rgba(15, 23, 42, 0.25);
    }

    /* Productlijn-acties inklappen in een opties-knop -> overlay */
    .rij-opties-btn { display: inline-flex; }
    .rij-acties {
        display: none;
        position: fixed;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        z-index: 200;
        background: #fff;
        border-radius: var(--radius);
        box-shadow: 0 0 0 100vmax rgba(15, 23, 42, 0.45), 0 12px 32px rgba(15, 23, 42, 0.25);
        padding: 1rem 1.25rem;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        min-width: 180px;
    }
    .rij-acties.open { display: flex; }
}

@media (max-width: 560px) {
    .grid-2, .grid-3, .grid-stats { grid-template-columns: 1fr; }

    .toolbar { gap: 0.5rem; }
    .toolbar .input, .toolbar .select { min-width: 0; width: 100%; }

    .table thead th, .table tbody td { padding: 0.6rem 0.7rem; }

    .form-grid { grid-template-columns: 1fr; }
}

.table thead th[draggable="true"] { cursor: grab; }
.table thead th.sleep { opacity: 0.4; }
.table thead th.sleep-voor { box-shadow: inset 3px 0 0 var(--primary); }
.table thead th.sleep-na { box-shadow: inset -3px 0 0 var(--primary); }