/**
 * Charter Boordcomputer v13.4 - Jansen Logistics
 * Bold, tight, professional driver app
 */

/* ============ CSS VARIABLES ============ */
:root {
    --jansen-blue: #2563eb;
    --jansen-blue-dark: #1d4ed8;
    --jansen-blue-darker: #1e3a5f;
    --jansen-blue-light: #3b82f6;
    --jansen-blue-lighter: #dbeafe;

    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    --success: #059669;
    --success-light: #d1fae5;
    --success-dark: #047857;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --warning-dark: #b45309;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --danger-dark: #b91c1c;

    --laden-color: #1d4ed8;
    --laden-bg: #dbeafe;
    --lossen-color: #047857;
    --lossen-bg: #d1fae5;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 50%;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.15);

    --header-height: 56px;
    --bottom-nav-height: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
}

h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; color: var(--gray-900); }

/* ============ SCREENS ============ */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ============ LOGIN SCREEN ============ */
#login-screen {
    background: linear-gradient(145deg, var(--jansen-blue-darker) 0%, var(--jansen-blue-dark) 100%);
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    padding-top: calc(var(--safe-top) + 1.5rem);
}

.login-container { width: 100%; max-width: 380px; }

.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 2rem 1.5rem;
    box-shadow: var(--shadow-xl);
}

.login-header { text-align: center; margin-bottom: 1.5rem; }

.login-logo { width: 220px; height: auto; margin-bottom: 1.25rem; }

.login-header h1 { font-size: 1.25rem; color: var(--gray-900); margin-bottom: 0.125rem; }
.login-header .subtitle { color: var(--gray-500); font-size: 0.8rem; font-weight: 500; }

/* ============ FORM ELEMENTS ============ */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--gray-700); margin-bottom: 0.375rem; text-transform: uppercase; letter-spacing: 0.03em; }

