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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 248px;
    --r: 14px;
    --r-sm: 10px;
    --r-xs: 8px;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 2px 10px rgba(16,24,40,.05);
    --shadow-md: 0 2px 6px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
    --shadow-lg: 0 12px 40px rgba(16,24,40,.18);
    --topbar-h: 56px;
    --tabbar-h: 62px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color-scheme: light;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ============ SIDEBAR (desktop) ============ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(185deg, #1e293b 0%, #0f172a 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    padding: 1.25rem 0 1rem;
    overflow-y: auto;
    z-index: 150;
    display: flex;
    flex-direction: column;
}

.sidebar-footer {
    padding: 0.75rem 0.85rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    margin-top: auto;
}

.backup-btn {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: rgba(255,255,255,0.04);
    color: var(--gray-300);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--r-xs);
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.15s;
    margin-bottom: 0.4rem;
}

.backup-btn:hover { background: rgba(255,255,255,0.1); color: white; }
.backup-btn-secondary { background: transparent; }

.backup-status {
    text-align: center;
    font-size: 0.7rem;
    color: var(--gray-500);
    padding-top: 0.4rem;
    transition: color 0.3s;
}
.backup-status.saved { color: #4ade80; }

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 0.75rem;
}
.logo-icon { font-size: 1.5rem; }
.logo h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }

.nav-menu { list-style: none; display: flex; flex-direction: column; flex: 1; gap: 2px; padding: 0 0.6rem; }

.nav-item {
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--gray-400);
    transition: all 0.15s;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--r-xs);
    position: relative;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; }

