:root {
    --cyan: #00BCD4;
    --cyan-dark: #0097A7;
    --cyan-light: #B2EBF2;
    --black: #1a1a1a;
    --white: #ffffff;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-500: #868e96;
    --gray-700: #495057;
    --gray-900: #212529;
    --danger: #e53935;
    --success: #43a047;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

input, textarea, select {
    font-size: 16px !important;
}

.app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ==================== HEADER ==================== */
.header {
    background: var(--cyan);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 11px;
    opacity: 0.85;
    font-weight: 400;
    display: block;
}

.header-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.header-btn:active {
    background: rgba(255, 255, 255, 0.35);
}

/* ==================== LOGIN ==================== */
.login-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 40px 20px;
    background: linear-gradient(180deg, var(--cyan) 0%, var(--cyan-dark) 100%);
}

.login-logo {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 800;
    color: var(--cyan);
    margin-bottom: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.login-title {
    color: white;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 40px;
}

.pin-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 30px;
}

.pin-digit {
    width: 52px;
    height: 62px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid transparent;
    border-radius: 12px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    outline: none;
}

.pin-digit:focus {
    border-color: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.login-btn {
    width: 100%;
    max-width: 260px;
    padding: 16px;
    background: white;
    color: var(--cyan-dark);
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.login-btn:active { transform: scale(0.98); }
.login-btn:disabled { opacity: 0.5; }

.login-error {
    color: #ffcdd2;
    margin-top: 16px;
    font-size: 14px;
}

/* ==================== DASHBOARD ==================== */
.dashboard {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-title { font-size: 18px; font-weight: 600; color: var(--gray-700); margin-bottom: 8px; }
.empty-text { font-size: 14px; color: var(--gray-500); }

.delivery-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.delivery-card {
    display: block;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    border-left: 4px solid var(--cyan);
    cursor: pointer;
    transition: transform 0.1s;
    text-decoration: none;
    color: inherit;
}

.delivery-card:active { transform: scale(0.98); }

.delivery-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.delivery-bon-nr { font-size: 16px; font-weight: 700; color: var(--cyan-dark); }

.delivery-datum {
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 3px 8px;
    border-radius: 6px;
}

.delivery-klant { font-size: 15px; font-weight: 600; color: var(--gray-900); margin-bottom: 4px; }
.delivery-adres { font-size: 13px; color: var(--gray-500); }

.delivery-meta {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--gray-500);
}

.delivery-meta span {
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

.refresh-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    background: var(--cyan-light);
    color: var(--cyan-dark);
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    text-decoration: none;
}

.refresh-btn:active { background: var(--cyan); color: white; }

/* ==================== DETAIL PAGE ==================== */
.detail-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: white;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: none;
}

.detail-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.detail-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.detail-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 13px; color: var(--gray-500); flex-shrink: 0; margin-right: 12px; }
.detail-value { font-size: 13px; font-weight: 500; color: var(--gray-900); text-align: right; word-break: break-word; }

/* ==================== SIGNATURE ==================== */
.signature-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.input-group { margin-bottom: 16px; }

.input-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.input-field {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus { border-color: var(--cyan); }

.signature-canvas-wrapper {
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    background: white;
    touch-action: none;
}

.signature-canvas-wrapper canvas {
    display: block;
    width: 100%;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.clear-btn {
    background: none;
    border: 1px solid var(--gray-300);
    color: var(--gray-700);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.clear-btn:active { background: var(--gray-100); }

.signature-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--gray-300);
    font-size: 15px;
    pointer-events: none;
}

/* ==================== BUTTONS ==================== */
.confirm-btn {
    width: 100%;
    padding: 16px;
    background: var(--cyan);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 188, 212, 0.3);
}

.confirm-btn:active { background: var(--cyan-dark); }
.confirm-btn:disabled { background: var(--gray-300); box-shadow: none; }

/* ==================== OVERLAYS & MESSAGES ==================== */
.success-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.success-card {
    background: white;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    max-width: 320px;
    width: 100%;
}

.success-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
    color: white;
}

.success-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--gray-900); }
.success-text { font-size: 14px; color: var(--gray-500); margin-bottom: 24px; }

.success-btn {
    display: block;
    width: 100%;
    padding: 14px;
    background: var(--cyan);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.error-msg {
    background: #ffebee;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 16px;
}

.success-msg {
    background: #e8f5e9;
    color: var(--success);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 12px;
}

.info-msg {
    background: var(--cyan-light);
    color: var(--cyan-dark);
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 12px;
}

/* ==================== LOADING ==================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