.input-lg {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    text-align: center;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-900);
    transition: all 0.15s ease;
}
.input-lg:focus { outline: none; border-color: var(--jansen-blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.input-lg::placeholder { color: var(--gray-400); font-weight: 400; letter-spacing: normal; }

.pin-inputs {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.pin-digit {
    width: 3.5rem;
    height: 3.5rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--gray-900);
    transition: all 0.15s ease;
    padding: 0;
    -moz-appearance: textfield;
}
.pin-digit::-webkit-outer-spin-button,
.pin-digit::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pin-digit:focus { outline: none; border-color: var(--jansen-blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.pin-digit::placeholder { color: var(--gray-300); font-weight: 400; }

.input-hint { display: block; margin-top: 0.375rem; font-size: 0.7rem; color: var(--gray-500); text-align: center; }

.form-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.15s ease;
}
.form-input:focus { outline: none; border-color: var(--jansen-blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

.form-textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    resize: vertical;
    transition: border-color 0.15s ease;
}
.form-textarea:focus { outline: none; border-color: var(--jansen-blue); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9375rem; font-weight: 700;
    border: none; border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.15s ease;
    text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--jansen-blue);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(37,99,235,0.3);
}
.btn-primary:hover:not(:disabled) { background: var(--jansen-blue-dark); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-success {
    background: var(--success);
    color: var(--white);
    box-shadow: 0 2px 4px rgba(5,150,105,0.3);
}
.btn-success:hover:not(:disabled) { background: var(--success-dark); }

.btn-outline { background: var(--white); color: var(--jansen-blue); border: 2px solid var(--jansen-blue); }
.btn-outline:hover:not(:disabled) { background: var(--jansen-blue-lighter); }

.btn-block { width: 100%; }
.btn-lg { padding: 0.875rem 1.5rem; font-size: 1rem; }
.btn-icon { width: 18px; height: 18px; flex-shrink: 0; }

.btn-loader {
    width: 18px; height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: var(--radius-full);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--gray-400); font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

/* ============ LAST TRIP CARD ============ */
.last-trip-card {
    display: flex;
    align-items: center;
    background: var(--jansen-blue-lighter);
    border: 2px solid var(--jansen-blue);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    gap: 0.625rem;
}
.last-trip-card:active { background: #bfdbfe; }
.last-trip-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.last-trip-icon svg { width: 20px; height: 20px; stroke: var(--jansen-blue-dark); }
.last-trip-info { flex: 1; min-width: 0; }
.last-trip-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--jansen-blue-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}
.last-trip-route {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-top: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.last-trip-meta { flex-shrink: 0; text-align: right; }
.last-trip-code {
    display: block;
    font-size: 1rem;
    font-weight: 800;
    color: var(--jansen-blue-dark);
    line-height: 1;
}
.last-trip-date {
    display: block;
    font-size: 0.65rem;
    color: var(--gray-500);
    margin-top: 0.125rem;
}
.last-trip-chevron { width: 16px; height: 16px; flex-shrink: 0; stroke: var(--gray-400); }

/* ============ ERROR BOX ============ */
.error-box {
    background: var(--danger-light);
    color: var(--danger-dark);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
    border-left: 4px solid var(--danger);
}

.login-footer { text-align: center; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--gray-200); }
.login-footer p { font-size: 0.7rem; color: var(--gray-400); }

/* Language Toggle */
.lang-toggle { display: flex; justify-content: center; gap: 0.25rem; margin-bottom: 0.75rem; }
.lang-btn {
    padding: 0.2rem 0.6rem; border: 1px solid var(--gray-300); background: transparent;
    color: var(--gray-400); border-radius: 4px; cursor: pointer; font-size: 0.7rem; font-weight: 600;
    font-family: 'Inter', sans-serif; transition: all 0.15s;
}
.lang-btn.active { background: var(--jansen-blue); color: var(--white); border-color: var(--jansen-blue); }
.lang-btn:hover:not(.active) { background: var(--gray-100); color: var(--gray-600); }

/* Sync Status Indicator */
.sync-status {
    display: none; align-items: center; gap: 0.25rem;
    padding: 0.1875rem 0.5rem;
    font-size: 0.625rem; font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase; letter-spacing: 0.03em;
    align-self: center;
}
.sync-status.offline { display: inline-flex; background: var(--danger); color: var(--white); }
.sync-status.syncing { display: inline-flex; background: var(--warning); color: var(--white); animation: pulse 1.5s ease-in-out infinite; }
.sync-status.queued { display: inline-flex; background: var(--gray-600); color: var(--white); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ============ SCANNER OVERLAY ============ */
.overlay { position: fixed; inset: 0; background: var(--gray-900); z-index: 1000; display: none; flex-direction: column; }
.overlay.active { display: flex; }
.overlay-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; padding-top: calc(var(--safe-top) + 0.75rem); background: rgba(0,0,0,0.8); color: var(--white); }
.overlay-header h2 { color: var(--white); font-size: 1rem; }

.btn-icon-close {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.15);
    border: none; border-radius: var(--radius-full);
    color: var(--white); font-size: 1.375rem;
    cursor: pointer; transition: background 0.15s ease;
}
.btn-icon-close:hover { background: rgba(255,255,255,0.25); }

.scanner-viewport { flex: 1; position: relative; overflow: hidden; }
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 240px; height: 240px;
    border: 3px solid var(--jansen-blue-light);
    border-radius: var(--radius-md);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}
.corner { position: absolute; width: 20px; height: 20px; border-color: var(--white); border-style: solid; }
.corner.tl { top: -3px; left: -3px; border-width: 4px 0 0 4px; border-radius: 6px 0 0 0; }
.corner.tr { top: -3px; right: -3px; border-width: 4px 4px 0 0; border-radius: 0 6px 0 0; }
.corner.bl { bottom: -3px; left: -3px; border-width: 0 0 4px 4px; border-radius: 0 0 0 6px; }
.corner.br { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 6px 0; }
.scanner-hint { text-align: center; padding: 1rem; color: var(--gray-300); font-size: 0.8rem; background: rgba(0,0,0,0.8); }

/* ============ APP SCREEN ============ */
#app-screen { background: var(--gray-100); padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom)); }

/* ============ APP HEADER ============ */
.app-header {
    position: sticky; top: 0; z-index: 100;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.625rem 1rem;
    padding-top: calc(var(--safe-top) + 0.625rem);
    background: var(--jansen-blue-darker);
    color: var(--white);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.header-left { display: flex; align-items: center; gap: 0.625rem; }
.header-left h1 { font-size: 1.125rem; font-weight: 800; color: var(--white); letter-spacing: -0.02em; }

.header-right { display: flex; gap: 0.375rem; }
.header-right .btn-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.1);
    border: none; border-radius: var(--radius-md);
    color: var(--white); cursor: pointer;
    transition: all 0.15s ease;
}
.header-right .btn-icon:hover { background: rgba(255,255,255,0.2); }
.header-right .btn-icon svg { width: 22px; height: 22px; }
.header-right .btn-icon.spinning svg { animation: spin 0.7s linear infinite; }

/* ============ BADGES ============ */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.1875rem 0.5rem;
    font-size: 0.6875rem; font-weight: 800;
    border-radius: var(--radius-sm);
    text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-primary { background: rgba(255,255,255,0.2); color: var(--white); }
.badge-warning { background: var(--warning); color: var(--white); }
.badge-success { background: var(--success); color: var(--white); }

/* ============ INFO BAR ============ */
.info-bar {
    display: flex; gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--white);
    border-bottom: 2px solid var(--gray-200);
}
.info-row { display: flex; align-items: center; gap: 0.375rem; font-size: 0.8rem; font-weight: 600; color: var(--gray-600); }
.info-row svg { width: 16px; height: 16px; color: var(--jansen-blue); flex-shrink: 0; }

