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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: #000000;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-wrapper { display: flex; height: 100vh; width: 100vw; overflow: hidden; background: #000000; }

#video-container { flex: 1; position: relative; background: #000000; overflow: hidden; }
#teslaCam { width: 100%; height: 100%; object-fit: cover; display: block; }

#ui-panel {
    width: 440px;
    background: #111111;
    border-left: 1px solid #222222;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: -15px 0 35px rgba(0,0,0,0.9);
    overflow-y: auto;
}

.clock-bar {
    display: flex;
    justify-content: space-between;
    background: #1c1c1d;
    border: 1px solid #2a2a2e;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.clock-label { font-size: 9px; font-weight: 700; color: #888888; }
.clock-value { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; color: #3e6ae1; }

.brand-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
}

.brand-meta { display: flex; flex-direction: column; }
.brand-name { font-size: 10px; letter-spacing: 1.5px; color: #ff4d57; font-weight: 800; }
.brand-sub { font-size: 10px; color: #8a8f98; margin-top: 2px; }

.header { margin-bottom: 20px; }
.header h1 { font-size: 20px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; color: #ffffff; }
.fsd-badge { background: #3e6ae1; color: #ffffff; padding: 4px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; letter-spacing: 0.5px; }
.recipient { font-size: 13px; color: #888888; margin-top: 4px; }

.telemetry-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.telemetry-item {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.telemetry-item span { font-size: 9px; color: #7f8895; text-transform: uppercase; letter-spacing: 0.7px; }
.telemetry-item strong { font-size: 11px; color: #f4f7ff; font-family: 'JetBrains Mono', monospace; }

.battery-container { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 26px; font-weight: 700; color: #2ecc71; margin-bottom: 24px; }
.battery-low-indicator { display: none; font-size: 11px; font-weight: 800; letter-spacing: 0.6px; color: #ff6b6b; text-transform: uppercase; }
.battery-container.low .battery-low-indicator { display: inline-block; animation: lowBatteryFlash 1s infinite; }
.battery-icon { width: 50px; height: 24px; border: 2px solid #2ecc71; border-radius: 4px; position: relative; display: flex; padding: 2px; }
.battery-container.low .battery-icon { border-color: #ff6b6b; }
.battery-icon::after { content: ''; position: absolute; right: -6px; top: 5px; width: 4px; height: 10px; background: #2ecc71; border-radius: 1px; }
.battery-container.low .battery-icon::after { background: #ff6b6b; }
.battery-level { height: 100%; background: #2ecc71; border-radius: 1px; transition: width 1s linear; }
.battery-container.low .battery-level { background: #ff6b6b; }

@keyframes lowBatteryFlash { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.stat-box { background: #1c1c1d; padding: 16px 10px; border-radius: 10px; border: 1px solid #2a2a2e; text-align: center; }
.stat-label { font-size: 10px; color: #888888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; font-weight: 600; }
.stat-value { font-size: 22px; font-weight: 700; color: #ffffff; }
.stat-unit { font-size: 12px; color: #aaaaaa; font-weight: 400; }

.route-info { background: #1c1c1d; padding: 20px; border-radius: 10px; border: 1px solid #2a2a2e; margin-bottom: 20px; }
.route-point { display: flex; align-items: flex-start; }
.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; margin-right: 14px; flex-shrink: 0; }
.dot.origin { background: #3e6ae1; }
.dot.destination { background: #e82127; }
.route-line-dashed { border-left: 2px dashed #444444; height: 22px; margin-left: 5px; margin-top: 4px; margin-bottom: 4px; }
.address h4 { margin: 0 0 2px 0; font-size: 14px; font-weight: 600; color: #ffffff; }
.address p { margin: 0; font-size: 12px; color: #888888; line-height: 1.4; }

.progress-bar-container { width: 100%; background: #2a2a2e; height: 6px; border-radius: 3px; overflow: hidden; margin-top: 20px; }
.progress-bar { height: 100%; background: #3e6ae1; width: 0%; transition: width 1s linear; }
.status-text { text-align: center; font-size: 12px; color: #888888; margin-top: 12px; font-weight: 500; }

.section-head { font-size: 10px; font-weight: 700; color: #888888; letter-spacing: 0.7px; text-transform: uppercase; margin-bottom: 10px; }

.map-card, .dispatch-card, .contact-card {
    background: #1c1c1d;
    border: 1px solid #2a2a2e;
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 20px;
}

.route-map {
    position: relative;
    height: 120px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(62,106,225,0.12), rgba(17,17,17,0.4));
    border: 1px solid rgba(62,106,225,0.35);
    overflow: hidden;
}

.route-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.9;
}

.route-svg path {
    fill: none;
    stroke: rgba(126, 160, 255, 0.85);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 10 12;
    animation: routePulse 3s linear infinite;
}

@keyframes routePulse {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: -220; }
}

.map-line {
    position: absolute;
    left: 18px; right: 18px; top: 50%; height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, #3e6ae1 0%, #8da7ff 50%, #e82127 100%);
    transform: translateY(-50%); opacity: 0.3;
}

.map-stop {
    position: absolute; top: 22px; font-size: 11px; font-weight: 600; color: #dfe7ff;
    background: rgba(17,17,17,0.75); border: 1px solid rgba(255,255,255,0.08);
    padding: 5px 7px; border-radius: 999px;
}

.origin-stop { left: 10px; }
.destination-stop { right: 10px; }

.route-vehicle {
    position: absolute; left: 8%; top: 50%; width: 18px; height: 18px;
    transform: translate(-50%, -50%); border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #dff3ff, #53c9ff 48%, #1b7cd5 100%);
    box-shadow: 0 0 18px rgba(83,201,255,0.8);
    transition: left 0.7s ease, top 0.7s ease;
}

.charge-zone {
    position: absolute; right: 18%; top: 18px; font-size: 10px; font-weight: 700;
    letter-spacing: 0.5px; background: rgba(255,170,0,0.2); color: #ffd769;
    border: 1px solid rgba(255,170,0,0.35); padding: 4px 6px; border-radius: 999px;
    opacity: 0; transition: opacity 0.25s ease;
}

.charge-zone.visible { opacity: 1; }

.map-meta { display: flex; justify-content: space-between; margin-top: 12px; color: #d4d4d8; font-size: 11px; gap: 10px; }
.map-meta strong { color: #ffffff; font-weight: 700; }

.dispatch-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.dispatch-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #7d7d85; transition: color 0.2s ease; }
.dispatch-item.active { color: #ffffff; }
.dispatch-item.complete { color: #7ae1a7; }
.dispatch-dot { width: 8px; height: 8px; background: currentColor; border-radius: 50%; box-shadow: 0 0 10px currentColor; }

.contact-actions { display: flex; gap: 10px; margin-top: 10px; }
.contact-btn {
    flex: 1; border: 1px solid #2a2a2e; border-radius: 8px; padding: 10px 12px;
    text-align: center; font-weight: 700; font-size: 12px; cursor: pointer;
    text-decoration: none; transition: transform 0.2s ease, border-color 0.2s ease;
}
.contact-btn:hover { transform: translateY(-1px); }
.contact-btn.call { background: rgba(62,106,225,0.12); color: #dfe7ff; border-color: rgba(62,106,225,0.4); }
.contact-btn.sms { background: rgba(19,255,123,0.08); color: #b8f5cf; border-color: rgba(19,255,123,0.3); }

.contact-status { margin-top: 12px; font-size: 11px; color: #a7f3d0; }

.info-card { background: #1c1c1d; border: 1px solid #2a2a2e; border-radius: 10px; padding: 14px; margin-bottom: 20px; }
.info-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; }
.info-row:last-child { margin-bottom: 0; }
.info-key { color: #888888; }
.info-val { font-weight: 600; color: #ffffff; }
.highlight-phone a { font-family: 'JetBrains Mono', monospace; color: #3e6ae1; text-decoration: none; }

.history-box { background: #1c1c1d; border: 1px solid #2a2a2e; border-radius: 10px; padding: 14px; margin-bottom: 20px; }
.history-title { font-size: 10px; font-weight: 700; color: #888888; text-transform: uppercase; margin-bottom: 8px; }
.history-list { max-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.history-item { font-size: 11px; color: #cccccc; padding: 4px 0; border-bottom: 1px solid #2a2a2e; }
.history-time { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: #3e6ae1; margin-right: 6px; }

.btn-cancel { width: 100%; padding: 14px; background: transparent; color: #e82127; border: 1px solid #e82127; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; transition: 0.2s; margin-bottom: 20px; }
.btn-cancel:hover { background: rgba(232, 33, 39, 0.1); }

.pod-box { background: #1c1c1d; border: 1px dashed #444444; border-radius: 10px; padding: 14px; font-size: 12px; opacity: 0.5; }
.pod-box.active { opacity: 1; border-color: #2ecc71; }
.pod-title { font-weight: 700; color: #2ecc71; margin-bottom: 8px; text-transform: uppercase; }

.proof-preview { display: none; margin-top: 12px; padding-top: 10px; border-top: 1px solid #2a2a2e; }
.proof-preview.visible { display: block; }

#receiptPreview { display: none; width: 100%; max-height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid #2a2a2e; margin-bottom: 8px; }
#receiptPreview.visible { display: block; }
.proof-status { font-size: 11px; color: #94a3b8; }

.delivery-proof-panel { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.delivery-proof-upload, .signature-box {
    display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: #dbe6ff;
    padding: 9px 10px; border-radius: 8px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.08);
}
.delivery-proof-upload input, .signature-box input {
    width: 100%; background: rgba(17,17,17,0.6); border: 1px solid rgba(255,255,255,0.08);
    color: #f3f4f6; padding: 8px 10px; border-radius: 6px; font-size: 11px;
}

.submit-proof-btn {
    background: linear-gradient(135deg, #e31c25, #ff5b5f); border: none; border-radius: 8px;
    color: white; font-weight: 700; padding: 10px 12px; cursor: pointer; box-shadow: 0 10px 18px rgba(227, 28, 37, 0.25);
}

.toast-container { position: fixed; right: 24px; top: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100001; pointer-events: none; }
.toast { min-width: 220px; max-width: 300px; background: rgba(17, 17, 17, 0.96); border: 1px solid rgba(255,255,255,0.08); border-left: 4px solid #3e6ae1; color: #f3f4f6; padding: 12px 14px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.35); font-size: 12px; animation: toastIn 0.25s ease; }
.toast.warning { border-left-color: #ffd166; }
.toast.success { border-left-color: #34d399; }
.toast.error { border-left-color: #f87171; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* REPOSITIONED TOAST POPUP: Shifted up to avoid blocking submit buttons */
.activity-popup {
    position: fixed;
    right: 24px;
    bottom: 120px; /* Shifted up away from bottom action buttons */
    width: 340px;
    padding: 16px 18px;
    background: #1c1c1d;
    border-left: 5px solid #3e6ae1;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: block;
    z-index: 99999;
    border-top: 1px solid #2a2a2e;
    border-right: 1px solid #2a2a2e;
    border-bottom: 1px solid #2a2a2e;
    opacity: 0.95;
    transform: translateY(0);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.activity-popup.show { opacity: 1; transform: translateY(-2px); }
.activity-label { font-size: 9px; letter-spacing: 1px; color: #3e6ae1; font-weight: 800; margin-bottom: 4px; }
#activityMessage { font-size: 12px; color: #dddddd; line-height: 1.4; }

.charge-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); z-index: 100000; }
.charge-overlay.hidden { display: none; }
.charge-modal { width: min(440px, calc(100vw - 32px)); background: #131416; border: 1px solid #2a2a2e; border-radius: 16px; padding: 22px 20px 18px; text-align: center; box-shadow: 0 18px 40px rgba(0,0,0,0.6); }
.charge-badge { display: inline-block; background: #3e6ae1; color: #fff; padding: 6px 10px; border-radius: 999px; font-size: 10px; letter-spacing: 1px; font-weight: 800; margin-bottom: 12px; }
.charge-modal h3 { color: #fff; font-size: 26px; margin-bottom: 10px; }
.charge-modal p { color: #d1d5db; font-size: 14px; line-height: 1.5; margin-bottom: 12px; }
.charge-contact { color: #94a3b8; font-size: 12px; font-weight: 600; margin-bottom: 18px; }

.charge-mission-panel { background: rgba(21, 24, 28, 0.95); border: 1px solid rgba(126, 160, 255, 0.2); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; box-shadow: inset 0 0 16px rgba(62,106,225,0.12); }
.mission-label { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: #8ea5ff; margin-bottom: 10px; font-weight: 700; }
.mission-row { display: flex; justify-content: space-between; align-items: center; color: #dfe7ff; font-size: 12px; margin-bottom: 8px; }
.mission-row.small { font-size: 11px; color: #cbd5e1; }

.charge-meter { width: 100%; height: 10px; border-radius: 999px; background: rgba(255,255,255,0.05); overflow: hidden; border: 1px solid rgba(255,255,255,0.08); margin-bottom: 10px; }
.charge-meter span { display: block; width: 18%; height: 100%; background: linear-gradient(90deg, #2ecc71 0%, #3e6ae1 52%, #7dd3fc 100%); border-radius: inherit; box-shadow: 0 0 18px rgba(125,211,252,0.8); transition: width 0.9s ease; }

.receipt-upload { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 12px 14px; border: 1px solid #3a3f46; border-radius: 10px; background: #1b1d20; color: #f3f4f6; font-size: 13px; margin-bottom: 10px; }
.receipt-upload input { width: 100%; max-width: 180px; color: #cbd5e1; }
.receipt-file-name { font-size: 12px; color: #94a3b8; min-height: 18px; margin-bottom: 16px; }

.pay-charge-btn { background: linear-gradient(135deg, #3e6ae1, #48b3ff); border: none; color: #fff; border-radius: 8px; padding: 12px 18px; font-size: 14px; font-weight: 700; cursor: pointer; width: 100%; }
.pay-charge-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.charge-blur #video-container, .charge-blur #ui-panel { filter: blur(3px) saturate(0.8); }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.8); display: none; align-items: center; justify-content: center; z-index: 100000; }
.modal-overlay.active { display: flex; }
.modal-box { background: #1c1c1d; padding: 24px; border-radius: 10px; width: 320px; text-align: center; border: 1px solid #2a2a2e; }
.modal-box h3 { font-size: 18px; color: #ffffff; margin-bottom: 8px; }
.modal-box p { font-size: 12px; color: #888888; margin-bottom: 20px; }
.modal-buttons { display: flex; gap: 10px; }
.modal-btn { flex: 1; padding: 10px; border-radius: 6px; font-weight: 600; font-size: 12px; cursor: pointer; border: none; }
.btn-confirm { background: #e82127; color: #ffffff; }
.btn-dismiss { background: #2a2a2e; color: #ffffff; }

@media (max-width: 768px) {
    .app-wrapper { flex-direction: column; overflow-y: hidden; }
    #video-container { width: 100%; height: 50vh; flex: none; position: relative; z-index: 10; }
    #ui-panel {
        position: fixed; left: 0; right: 0; bottom: 0;
        height: calc(50vh + env(safe-area-inset-bottom)); padding: 18px 16px 20px;
        border-left: none; border-top-left-radius: 14px; border-top-right-radius: 14px;
        background: linear-gradient(180deg, rgba(18,18,20,0.98), rgba(14,14,16,0.98));
        box-shadow: 0 -18px 40px rgba(0,0,0,0.7); overflow-y: auto; z-index: 30;
    }
    .activity-popup { right: 12px; bottom: 110px; width: calc(100% - 24px); }
}