:root {
    /* Hoofdkleur: blauwtinten */
    --navy: #16324a;
    --blue-dark: #1d4e73;
    --blue: #2f7bb3;
    --blue-mid: #4f96c9;
    --blue-light: #d9ebf6;
    --blue-bg: #f2f7fb;
    /* Steunkleur: bruin */
    --brown: #7c5c42;
    --brown-light: #e8dccb;

    --surface: #ffffff;
    --ink: #1f2933;
    --muted: #6b7a89;
    --border: #dbe6ee;
    --danger: #b3441f;
    --radius: 10px;

    /* Statuskleuren - zachte pastels */
    --status-gepland-bg: #cfe3f7;  --status-gepland-fg: #1d4e73;
    --status-actief-bg: #ffe3c2;   --status-actief-fg: #8a5a12;
    --status-feedback-bg: #e6d4f0; --status-feedback-fg: #5c2d6b;
    --status-on-hold-bg: #f8d2d2;  --status-on-hold-fg: #8a2626;
    --status-done-bg: #cfead3;     --status-done-fg: #2e6b3a;

    /* Prioriteit (1 = meest dringend) */
    --prio-1: #f0554a;
    --prio-2: #f2954a;
    --prio-3: #d9a91f;
    --prio-4: #6bc17c;
    --prio-5: #5fa8e0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--blue-bg);
    color: var(--ink);
    line-height: 1.5;
}

.container { max-width: 1150px; margin: 0 auto; padding: 24px 20px 60px; }

.topbar {
    background: var(--navy);
    color: #eaf2f8;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar .brand { color: #eaf2f8; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.topbar nav a { color: #eaf2f8; text-decoration: none; margin-left: 18px; opacity: 0.85; font-size: 0.92rem; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }

h1 { font-size: 1.5rem; margin: 0 0 6px; color: var(--navy); }
h2 { font-size: 1.05rem; color: var(--navy); }

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.page-head-actions { display: flex; gap: 8px; }
.email-pref-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--navy); font-weight: 600; padding: 0 4px; cursor: pointer; user-select: none; white-space: nowrap; }
.email-pref-toggle input { width: auto; cursor: pointer; }