/* ============ PROGRESS SECTION ============ */
.progress-section {
    padding: 0.75rem 1rem;
    background: var(--white);
    border-bottom: 2px solid var(--gray-200);
}
.progress-stats { display: flex; justify-content: center; gap: 2rem; margin-bottom: 0.5rem; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 1.75rem; font-weight: 800; color: var(--jansen-blue-dark); line-height: 1; }
.stat-label { font-size: 0.625rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-top: 0.125rem; }
.cmr-stat .stat-value { color: var(--success); }

.progress-bar-container { height: 6px; background: var(--gray-200); border-radius: var(--radius-full); overflow: hidden; }
.progress-bar {
    height: 100%;
    background: var(--jansen-blue);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

/* ============ MAIN CONTENT ============ */
.main-content { padding: 0.75rem; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.section-header h2 { font-size: 0.8125rem; font-weight: 800; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.06em; }

/* ============ TASK LIST ============ */
.task-list { list-style: none; display: flex; flex-direction: column; gap: 0.625rem; }
.task-loading { text-align: center; padding: 2rem; color: var(--gray-500); }
.task-loading .spinner { width: 28px; height: 28px; border: 3px solid var(--gray-200); border-top-color: var(--jansen-blue); border-radius: var(--radius-full); animation: spin 0.7s linear infinite; margin: 0 auto 0.5rem; }

.task-item {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s ease;
}
.task-item:hover { box-shadow: var(--shadow-md); }
.task-item:active { transform: scale(0.99); }
.task-item[data-status="in_progress"] { box-shadow: var(--shadow-md); outline: 2px solid var(--warning); }

/* --- Card Top Bar --- */
.task-card-top {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    gap: 0.5rem;
}
.task-card-top-left { display: flex; align-items: center; gap: 0.375rem; min-width: 0; }
.task-card-top-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

.task-type-badge {
    display: inline-flex; align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem; font-weight: 800;
    border-radius: 4px;
    text-transform: uppercase; letter-spacing: 0.05em;
    white-space: nowrap;
}
.task-type-badge.laden { background: var(--laden-bg); color: var(--laden-color); }
.task-type-badge.lossen { background: var(--lossen-bg); color: var(--lossen-color); }

.task-seq { font-size: 0.625rem; font-weight: 700; color: var(--gray-400); }
.task-order {
    font-size: 0.625rem; font-weight: 700; color: var(--jansen-blue);
    background: var(--jansen-blue-lighter); padding: 0.0625rem 0.375rem; border-radius: 4px;
    white-space: nowrap;
}
.task-ref {
    font-size: 0.625rem; font-weight: 600; color: var(--gray-600);
    background: var(--gray-100); padding: 0.0625rem 0.375rem; border-radius: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px;
}

.task-time { font-size: 0.6875rem; font-weight: 700; color: var(--gray-500); white-space: nowrap; }
.task-time.active-time { color: var(--warning-dark); }
.task-time.completed-time { color: var(--success-dark); }

.cmr-dot {
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full);
    font-size: 0.625rem; font-weight: 800; flex-shrink: 0;
}
.cmr-dot.has-cmr { background: var(--success-light); color: var(--success); }
.cmr-dot.no-cmr { background: var(--danger-light); color: var(--danger); }

/* --- Card Body --- */
.task-card-body { display: flex; }
.task-status-bar { width: 5px; flex-shrink: 0; background: var(--gray-300); }
.task-status-bar.completed { background: var(--success); }
.task-status-bar.in_progress { background: var(--warning); }
.task-status-bar.pending { background: var(--jansen-blue); }

.task-card-main { flex: 1; padding: 0.625rem 0.75rem; min-width: 0; }
.task-location { font-weight: 700; font-size: 0.9375rem; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3; }
.task-address { font-size: 0.6875rem; color: var(--gray-400); font-weight: 500; margin-top: 0.0625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-customer { font-size: 0.75rem; color: var(--gray-600); font-weight: 600; margin-top: 0.25rem; }
.task-product { font-size: 0.6875rem; color: var(--gray-400); font-weight: 500; font-style: italic; margin-top: 0.0625rem; }

/* --- Card Footer (Cargo) --- */
.task-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.375rem 0.75rem;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    gap: 0.5rem;
}
.cargo-grid { display: flex; gap: 0.75rem; }
.cargo-cell { display: flex; align-items: baseline; gap: 0.1875rem; }
.cargo-val { font-size: 0.8125rem; font-weight: 800; color: var(--gray-800); }
.cargo-lbl { font-size: 0.5625rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.03em; }

.cargo-temp {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem; font-weight: 700;
    white-space: nowrap; flex-shrink: 0;
}
.cargo-temp.frozen { background: #e0f2fe; color: #0369a1; }
.cargo-temp.chilled { background: #dbeafe; color: #1d4ed8; }

/* ============ VIEW PANELS ============ */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* ============ DOCUMENTS VIEW ============ */
.documents-list { display: flex; flex-direction: column; gap: 0.75rem; }

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 3rem 1.5rem; text-align: center; color: var(--gray-400);
}
.empty-icon { width: 48px; height: 48px; margin-bottom: 1rem; stroke: var(--gray-300); }
.empty-state p { font-weight: 600; font-size: 0.9375rem; color: var(--gray-500); margin-bottom: 0.25rem; }
.empty-hint { font-size: 0.75rem; }

.doc-group { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.doc-group-header {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.doc-group-title { font-size: 0.75rem; font-weight: 700; color: var(--gray-700); }
.doc-group-ref { font-size: 0.625rem; font-weight: 600; color: var(--gray-400); background: var(--gray-100); padding: 0.0625rem 0.375rem; border-radius: 4px; }

.doc-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--gray-100);
    text-decoration: none; color: inherit;
    transition: background 0.1s;
}
.doc-item:last-child { border-bottom: none; }
.doc-item:active { background: var(--gray-50); }

.doc-icon { width: 36px; height: 36px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; background: var(--danger-light); border-radius: var(--radius-md); color: var(--danger); }
.doc-icon svg { width: 20px; height: 20px; }

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 0.8125rem; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.6875rem; color: var(--gray-400); font-weight: 500; margin-top: 0.125rem; }
.doc-type-badge { font-size: 0.5625rem; font-weight: 800; background: var(--gray-200); color: var(--gray-600); padding: 0 0.25rem; border-radius: 3px; text-transform: uppercase; }

.doc-chevron { width: 18px; height: 18px; flex-shrink: 0; color: var(--gray-300); }

/* ============ INFO VIEW ============ */
.info-content { display: flex; flex-direction: column; gap: 0.75rem; }

.info-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    padding: 0.875rem;
}
.info-section-header {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.625rem; padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-100);
}
.info-section-header svg { width: 18px; height: 18px; color: var(--jansen-blue); flex-shrink: 0; }
.info-section-header h3 { font-size: 0.8125rem; font-weight: 800; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.04em; }