.nav-item-logout { margin-top: 0.4rem; color: #f87171; }
.nav-item-logout:hover { background: rgba(220,38,38,0.18); color: #fca5a5; }

/* ============ MOBIELE CHROME (verborgen op desktop) ============ */
.m-topbar, .m-tabbar, .m-overlay, .m-sheet { display: none; }

/* ============ CONTENT ============ */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 2rem;
    max-width: 1240px;
    width: 100%;
}

.page { display: none; animation: fadeIn 0.2s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}

h2 { font-size: 1.5rem; color: var(--gray-900); margin-bottom: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header h2 { margin-bottom: 0; }
h3 { font-size: 1.1rem; color: var(--gray-800); margin-bottom: 1rem; font-weight: 650; }
h4 { font-size: 0.95rem; color: var(--gray-700); margin: 0.5rem 0; font-weight: 600; }

/* ============ BUTTONS ============ */
.btn {
    padding: 0.6rem 1.15rem;
    border: none;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    font-family: inherit;
    line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 2px 8px rgba(37,99,235,.25); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--gray-700); box-shadow: inset 0 0 0 1px var(--gray-300); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-group { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ============ CARDS ============ */
.card {
    background: white;
    border-radius: var(--r);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    border: 1px solid var(--gray-100);
}

/* ============ STATS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: white;
    border-radius: var(--r);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-100);
}
.stat-card-accent {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    border: none;
    box-shadow: 0 8px 24px rgba(37,99,235,.28);
}
.stat-card-accent .stat-label { color: rgba(255,255,255,0.8); }
.stat-card-accent .stat-value { color: white; }
.stat-label { font-size: 0.78rem; color: var(--gray-500); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-value { font-size: 1.55rem; font-weight: 750; color: var(--gray-900); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

/* ============ IB PAGINA ============ */
.ib-table td { padding: 0.6rem 0.75rem; }
.ib-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ib-section-header td { background: var(--gray-50); font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); padding: 0.4rem 0.75rem; }
.ib-winst-row td { background: #eff6ff; color: #1e40af; font-size: 1rem; padding: 0.75rem; border-top: 2px solid #bfdbfe; font-weight: 700; }
.ib-aftrek-row { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); font-size: 0.875rem; }
.ib-aftrek-row label { color: var(--gray-700); }
.balans-input { width: 110px; padding: 5px 8px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 0.85rem; text-align: right; font-family: inherit; }
.balans-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ============ TABLE ============ */
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
    background: var(--gray-50);
    padding: 0.7rem 0.75rem;
    text-align: left;
    font-weight: 700;
    color: var(--gray-500);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
.table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: middle;
}
.table tr:hover td { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============ STATUS BADGES ============ */
.badge { padding: 0.22rem 0.65rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-concept { background: var(--gray-200); color: var(--gray-600); }
.badge-verzonden { background: var(--primary-light); color: var(--primary-dark); }
.badge-betaald { background: var(--success-light); color: var(--success); }
.badge-vervallen { background: var(--danger-light); color: var(--danger); }
.badge-open { background: var(--warning-light); color: #b45309; }

/* ============ SEARCH & FILTER ============ */
.search-bar, .filter-bar { margin-bottom: 1rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }
.search-bar input, .filter-bar select {
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 0.875rem;
    background: white;
    font-family: inherit;
}
.search-bar input { width: 300px; max-width: 100%; }
.search-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ============ FORMS ============ */
.form-group { margin-bottom: 1rem; flex: 1; min-width: 200px; }
.form-group label { display: block; margin-bottom: 0.35rem; font-size: 0.8rem; font-weight: 600; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--r-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 200;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem;
    overflow-y: auto;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    border-radius: var(--r);
    width: 100%;
    max-width: 600px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease;
}
.modal-large { max-width: 850px; }
.modal-split { max-width: 1200px; }
.modal-split-body { display: flex; flex-direction: row; flex-wrap: nowrap; gap: 1.5rem; align-items: flex-start; }
.modal-split-form { flex: 0 0 400px; min-width: 0; }
.modal-split-pdf { flex: 1; min-width: 0; display: none; }
.modal-split-pdf.visible { display: block; }
.modal-split-pdf iframe { width: 100%; height: 75vh; min-height: 500px; border: 1px solid var(--gray-200); border-radius: var(--r-sm); background: var(--gray-100); }

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; padding-bottom: 0.75rem; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { margin-bottom: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--gray-400); padding: 0 0.25rem; line-height: 1; }
.modal-close:hover { color: var(--gray-700); }

/* ============ FACTUUR FORM ============ */
.factuur-totalen { text-align: right; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
#factuur-regels-table input, #factuur-regels-table select { padding: 0.4rem 0.5rem; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 0.8rem; }
#factuur-regels-table input[type="text"] { width: 100%; min-width: 150px; }
#factuur-regels-table input[type="number"] { width: 80px; }
#factuur-regels-table select { width: 80px; }

/* ============ BTW ============ */
.btw-overzicht { display: flex; flex-direction: column; gap: 1rem; }
.btw-table td:not(:first-child) { text-align: right; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.btw-table td:first-child { min-width: 300px; }
.btw-totaal-card { border: 2px solid var(--primary); }
.btw-resultaat td { font-size: 1.1rem; padding-top: 0.75rem; border-top: 2px solid var(--gray-200); }

/* ============ SETTINGS ============ */
.settings-card { max-width: 700px; }

/* ============ FACTUUR PREVIEW ============ */
.factuur-print { font-family: var(--font); max-width: 700px; margin: 0 auto; padding: 2rem; }
.factuur-print .header { display: flex; justify-content: space-between; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 3px solid var(--primary); }
.factuur-print .bedrijf-info h2 { font-size: 1.4rem; color: var(--primary); margin-bottom: 0.5rem; }
.factuur-print .bedrijf-info p, .factuur-print .klant-info p { font-size: 0.85rem; color: var(--gray-600); line-height: 1.6; margin: 0; }
.factuur-print .klant-info { text-align: right; }
.factuur-print .klant-info strong { color: var(--gray-800); }
.factuur-print .meta { display: flex; gap: 2rem; margin-bottom: 2rem; font-size: 0.85rem; }
.factuur-print .meta span { color: var(--gray-500); }
.factuur-print .meta strong { color: var(--gray-800); }
.factuur-print table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.factuur-print th { background: var(--gray-100); padding: 0.6rem; text-align: left; font-size: 0.8rem; color: var(--gray-600); }
.factuur-print td { padding: 0.6rem; border-bottom: 1px solid var(--gray-200); font-size: 0.85rem; }
.factuur-print .totalen { text-align: right; }
.factuur-print .totalen div { margin-bottom: 0.3rem; font-size: 0.9rem; }
.factuur-print .totalen .grand-total { font-size: 1.2rem; font-weight: 700; color: var(--primary); border-top: 2px solid var(--gray-200); padding-top: 0.5rem; margin-top: 0.5rem; }
.factuur-print .footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); font-size: 0.8rem; color: var(--gray-500); }

/* ============ ACTION BUTTONS IN TABLE ============ */
.action-btns { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.action-btns button {
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--gray-300);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.12s;
}
.action-btns button:hover { background: var(--gray-100); border-color: var(--gray-400); }

/* ACTION DROPDOWN (mobiel, facturen) */
.action-dropdown { position: relative; display: none; }
.action-dropdown-btn { width: 36px; height: 36px; border: 1px solid var(--gray-300); background: white; border-radius: var(--r-xs); cursor: pointer; font-size: 1.1rem; line-height: 1; display: flex; align-items: center; justify-content: center; }
.action-dropdown-btn:hover { background: var(--gray-100); }
.action-dropdown-menu { display: none; position: absolute; right: 0; top: 100%; z-index: 200; background: white; border: 1px solid var(--gray-200); border-radius: var(--r-sm); box-shadow: var(--shadow-md); min-width: 160px; overflow: hidden; }
.action-dropdown-menu.open { display: block; }
.action-dropdown-menu button { display: block; width: 100%; padding: 0.7rem 1rem; border: none; background: white; text-align: left; cursor: pointer; font-size: 0.85rem; border-bottom: 1px solid var(--gray-100); font-family: inherit; }
.action-dropdown-menu button:last-child { border-bottom: none; }
.action-dropdown-menu button:hover { background: var(--gray-50); }

/* ============ MAAND TABS ============ */
.month-tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.month-tab { padding: 0.4rem 0.7rem; border: 1px solid var(--gray-300); background: white; border-radius: var(--r-xs); cursor: pointer; font-size: 0.8rem; color: var(--gray-600); transition: all 0.15s; font-family: inherit; }
.month-tab:hover { background: var(--gray-100); }
.month-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.spec-loc-tab.active { background: var(--primary) !important; color: white !important; }

/* Veldlabels voor specificatie-regels (alleen zichtbaar op mobiel) */
.veld-lab { display: none; }

/* ============ PRINT ============ */
@media print {
    body { background: white; }
    .sidebar, .m-topbar, .m-tabbar, .m-overlay, .modal-header, .nav-menu, .page-header { display: none !important; }
    .content { margin-left: 0; padding: 0; }
    .modal { position: static; background: none; padding: 0; }
    .modal-content { box-shadow: none; max-width: 100%; }
}

/* =====================================================
   MOBIEL (<= 900px)  -  app-achtige navigatie
   ===================================================== */
@media (max-width: 900px) {
    html, body { overflow-x: clip; max-width: 100%; width: 100%; touch-action: pan-y; overscroll-behavior-x: none; }
    body { display: block; }
    .content, .page, .card { max-width: 100%; }
    /* document-voorbeeld mag wel horizontaal schuiven */
    #factuur-preview { touch-action: auto; }

    /* Topbalk */
    .m-topbar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: calc(var(--topbar-h) + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 0.75rem 0;
        background: rgba(255,255,255,0.92);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--gray-200);
        z-index: 120;
    }
    .m-topbar__menu {
        width: 42px; height: 42px; flex: none;
        border: none; background: var(--gray-100); border-radius: var(--r-xs);
        cursor: pointer; display: flex; flex-direction: column; justify-content: center;
        align-items: center; gap: 4px;
    }
    .m-topbar__menu span { display: block; width: 18px; height: 2px; border-radius: 2px; background: var(--gray-700); transition: 0.2s; }
    .m-topbar__title { flex: 1; min-width: 0; font-weight: 700; font-size: 1.05rem; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .m-topbar__add {
        width: 42px; height: 42px; flex: none; border: none; cursor: pointer;
        background: var(--primary); color: white; border-radius: var(--r-xs);
        font-size: 1.6rem; line-height: 1; display: flex; align-items: center; justify-content: center;
        box-shadow: 0 2px 8px rgba(37,99,235,.3);
    }

    /* Zijmenu wordt uitschuiflade */
    .sidebar {
        width: 284px;
        max-width: 85vw;
        transform: translateX(-104%);
        visibility: hidden;
        transition: transform 0.25s ease, visibility 0s linear 0.25s;
        box-shadow: var(--shadow-lg);
        padding-top: calc(1.25rem + env(safe-area-inset-top));
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
    body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform 0.25s ease; }
    .logo { display: flex; }

    .m-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(10,16,30,0.5);
        z-index: 140;
        opacity: 0; pointer-events: none;
        transition: opacity 0.25s ease;
    }
    body.drawer-open .m-overlay { opacity: 1; pointer-events: auto; }
    body.drawer-open { overflow: hidden; }

    /* Onderbalk met tabs */
    .m-tabbar {
        display: flex;
        position: fixed; left: 0; right: 0; bottom: 0;
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        padding: 0 0.25rem env(safe-area-inset-bottom);
        background: rgba(255,255,255,0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--gray-200);
        box-shadow: 0 -4px 18px rgba(0,0,0,0.05);
        z-index: 120;
        justify-content: space-around;
        align-items: stretch;
    }
    .m-tab {
        flex: 1; border: none; background: none; cursor: pointer; font-family: inherit;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px; font-size: 0.66rem; font-weight: 600; color: var(--gray-500); padding: 6px 2px;
    }
    .m-tab__ic { font-size: 1.3rem; line-height: 1; }
    .m-tab.is-active { color: var(--primary); }
    .m-tab--plus { position: relative; }
    .m-tab__plus {
        width: 52px; height: 52px; margin-top: -24px; border-radius: 50%;
        background: var(--primary); color: white; display: flex; align-items: center; justify-content: center;
        font-size: 2rem; line-height: 1; box-shadow: 0 6px 18px rgba(37,99,235,.4);
        border: 4px solid white;
    }

    /* Snel-toevoegen sheet */
    .m-sheet { display: block; position: fixed; inset: 0; z-index: 210; visibility: hidden; }
    body.sheet-open .m-sheet { visibility: visible; }
    .m-sheet__backdrop { position: absolute; inset: 0; background: rgba(10,16,30,0.5); opacity: 0; transition: opacity 0.2s; }
    body.sheet-open .m-sheet__backdrop { opacity: 1; }
    .m-sheet__panel {
        position: absolute; left: 0; right: 0; bottom: 0;
        background: white; border-radius: 20px 20px 0 0;
        padding: 0.75rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
        transform: translateY(100%); transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sheet-open .m-sheet__panel { transform: none; }
    .m-sheet__grip { width: 40px; height: 4px; border-radius: 2px; background: var(--gray-300); margin: 0.25rem auto 0.9rem; }
    .m-sheet h3 { text-align: center; margin-bottom: 1rem; }
    .m-sheet__panel > button {
        width: 100%; text-align: left; padding: 0.95rem 1rem; margin-bottom: 0.5rem;
        border: 1px solid var(--gray-200); background: var(--gray-50); border-radius: var(--r-sm);
        font-size: 1rem; font-family: inherit; cursor: pointer; font-weight: 600; color: var(--gray-800);
        display: flex; gap: 0.6rem; align-items: center;
    }
    .m-sheet__panel > button:active { background: var(--gray-100); }
    .m-sheet__cancel { justify-content: center; background: white !important; color: var(--gray-500) !important; font-weight: 500 !important; }

    /* Content ruimte voor balken */
    .content {
        margin-left: 0;
        max-width: 100%;
        padding: calc(var(--topbar-h) + env(safe-area-inset-top) + 1rem) 0.85rem calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 1rem);
    }

    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .page-header .btn-group, .page-header > .btn { width: 100%; }
    .page-header .btn-group .btn { flex: 1; }
    h2 { font-size: 1.3rem; margin-bottom: 1rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
    .stat-card { padding: 0.85rem 0.9rem; }
    .stat-value { font-size: 1.2rem; }
    .dashboard-grid { grid-template-columns: 1fr; }

    .card { padding: 1rem; }

    /* Forms stapelen */
    .form-row { flex-direction: column; gap: 0; }
    .form-group { min-width: 100%; }
    .search-bar, .filter-bar { flex-direction: column; }
    .search-bar input, .filter-bar select { width: 100%; }

    /* Touch-vriendelijke knoppen */
    .btn { padding: 0.75rem 1rem; font-size: 0.95rem; min-height: 46px; }
    .btn-sm { min-height: 40px; }

    /* Modals bijna fullscreen */
    .modal { padding: 0.5rem; }
    .modal-content { max-width: 100%; border-radius: var(--r); padding: 1.1rem; max-height: calc(100vh - 1rem); overflow-y: auto; }
    .modal-large, .modal-split { max-width: 100%; }
    .modal-split-body { flex-direction: column; }
    .modal-split-form { flex: 1 1 auto; width: 100%; }
    .modal-split-pdf.visible { width: 100%; }
    .modal-split-pdf iframe { height: 60vh; min-height: 320px; }

    /* ===== ALLE TABELLEN ALS KAARTEN (geen horizontaal scrollen) ===== */
    .table.cards { display: block; width: 100%; }
    .table.cards thead { display: none; }
    .table.cards tbody { display: block; }
    .table.cards tbody tr {
        display: block; background: white; border: 1px solid var(--gray-200);
        border-radius: var(--r-sm); padding: 0.55rem 0.9rem; margin-bottom: 0.7rem;
        box-shadow: var(--shadow);
    }
    .table.cards tbody tr:hover td { background: none; }

    /* Weergave-cel: label links, waarde rechts */
    .table.cards td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        padding: 0.45rem 0; border-bottom: 1px dashed var(--gray-100); text-align: right;
        white-space: normal; color: var(--gray-800); min-width: 0; width: auto;
    }
    .table.cards td:last-child { border-bottom: none; }
    .table.cards td::before {
        content: attr(data-label); font-weight: 600; color: var(--gray-500);
        font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
        text-align: left; flex: none; white-space: nowrap;
    }

    /* Invoer-cel: label boven, veld op volledige breedte */
    .table.cards td.cel-veld {
        display: block; text-align: left;
    }
    .table.cards td.cel-veld::before { display: block; margin-bottom: 0.3rem; }
    .table.cards td.cel-veld input,
    .table.cards td.cel-veld select,
    .table.cards td.cel-veld textarea { width: 100% !important; min-width: 0 !important; min-height: 44px; font-size: 0.95rem; }
    .table.cards td.cel-veld > div { display: flex; width: 100%; gap: 0.4rem; }
    .table.cards td.cel-veld > div > input { flex: 1; }
    .table.cards td.cel-veld > div > select { flex: 0 0 90px; width: 90px !important; }

    /* Actie-cel: knoppen onderaan de kaart */
    .table.cards td.cel-actie { justify-content: flex-end; padding-top: 0.6rem; }
    .table.cards td.cel-actie::before { content: ""; }
    .table.cards td.cel-actie .action-btns { justify-content: flex-end; width: 100%; }
    .table.cards td.cel-actie .action-btns button { flex: 1; min-height: 42px; padding: 0.5rem 0.6rem; font-size: 0.82rem; }

    /* Lege/colspan-cel (bijv. "Geen regels") */
    .table.cards td.cel-breed { display: block; text-align: center; color: var(--gray-400); }
    .table.cards td.cel-breed::before { content: ""; }

    /* Factuur/offerte-voorbeeld: document mag lokaal schuiven binnen de modal */
    #factuur-preview { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .factuur-print { padding: 1rem; min-width: 0; }

    /* ===== Specificatie-regels (maatwerk) stapelen ===== */
    .spec-head { display: none !important; }
    .veld-lab {
        display: block; flex: 1 1 100%; width: 100%;
        font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
        color: var(--gray-500); margin: 2px 0 -2px;
    }
    #uren-regels > div, #commissie-regels > div, #extra-regels > div {
        flex-wrap: wrap !important; gap: 4px 8px !important;
        position: relative; padding-right: 46px !important;
    }
    #uren-regels > div > *:not(button):not(.veld-lab),
    #commissie-regels > div > *:not(button):not(.veld-lab),
    #extra-regels > div > *:not(button):not(.veld-lab) {
        flex: 1 1 100% !important; width: 100% !important; min-width: 0 !important; text-align: left;
    }
    #uren-regels > div > input, #uren-regels > div > select,
    #commissie-regels > div > input, #commissie-regels > div > select,
    #extra-regels > div > input, #extra-regels > div > select { min-height: 44px; font-size: 0.95rem; }
    #uren-regels > div > button, #commissie-regels > div > button, #extra-regels > div > button {
        position: absolute !important; top: 8px; right: 8px;
        width: 32px !important; height: 32px !important;
    }

    /* Inline 3-koloms grids stapelen (samenvattingskaarten specificatie/abonnementen) */
    [style*="repeat(3,1fr)"], [style*="repeat(3, 1fr)"] { grid-template-columns: 1fr !important; }

    /* Sectiekoppen met €/uur + BTW% laten afbreken */
    .spec-sectie-kop { flex-wrap: wrap !important; gap: 0.6rem !important; }
    .spec-sectie-kop input { min-height: 40px; }
}

/* Heel kleine schermen */
@media (max-width: 340px) {
    .stats-grid { grid-template-columns: 1fr; }
    .m-tab { font-size: 0.6rem; }
}
