:root {
    --primary-color: var(--primary-color);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    color: #222;
    background: #f5f5f5;
}

main#app {
    min-height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
    background: var(--primary-color);
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 500;
}

.topbar .link {
    background: none;
    border: none;
    color: #fff;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
}

.topbar-actions {
    display: flex;
    gap: 0.25rem;
}

.setting-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem;
    background: #fff;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.setting-row input[type=checkbox] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin-top: 0.1rem;
    accent-color: var(--primary-color);
}

.setting-row span {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.setting-row strong {
    font-size: 0.95rem;
}

.setting-row small {
    color: #666;
    font-size: 0.8rem;
    line-height: 1.35;
}

.setting-radio {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    padding: 0.85rem;
    background: #fff;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 1px solid #eee;
}

.setting-radio input[type=radio] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 0.1rem;
    accent-color: var(--primary-color);
}

.setting-radio span {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.setting-radio strong {
    font-size: 0.95rem;
}

.setting-radio small {
    color: #666;
    font-size: 0.8rem;
    line-height: 1.35;
}

.page {
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

form h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    font-weight: 500;
}

form label {
    display: block;
    margin-bottom: 1rem;
}

form label span {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    color: #555;
}

form input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

button[type=submit] {
    width: 100%;
    padding: 0.85rem;
    font-size: 1rem;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button[type=submit]:disabled {
    opacity: 0.6;
}

.filters {
    margin-bottom: 1rem;
}

.license-row {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.license-input-wrap {
    flex: 1;
    position: relative;
}

.license-input-wrap input[type=text] {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 0.65rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    text-transform: uppercase;
}

.license-clear {
    position: absolute;
    top: 50%;
    right: 0.35rem;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: #ddd;
    color: #555;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.license-clear[hidden] {
    display: none;
}

.license-clear:active {
    background: #bbb;
}

.license-row button {
    width: 48px;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.license-row button:disabled {
    opacity: 0.5;
}

.own-toggle {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #444;
    cursor: pointer;
}

.own-toggle input[type=checkbox] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.ocr-status {
    margin: 0.4rem 0 0;
    font-size: 0.85rem;
    color: #555;
    min-height: 1.2em;
}

.date-buttons {
    display: flex;
    gap: 0.4rem;
}

.date-buttons button {
    flex: 1;
    padding: 0.55rem 0.5rem;
    font-size: 0.9rem;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
}

.date-buttons button.active {
    background: var(--primary-color);
    color: #fff;
}

.dossier-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dossier-list li {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.dossier-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.15rem;
}

.dossier-list .license {
    font-family: monospace;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.dossier-list .number {
    color: #888;
    font-size: 0.8rem;
}

.dossier-list .customer {
    font-weight: 500;
    font-size: 0.95rem;
}

.dossier-list .opdrachtgever,
.dossier-list .location {
    color: #666;
    font-size: 0.85rem;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #888;
}

.brand-logo {
    display: block;
    max-width: 240px;
    max-height: 100px;
    margin: 2rem auto 1.5rem;
    object-fit: contain;
}

.error {
    color: #c62828;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.dossier-list li {
    cursor: pointer;
}

.dossier-list li:active {
    background: #e3f2fd;
}

.dossier-summary {
    background: #fff;
    padding: 0.85rem 1rem;
    margin: 0 -1rem 1rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    line-height: 1.4;
}

.dossier-summary strong {
    color: var(--primary-color);
    font-family: monospace;
}

.section-h {
    font-size: 0.95rem;
    font-weight: 500;
    color: #555;
    margin: 1rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-h.optional {
    color: #888;
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.checklist-item {
    background: #fff;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.3rem;
    border-radius: 4px;
    border-left: 3px solid #aaa;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.checklist-item.done {
    border-left-color: #2e7d32;
    background: #f1f8f1;
    color: #555;
}

.checklist-item .check {
    width: 22px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--primary-color);
    flex-shrink: 0;
}

.checklist-item.done .check {
    color: #2e7d32;
}

.checklist-item .label {
    flex: 1;
}

.license-photo-banner {
    background: #fff8e1;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.license-photo-banner[hidden] {
    display: none;
}

.license-photo-banner .banner-text {
    font-size: 0.9rem;
    color: #5d4037;
}

.license-photo-banner .banner-actions {
    display: flex;
    gap: 0.4rem;
}

.license-photo-banner button {
    flex: 1;
    padding: 0.5rem;
    font-size: 0.9rem;
    border-radius: 4px;
    cursor: pointer;
}

.license-photo-banner button.primary {
    background: var(--primary-color);
    color: #fff;
    border: none;
}

.license-photo-banner button.dismiss {
    background: #fff;
    color: #666;
    border: 1px solid #ccc;
}

.capture-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.capture-grid[hidden] {
    display: none;
}

.other-category {
    width: 100%;
    padding: 0.6rem;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    margin-bottom: 1rem;
}

.source-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-radius: 12px 12px 0 0;
    padding: 1rem;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    z-index: 1500;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.25s;
}

.source-sheet[hidden] {
    display: none;
}

.source-sheet.visible {
    transform: translateY(0);
}

.source-sheet-title {
    font-size: 0.9rem;
    color: #666;
    text-align: center;
    margin-bottom: 0.75rem;
}

.source-sheet button {
    display: block;
    width: 100%;
    padding: 0.85rem;
    margin-bottom: 0.4rem;
    font-size: 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.source-sheet button.primary {
    background: var(--primary-color);
    color: #fff;
    border: none;
}

.source-sheet button.dismiss {
    background: #fff;
    color: #666;
    border: 1px solid #ccc;
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.capture-btn {
    padding: 0.7rem 0.5rem;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

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

.photo-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.photo-item {
    display: flex;
    gap: 0.75rem;
    background: #fff;
    padding: 0.5rem;
    margin-bottom: 0.4rem;
    border-radius: 4px;
    border-left: 3px solid #ccc;
    align-items: flex-start;
}

.photo-item.status-preparing { border-left-color: #f9a825; }
.photo-item.status-queued { border-left-color: #888; }
.photo-item.status-uploading { border-left-color: var(--primary-color); }
.photo-item.status-failed { border-left-color: #c62828; }

.photo-item img,
.photo-item .thumb-placeholder {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.photo-item .thumb-placeholder {
    background: #eee;
}

.photo-meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    font-size: 0.85rem;
}

.photo-meta strong {
    font-size: 0.95rem;
}

.photo-meta .muted {
    color: #888;
    font-size: 0.8rem;
}

.photo-actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.photo-actions button {
    padding: 0.35rem 0.6rem;
    font-size: 0.8rem;
    background: #fff;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.photo-actions button.remove {
    color: #c62828;
    border-color: #c62828;
}

.status-text {
    color: #666;
}

.status-failed .status-text {
    color: #c62828;
}

.empty {
    color: #888;
    font-style: italic;
    padding: 0.5rem 0;
}

/* === Tablet / iPad layout === */
@media (min-width: 768px) {
    .page {
        max-width: 900px;
        padding: 1.25rem;
    }

    /* Login-form blijft smal en netjes gecentreerd */
    #loginForm {
        max-width: 400px;
        margin: 3rem auto 0;
    }

    /* Dossier-lijst in 2 kolommen */
    .dossier-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .dossier-list li {
        border-bottom: none;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
    }

    /* Foto-lijst (pending + geüpload) in 2 kolommen */
    .photo-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }
    .photo-item {
        margin-bottom: 0;
    }
    .photo-item img,
    .photo-item .thumb-placeholder {
        width: 80px;
        height: 80px;
    }

    /* Sneltoetsen-grid in 3 kolommen ipv 2 */
    .capture-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Checklist in 2 kolommen op iPad */
    .checklist {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
    .checklist-item {
        margin-bottom: 0;
    }

    /* Dossier-summary minder strak tegen rand */
    .dossier-summary {
        margin: 0 0 1rem;
        border-radius: 6px;
        border-bottom: none;
        border: 1px solid #eee;
    }

    /* Filters: niet over hele breedte */
    .filters {
        max-width: 600px;
    }
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lightbox[hidden] {
    display: none;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 0.5rem);
    right: 0.75rem;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.toast {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: calc(env(safe-area-inset-top, 0px) + 1rem);
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem 1.1rem;
    border-radius: 6px;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.35;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.25s, transform 0.25s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    text-align: center;
}

.toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast-warning { background: #f57c00; }
.toast-info { background: var(--primary-color); }
.toast-error { background: #c62828; }
.toast-success { background: #2e7d32; }