.info-grid {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.info-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.info-cell { display: flex; flex-direction: column; gap: 0.0625rem; }
.info-cell.full { grid-column: 1 / -1; }
.info-label { font-size: 0.625rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.04em; }
.info-value { font-size: 0.8125rem; font-weight: 600; color: var(--gray-800); }
.info-value.big { font-size: 1.125rem; font-weight: 800; color: var(--gray-900); }

.info-stat { display: flex; flex-direction: column; align-items: center; text-align: center; }
.info-stat-val { font-size: 1.25rem; font-weight: 800; color: var(--gray-900); }
.info-stat-lbl { font-size: 0.625rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; }

.info-progress-bar {
    height: 8px; background: var(--gray-100); border-radius: 4px;
    margin-bottom: 0.625rem; overflow: hidden;
}
.info-progress-fill { height: 100%; background: var(--success); border-radius: 4px; transition: width 0.3s ease; }

.info-customer-list { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.info-customer-chip {
    display: inline-flex; align-items: center;
    padding: 0.1875rem 0.5rem;
    background: var(--gray-100); border-radius: 4px;
    font-size: 0.75rem; font-weight: 600; color: var(--gray-600);
}

/* ============ BOTTOM NAVIGATION ============ */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex; background: var(--white);
    border-top: 2px solid var(--gray-200);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 100;
}
.nav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 0.125rem; padding: 0.375rem;
    background: none; border: none; color: var(--gray-400);
    cursor: pointer; transition: all 0.15s ease; position: relative;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn span { font-size: 0.5625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.nav-btn.active { color: var(--jansen-blue); }
.nav-btn.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 32px; height: 3px; background: var(--jansen-blue); border-radius: 0 0 3px 3px;
}

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 1000; display: none; }
.modal.active { display: flex; align-items: flex-end; }

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-container {
    position: relative; width: 100%;
    max-height: 92vh;
    background: var(--white);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    display: flex; flex-direction: column;
    animation: slideUp 0.2s ease;
    box-shadow: var(--shadow-xl);
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 1rem;
    border-bottom: 2px solid var(--gray-200);
}
.modal-title-group { display: flex; flex-direction: column; gap: 0.125rem; }
.modal-title-group h2 { font-size: 1.0625rem; }