.btn { display: inline-block; padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent; cursor: pointer; font-size: 0.9rem; text-decoration: none; font-weight: 600; }.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: transparent; color: var(--navy); border-color: var(--border); }
.btn-ghost:hover { background: var(--blue-light); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-start { background: var(--status-done-fg); color: white; border: none; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; }
.btn-stop { background: var(--status-on-hold-fg); color: white; border: none; padding: 6px 12px; border-radius: 8px; font-size: 0.85rem; cursor: pointer; }
.btn-copy { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 0.78rem; cursor: pointer; color: var(--blue); }
.btn-remove-row { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.95rem; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card { display: block; background: white; border: 1px solid var(--border); border-top: 3px solid var(--blue-mid); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink); transition: box-shadow 0.15s, transform 0.15s; }
.card:hover { box-shadow: 0 4px 14px rgba(22,50,74,0.1); transform: translateY(-1px); }
.card h2 { margin: 0 0 6px; }
.card.is-archived { opacity: 0.55; }
.badge { display: inline-block; margin-top: 8px; background: var(--blue-light); color: var(--blue-dark); padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; }

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

/* Forms */
.form, .auth-box form {
    background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; max-width: 640px;
}
.form label, .auth-box label { display: block; margin-bottom: 16px; font-weight: 600; font-size: 0.9rem; color: var(--navy); }
.form input[type=text], .form input[type=password], .form input[type=date], .form input[type=number],
.form textarea, .form select, .auth-box input {
    display: block; width: 100%; margin-top: 6px; padding: 9px 10px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.95rem; font-family: inherit; background: white; color: var(--ink);
}
.form small { font-weight: 400; color: var(--muted); display: block; margin-top: 4px; }
.form-row { display: flex; gap: 16px; }
.form-row label { flex: 1; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.checkbox-row input { width: auto; }

.checklist-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.checklist-row input[type=checkbox] { width: auto; margin: 0; }
.checklist-row input[type=text] { flex: 1; margin: 0; }

.auth-box { max-width: 420px; margin: 60px auto; text-align: left; }
.auth-box h1 { text-align: center; }
.auth-box p.muted { text-align: center; }
.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.9rem; }
.alert-error { background: #fbe6df; color: var(--danger); }
.alert-ok { background: #d9f0df; color: #2e6b3a; }

/* Task table */
.task-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.task-table th, .task-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; text-align: left; vertical-align: middle; }
.task-table th { background: var(--blue-light); color: var(--navy); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; user-select: none; }
.task-table th.sortable { cursor: pointer; }
.task-table th.sortable:hover { background: #c9e2f2; }
.task-table th .arrow { opacity: 0.4; font-size: 0.7rem; margin-left: 2px; }
.task-table th.sort-active .arrow { opacity: 1; }
.task-table tbody tr:hover { background: var(--blue-bg); }
.task-title-link { color: var(--navy); text-decoration: none; font-weight: 600; cursor: pointer; background: none; border: none; padding: 0; font-size: inherit; text-align: left; display: inline-block; }
.task-title-link:hover { text-decoration: underline; }
.inline-form { margin: 0; }

.status-pill { display: inline-block; padding: 4px 11px; border-radius: 14px; font-size: 0.76rem; font-weight: 700; }
.status-gepland  { background: var(--status-gepland-bg);  color: var(--status-gepland-fg); }
.status-actief   { background: var(--status-actief-bg);   color: var(--status-actief-fg); }
.status-feedback { background: var(--status-feedback-bg); color: var(--status-feedback-fg); }
.status-on-hold  { background: var(--status-on-hold-bg);  color: var(--status-on-hold-fg); }
.status-done     { background: var(--status-done-bg);     color: var(--status-done-fg); }

.prio-badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; font-size: 0.75rem; font-weight: 800; color: white; }
.prio-1 { background: var(--prio-1); }
.prio-2 { background: var(--prio-2); }
.prio-3 { background: var(--prio-3); }
.prio-4 { background: var(--prio-4); }
.prio-5 { background: var(--prio-5); }

.status-select, .prio-select { border-radius: 6px; padding: 5px 8px; border: 1px solid var(--border); font-size: 0.82rem; background: white; font-weight: 600; cursor: pointer; }

.tracked-cell { white-space: nowrap; }
.btn-edit-time { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.85rem; margin-left: 6px; padding: 2px 4px; }
.btn-edit-time:hover { color: var(--blue); }
.time-edit-input { width: 64px; padding: 4px 6px; border: 1px solid var(--blue-mid); border-radius: 6px; font-size: 0.85rem; }
.btn-time-save, .btn-time-cancel { border: none; background: none; cursor: pointer; font-size: 0.9rem; padding: 2px 5px; margin-left: 2px; }
.btn-time-save { color: var(--status-done-fg); }
.btn-time-cancel { color: var(--danger); }

/* Kleur de dropdown zelf op basis van de huidige waarde (blijft een echte <select>) */
select.status-select.status-gepland  { background: var(--status-gepland-bg);  color: var(--status-gepland-fg);  border-color: var(--status-gepland-bg); }
select.status-select.status-actief   { background: var(--status-actief-bg);   color: var(--status-actief-fg);   border-color: var(--status-actief-bg); }
select.status-select.status-feedback { background: var(--status-feedback-bg); color: var(--status-feedback-fg); border-color: var(--status-feedback-bg); }
select.status-select.status-on-hold  { background: var(--status-on-hold-bg);  color: var(--status-on-hold-fg);  border-color: var(--status-on-hold-bg); }
select.status-select.status-done     { background: var(--status-done-bg);     color: var(--status-done-fg);     border-color: var(--status-done-bg); }

select.prio-select.prio-1 { background: var(--prio-1); color: white; border-color: var(--prio-1); }
select.prio-select.prio-2 { background: var(--prio-2); color: white; border-color: var(--prio-2); }
select.prio-select.prio-3 { background: var(--prio-3); color: white; border-color: var(--prio-3); }
select.prio-select.prio-4 { background: var(--prio-4); color: white; border-color: var(--prio-4); }
select.prio-select.prio-5 { background: var(--prio-5); color: white; border-color: var(--prio-5); }

.status-select:disabled, .prio-select:disabled { opacity: 0.6; cursor: not-allowed; }
.deadline-input { border: 1px solid var(--border); border-radius: 6px; padding: 5px 7px; font-size: 0.8rem; }
.locked-cell { color: var(--muted); font-size: 0.82rem; }
.lock-icon { opacity: 0.55; margin-right: 3px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0 22px; font-size: 0.8rem; }
.legend .swatch { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Klant-activiteit (alleen zichtbaar voor admin) */
.activity-widget { background: white; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 0.85rem; }
.activity-status { display: flex; align-items: center; gap: 4px; color: var(--ink); }
.activity-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 2px; }
.activity-dot-live { background: var(--status-done-fg); box-shadow: 0 0 0 3px var(--status-done-bg); animation: pulse-dot 1.6s infinite; }
.activity-dot-none { background: var(--border); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.activity-log { margin-top: 8px; }
.activity-log summary { cursor: pointer; color: var(--blue); font-size: 0.82rem; }
.activity-log ul { list-style: none; margin: 8px 0 0; padding: 0; max-height: 180px; overflow-y: auto; }
.activity-log li { padding: 3px 0; color: var(--muted); font-size: 0.8rem; border-bottom: 1px solid var(--blue-bg); }

/* Weekplanner */
.week-planner { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 10px; }
.week-day-col { background: var(--blue-bg); border-radius: var(--radius); padding: 12px; min-height: 90px; }
.week-day-col.is-today { background: var(--blue-light); border: 1px solid var(--blue-mid); }
.week-day-header { font-weight: 700; color: var(--navy); font-size: 0.85rem; margin-bottom: 10px; display: flex; flex-direction: column; gap: 1px; }
.week-task-card { display: block; background: white; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; text-decoration: none; color: var(--ink); }
.week-task-card:hover { box-shadow: 0 2px 8px rgba(22,50,74,.1); }
.week-task-title { font-weight: 600; color: var(--navy); font-size: 0.88rem; }
.week-task-meta { display: flex; align-items: center; gap: 6px; font-size: 0.76rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-task-meta .prio-badge { width: 16px; height: 16px; font-size: 0.65rem; flex-shrink: 0; margin-left: auto; }

@media (max-width: 900px) {
    .week-planner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
    .week-planner { grid-template-columns: 1fr; }
}

.notif-count { background: var(--danger); color: white; border-radius: 10px; padding: 1px 7px; font-size: 0.72rem; font-weight: 700; margin-left: 2px; }

.toast-stack { position: fixed; top: 70px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast { background: var(--navy); color: white; padding: 12px 14px; border-radius: 8px; box-shadow: 0 8px 24px rgba(22,50,74,.3); display: flex; align-items: flex-start; gap: 10px; font-size: 0.85rem; animation: toast-in 0.2s ease-out; }
.toast-msg { flex: 1; }
.toast-close { background: none; border: none; color: white; opacity: 0.7; cursor: pointer; font-size: 0.9rem; line-height: 1; }
.toast-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.undo-cell { background: var(--blue-light); text-align: center !important; font-size: 0.85rem; }
.undo-count { font-weight: 700; }
.btn-delete { background: none; border: 1px solid var(--border); color: var(--danger); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
.btn-delete:hover { background: var(--danger); color: white; border-color: var(--danger); }
.btn-reactivate { background: none; border: 1px solid var(--border); color: var(--status-done-fg); width: 26px; height: 26px; border-radius: 6px; cursor: pointer; font-size: 0.9rem; margin-right: 4px; }
.btn-reactivate:hover { background: var(--status-done-fg); color: white; border-color: var(--status-done-fg); }
.actions-cell { white-space: nowrap; }

tr.row-archived { opacity: 0.55; background: #f5f5f5; }
tr.row-archived .task-title-link { text-decoration: line-through; }
tr.row-archived .badge { background: #e0e0e0; color: #666; margin-left: 6px; }

.task-table tfoot td { font-weight: 700; background: var(--blue-light); border-top: 2px solid var(--blue-mid); border-bottom: none; }

.month-summary { margin-top: 26px; max-width: 320px; }
.month-summary h2 { margin-bottom: 10px; }
.small-table th, .small-table td { padding: 7px 12px; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(22,50,74,.45); align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: 14px; max-width: 640px; width: 100%; box-shadow: 0 20px 60px rgba(22,50,74,.35); }
.modal-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h2 { margin: 0 0 8px; font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 24px; max-height: 65vh; overflow-y: auto; }
.modal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; align-items: center; }
.modal-section { margin-top: 18px; }
.modal-section h3 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 8px; }
.modal-loading { padding: 40px; text-align: center; color: var(--muted); }

.checklist-view label { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 0.9rem; cursor: pointer; }
.checklist-view input { width: auto; }
.checklist-view .item-text.done-text { text-decoration: line-through; color: var(--muted); }
.checklist-view.readonly label { cursor: default; }
.notes-view { font-size: 0.9rem; white-space: pre-wrap; }

.comment { border-left: 3px solid var(--blue-mid); background: var(--blue-bg); padding: 8px 12px; border-radius: 0 8px 8px 0; margin-bottom: 10px; font-size: 0.87rem; }
.comment.from-client { border-left-color: var(--brown); background: var(--brown-light); }
.comment-meta { font-size: 0.74rem; color: var(--muted); margin-bottom: 4px; }
.comment b, .comment strong { color: var(--navy); }
.comment a { color: var(--blue); }
.comment-composer { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-top: 8px; }
.comment-toolbar { background: var(--blue-light); padding: 6px 8px; display: flex; gap: 4px; }
.comment-toolbar button { border: 1px solid transparent; background: white; width: 28px; height: 28px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; color: var(--navy); }
.comment-toolbar button:hover { border-color: var(--blue-mid); }
.comment-editable { min-height: 60px; padding: 10px 12px; font-size: 0.88rem; outline: none; }
.comment-editable:empty:before { content: attr(data-placeholder); color: var(--muted); }
.comment-post-row { display: flex; justify-content: flex-end; padding: 8px; border-top: 1px solid var(--border); }

/* Bijlagen */
.attachment-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.attachment-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--blue-bg); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; }
.attachment-link { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex: 1; min-width: 0; }
.attachment-link:hover .attachment-name { text-decoration: underline; }
.attachment-icon { font-size: 1.1rem; flex-shrink: 0; }
.attachment-name { font-weight: 600; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { flex-shrink: 0; }
.attachment-delete { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem; flex-shrink: 0; padding: 2px 6px; }
.attachment-delete:hover { color: white; background: var(--danger); border-radius: 4px; }

.dropzone {
    border: 2px dashed var(--blue-mid);
    border-radius: 10px;
    padding: 18px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    background: var(--blue-bg);
    transition: background 0.15s, border-color 0.15s;
}
.dropzone-active { background: var(--blue-light); border-color: var(--blue); }
.dropzone-browse { color: var(--blue); font-weight: 600; cursor: pointer; text-decoration: underline; }
#attachment-upload-status { font-size: 0.82rem; color: var(--danger); margin-top: 6px; }

@media (max-width: 900px) {
    .form-row { flex-direction: column; gap: 0; }
}

@media (max-width: 640px) {
    .container { padding: 16px 12px 40px; }

    .topbar { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 16px; }
    .topbar nav { display: flex; flex-wrap: wrap; gap: 4px 14px; }

    .page-head { flex-direction: column; align-items: stretch; }
    .page-head-actions { flex-direction: column; }
    .page-head-actions .btn { text-align: center; }

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

    /* Tabellen worden kaarten: elke rij een blokje, elke cel een label + waarde */
    .task-table thead { display: none; }
    .task-table, .task-table tbody, .task-table tfoot, .task-table tr, .task-table td {
        display: block;
        width: 100%;
    }
    .task-table { border: none; background: transparent; }
    .task-table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 12px;
        padding: 10px 14px;
    }
    .task-table tr.totals-row {
        background: var(--blue-light);
        border-color: var(--blue-mid);
    }
    .task-table td {
        border: none;
        border-bottom: 1px solid var(--blue-bg);
        padding: 9px 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        text-align: right;
    }
    .task-table td:last-child { border-bottom: none; }
    .task-table td[data-label]:not([data-label=""])::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--muted);
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.03em;
        text-align: left;
        flex-shrink: 0;
    }
    .task-table td:not([data-label]) { justify-content: flex-end; }
    .task-table .status-select, .task-table .prio-select, .task-table .deadline-input {
        max-width: 60%;
    }
    .task-table .inline-form { margin-left: auto; }
    .task-table .actions-cell { justify-content: flex-end; }

    .task-table td:empty { display: none; }

    .modal-box { max-width: 100%; margin: 0 8px; }
    .modal-body { max-height: 75vh; }

    .toast-stack { top: auto; bottom: 16px; right: 12px; left: 12px; max-width: none; }

    .month-summary { max-width: 100%; }
}