.modal-body { flex: 1; overflow-y: auto; padding: 0.75rem; -webkit-overflow-scrolling: touch; }

.modal-actions {
    display: flex; flex-direction: column; gap: 0.5rem;
    padding: 0.75rem;
    padding-bottom: calc(var(--safe-bottom) + 0.75rem);
    border-top: 2px solid var(--gray-200);
    background: var(--gray-50);
}

/* ============ DETAIL SECTIONS ============ */
.detail-section { margin-bottom: 0.75rem; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 {
    font-size: 0.6875rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--gray-500); margin-bottom: 0.375rem;
}

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.375rem; }

.detail-item {
    background: var(--gray-50);
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-100);
}
.detail-item .label {
    display: block; font-size: 0.5625rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--gray-500); font-weight: 700;
    margin-bottom: 0.0625rem;
}
.detail-item .value { font-weight: 700; color: var(--gray-800); font-size: 0.875rem; }
.detail-item.full { grid-column: span 2; }
.detail-item.remarks { background: var(--warning-light); border-left: 3px solid var(--warning); }
.detail-item.remarks .value { color: var(--gray-700); font-weight: 600; }

/* ============ SECTION CARD ============ */
.section-card {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: 0.625rem;
    margin-bottom: 0.625rem;
    border: 1px solid var(--gray-200);
}
.section-card:last-child { margin-bottom: 0; }
.section-card h4 {
    font-size: 0.6875rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--gray-500); margin-bottom: 0.375rem;
}

/* ============ STATUS BADGE ============ */
.status-badge {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8125rem; font-weight: 700;
}
.status-badge.status-completed { background: var(--success-light); color: var(--success-dark); }
.status-badge.status-active { background: var(--warning-light); color: var(--warning-dark); }
.status-badge.status-pending { background: var(--jansen-blue-lighter); color: var(--jansen-blue-dark); }

/* ============ DELIVERY INFO ============ */
.delivery-info {
    background: var(--white);
    border: 2px solid var(--success);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.625rem;
    margin-top: 0.5rem;
}
.delivery-info .delivery-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.1875rem 0; font-size: 0.8125rem;
}
.delivery-info .delivery-row .label { color: var(--gray-600); font-weight: 600; }
.delivery-info .delivery-row .value { color: var(--gray-900); font-weight: 800; }

/* Deviation info in delivery */
.deviation-info {
    background: var(--danger-light);
    border: 2px solid var(--danger);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.625rem;
    margin-top: 0.375rem;
}
.deviation-info .delivery-row { display: flex; justify-content: space-between; padding: 0.125rem 0; font-size: 0.8125rem; }
.deviation-info .delivery-row .label { color: var(--danger-dark); font-weight: 600; }
.deviation-info .delivery-row .value { color: var(--danger-dark); font-weight: 800; }

/* ============ COLLAPSIBLE HEADER ============ */
.collapsible-header {
    cursor: pointer; user-select: none;
    display: flex; align-items: center; justify-content: space-between;
}
.collapsible-header::after { content: '\25B8'; font-size: 0.8rem; color: var(--gray-400); transition: transform 0.15s ease; }
.collapsible-header.open::after { transform: rotate(90deg); }

/* ============ CAMERA MODAL ============ */
.camera-modal .modal-backdrop { display: none; }
.camera-container { position: fixed; inset: 0; background: black; display: flex; flex-direction: column; }
.camera-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; padding-top: calc(var(--safe-top) + 0.75rem);
    color: var(--white);
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
    position: absolute; top: 0; left: 0; right: 0; z-index: 10;
}
.camera-header span { font-size: 0.8rem; font-weight: 600; }

.camera-viewport { flex: 1; position: relative; overflow: hidden; }
#camera-video { width: 100%; height: 100%; object-fit: cover; }


.camera-controls {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem; padding-bottom: calc(var(--safe-bottom) + 1rem);
    background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, transparent 100%);
    position: absolute; bottom: 0; left: 0; right: 0;
}
.btn-camera-switch {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.2); border: none;
    border-radius: var(--radius-full); color: var(--white); cursor: pointer;
}
.btn-camera-switch svg { width: 22px; height: 22px; }

.btn-capture {
    width: 64px; height: 64px;
    background: var(--white); border: 4px solid var(--jansen-blue);
    border-radius: var(--radius-full); cursor: pointer;
    padding: 3px; transition: all 0.15s ease;
}
.btn-capture:active { transform: scale(0.92); }
.capture-inner { display: block; width: 100%; height: 100%; background: var(--jansen-blue); border-radius: var(--radius-full); }

/* ============ PREVIEW MODAL ============ */
.preview-container { max-height: 100vh; height: 100vh; border-radius: 0; }
.preview-body { flex: 1; position: relative; background: var(--gray-900); display: flex; align-items: center; justify-content: center; overflow: hidden; }
#preview-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.processing-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.8); display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--white); }
.spinner-lg { width: 40px; height: 40px; border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--white); border-radius: var(--radius-full); animation: spin 0.7s linear infinite; margin-bottom: 0.75rem; }

/* ============ DRAWER ============ */
.drawer { position: fixed; inset: 0; z-index: 1001; display: none; }
.drawer.active { display: flex; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); animation: fadeIn 0.15s ease; }

.drawer-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 300px; max-width: 85vw;
    background: var(--white);
    display: flex; flex-direction: column;
    animation: slideInRight 0.2s ease;
    box-shadow: var(--shadow-xl);
}
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem;
    padding-top: calc(var(--safe-top) + 1rem);
    background: var(--jansen-blue-darker);
    color: var(--white);
}
.drawer-header h2 { color: var(--white); font-size: 1rem; }

.drawer-user { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
.avatar { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: var(--jansen-blue-lighter); border-radius: var(--radius-full); color: var(--jansen-blue); }
.avatar svg { width: 24px; height: 24px; }
.user-info { display: flex; flex-direction: column; }
.user-name { font-weight: 700; color: var(--gray-800); font-size: 0.9375rem; }
.user-trip { font-size: 0.8rem; color: var(--gray-500); font-weight: 600; }

.drawer-nav { flex: 1; padding: 0.5rem; overflow-y: auto; }
.drawer-nav a {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: var(--gray-700); text-decoration: none;
    border-radius: var(--radius-md); font-weight: 600;
    transition: all 0.15s ease;
}
.drawer-nav a:hover { background: var(--gray-100); }
.drawer-nav a svg { width: 20px; height: 20px; color: var(--gray-500); }
.drawer-nav hr { border: none; height: 1px; background: var(--gray-200); margin: 0.5rem 0; }
.drawer-nav a.nav-danger { color: var(--danger); }
.drawer-nav a.nav-danger svg { color: var(--danger); }

.drawer-footer { padding: 0.75rem; border-top: 1px solid var(--gray-200); text-align: center; }
.drawer-footer p { font-size: 0.6875rem; color: var(--gray-400); line-height: 1.5; }

/* ============ TOAST ============ */
.toast-container {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 0.5rem);
    left: 0.5rem; right: 0.5rem;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 0.375rem;
    pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--gray-800);
    color: var(--white);
    border-radius: var(--radius-md);
    font-size: 0.8125rem; font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.2s ease;
    pointer-events: auto;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============ INSTALL BANNER ============ */
.install-banner {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; align-items: center; gap: 0.75rem;
    padding: 1rem 1.25rem;
    padding-bottom: calc(var(--safe-bottom) + 1rem);
    background: var(--white);
    border-top: 2px solid var(--jansen-blue);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.install-banner.visible { transform: translateY(0); }
.install-banner-icon {
    width: 40px; height: 40px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--jansen-blue-lighter); color: var(--jansen-blue);
    border-radius: var(--radius-md);
}
.install-banner-icon svg { width: 22px; height: 22px; }
.install-banner-content { flex: 1; min-width: 0; }
.install-banner-content strong { display: block; font-size: 0.875rem; color: var(--gray-900); margin-bottom: 0.125rem; }
.install-banner-content p { font-size: 0.75rem; color: var(--gray-500); line-height: 1.3; margin: 0; }
.install-banner-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }
.btn-dismiss {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: var(--gray-400);
    font-size: 1.25rem; cursor: pointer; border-radius: var(--radius-full);
}
.btn-dismiss:hover { background: var(--gray-100); color: var(--gray-600); }

/* ============ PHOTO NEXT DIALOG ============ */
.photo-next-dialog {
    display: flex; flex-direction: column; align-items: center;
    padding: 1.5rem 1rem; gap: 1rem; text-align: center;
}
.photo-next-success {
    display: flex; align-items: center; gap: 0.75rem;
    color: var(--success); font-size: 1.125rem; font-weight: 600;
}
.photo-next-icon { width: 32px; height: 32px; flex-shrink: 0; }
.photo-next-question {
    font-size: 1rem; font-weight: 500; color: var(--gray-700);
    margin: 0.25rem 0 0.5rem;
}
.photo-next-options {
    display: flex; flex-direction: column; gap: 0.5rem;
    width: 100%; max-width: 360px;
}
.photo-next-btn {
    display: flex; align-items: center; gap: 0.75rem;
    width: 100%; padding: 0.875rem 1rem;
    background: var(--white); border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-md); cursor: pointer;
    text-align: left; transition: all 0.15s ease;
}
.photo-next-btn:hover { border-color: var(--jansen-blue); background: var(--jansen-blue-lighter); }
.photo-next-btn:active { transform: scale(0.98); }
.photo-next-btn svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--jansen-blue); }
.photo-next-btn strong { display: block; font-size: 0.9375rem; color: var(--gray-800); }
.photo-next-btn small { display: block; font-size: 0.75rem; color: var(--gray-500); margin-top: 0.125rem; }
.photo-next-btn.done {
    border-color: var(--success); background: var(--success-light);
}
.photo-next-btn.done svg { color: var(--success); }
.photo-next-btn.done:hover { background: var(--success); border-color: var(--success-dark); }
.photo-next-btn.done:hover strong { color: var(--white); }

/* ============ UTILITY ============ */
.text-center { text-align: center; }
.text-muted { color: var(--gray-500); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }

/* ============ ROUTE MAP VIEW ============ */
.route-view { padding: 0; position: relative; overflow: hidden; }
.route-view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }

#route-map {
    flex: 1;
    width: 100%;
    min-height: 200px;
}

/* Custom map markers */
.route-marker {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-full);
    color: var(--white);
    font-size: 0.75rem; font-weight: 800;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.15s ease;
    border: 3px solid var(--white);
}
.route-marker:hover { transform: scale(1.15); }

.route-marker.laden { background: var(--laden-color); }
.route-marker.lossen { background: var(--lossen-color); }

.route-marker.active {
    opacity: 1;
    animation: markerPulse 2s ease-in-out infinite;
    border-color: var(--warning);
}
@keyframes markerPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.4), 0 2px 8px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 8px rgba(245,158,11,0), 0 2px 8px rgba(0,0,0,0.3); }
}

/* Driver location dot */
.driver-dot {
    width: 18px; height: 18px;
    background: var(--jansen-blue);
    border: 3px solid var(--white);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 0 rgba(37,99,235,0.4), 0 2px 6px rgba(0,0,0,0.3);
    animation: driverPulse 2s ease-in-out infinite;
}
@keyframes driverPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37,99,235,0.4), 0 2px 6px rgba(0,0,0,0.3); }
    50% { box-shadow: 0 0 0 12px rgba(37,99,235,0), 0 2px 6px rgba(0,0,0,0.3); }
}

/* Mapbox popup theming */
.mapboxgl-popup-content {
    background: var(--gray-800) !important;
    color: var(--white) !important;
    border-radius: var(--radius-md) !important;
    padding: 0.625rem 0.75rem !important;
    box-shadow: var(--shadow-lg) !important;
    font-family: inherit !important;
    min-width: 180px;
}
.mapboxgl-popup-tip { border-top-color: var(--gray-800) !important; }
.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip { border-top-color: var(--gray-800) !important; }
.mapboxgl-popup-anchor-top .mapboxgl-popup-tip { border-bottom-color: var(--gray-800) !important; }
.mapboxgl-popup-anchor-left .mapboxgl-popup-tip { border-right-color: var(--gray-800) !important; }
.mapboxgl-popup-anchor-right .mapboxgl-popup-tip { border-left-color: var(--gray-800) !important; }
.mapboxgl-popup-close-button { color: var(--gray-400) !important; font-size: 1.25rem; padding: 0.25rem 0.5rem; }
.mapboxgl-popup-close-button:hover { color: var(--white) !important; background: transparent !important; }

.map-popup-type {
    display: inline-block;
    font-size: 0.5625rem; font-weight: 800;
    text-transform: uppercase; letter-spacing: 0.05em;
    padding: 0.0625rem 0.375rem; border-radius: 3px;
    margin-bottom: 0.25rem;
}
.map-popup-type.laden { background: var(--laden-bg); color: var(--laden-color); }
.map-popup-type.lossen { background: var(--lossen-bg); color: var(--lossen-color); }

.map-popup-name { font-weight: 700; font-size: 0.875rem; margin-bottom: 0.125rem; }
.map-popup-address { font-size: 0.6875rem; color: var(--gray-400); margin-bottom: 0.25rem; }
.map-popup-customer { font-size: 0.75rem; color: var(--gray-300); }
.map-popup-status { font-size: 0.625rem; font-weight: 700; margin-top: 0.25rem; }
.map-popup-status.completed { color: var(--success); }
.map-popup-status.active { color: var(--warning); }
.map-popup-status.pending { color: var(--jansen-blue-light); }

/* Recenter button on map */
.map-recenter-btn {
    position: absolute; bottom: 1rem; right: 1rem;
    width: 44px; height: 44px;
    background: var(--white); border: none;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-md);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10;
    transition: all 0.15s ease;
}
.map-recenter-btn:hover { background: var(--gray-50); box-shadow: var(--shadow-lg); }
.map-recenter-btn svg { width: 22px; height: 22px; color: var(--gray-700); }

/* ============ RESPONSIVE ============ */
@media (min-width: 768px) {
    .login-card { padding: 2rem 2.5rem; }
    .modal-container { max-width: 480px; margin: auto; border-radius: var(--radius-xl); max-height: 85vh; }
    .modal.active { align-items: center; justify-content: center; padding: 1rem; }
    .preview-container { max-height: 90vh; height: auto; border-radius: var(--radius-xl); }
}
