* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --green: #2E7D32;
    --green-light: #E8F5E9;
    --orange: #EF6C00;
    --orange-light: #FFF3E0;
    --red: #C62828;
    --red-light: #FFEBEE;
    --purple: #6A1B9A;
    --bg: #F8F9FA;
    --card: #FFFFFF;
    --text: #212121;
    --text-secondary: #757575;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --radius: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text);
    min-height: 100vh; min-height: 100dvh;
    overflow-x: hidden; -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 480px; margin: 0 auto;
    min-height: 100vh; min-height: 100dvh; position: relative;
}

.header {
    background: var(--primary); color: white;
    padding: 16px 20px; display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(21,101,192,0.3);
}

.header-back {
    background: rgba(255,255,255,0.15); border: none; color: white;
    width: 40px; height: 40px; border-radius: 12px;
    font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

.header-title { font-size: 18px; font-weight: 700; flex: 1; }

.header-badge {
    background: rgba(255,255,255,0.2); padding: 4px 10px;
    border-radius: 8px; font-size: 11px; font-weight: 600;
}

.card {
    background: var(--card); border-radius: var(--radius);
    padding: 16px; margin: 12px 16px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}

.btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 16px 24px; border: none; border-radius: 14px;
    font-size: 16px; font-weight: 700; cursor: pointer;
    width: 100%; transition: all 0.2s;
    -webkit-user-select: none; user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-green { background: var(--green); color: white; }
.btn-orange { background: var(--orange); color: white; }
.btn-red { background: var(--red); color: white; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-sm { padding: 10px 16px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; padding: 0 16px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.input-group { margin-bottom: 16px; }

.input-label {
    display: block; font-size: 14px; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}

.input {
    width: 100%; padding: 14px 16px; border: 2px solid var(--border);
    border-radius: 12px; font-size: 16px; background: var(--bg);
    color: var(--text); outline: none; transition: border-color 0.2s;
}

.input:focus { border-color: var(--primary); }

.input-big {
    font-size: 28px; font-weight: 700; text-align: center; padding: 16px;
}

.stats-panel {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 20px; color: white;
}

.stats-panel.paused {
    background: linear-gradient(135deg, var(--orange), #E65100);
}

.stats-main { display: flex; gap: 0; }
.stats-main-item { flex: 1; text-align: center; }
.stats-main-item + .stats-main-item { border-left: 1px solid rgba(255,255,255,0.2); }

.stats-label {
    font-size: 11px; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.5px;
}

.stats-value {
    font-size: 28px; font-weight: 800; margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.stats-value-sm { font-size: 22px; }

.stats-row {
    display: flex; justify-content: space-around;
    margin-top: 14px; padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.stats-mini {
    display: flex; align-items: center; gap: 4px;
    font-size: 13px; opacity: 0.9;
}

.paused-badge { text-align: center; margin-bottom: 12px; }
.paused-badge span {
    background: rgba(255,255,255,0.2); padding: 4px 16px;
    border-radius: 20px; font-size: 13px; font-weight: 700; letter-spacing: 1px;
}

.gps-signal {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; margin: 8px 16px;
    border-radius: 12px; font-size: 13px; font-weight: 600;
}

.gps-signal.excellent { background: #E8F5E9; color: #2E7D32; }
.gps-signal.good { background: #F1F8E9; color: #558B2F; }
.gps-signal.fair { background: #FFF3E0; color: #EF6C00; }
.gps-signal.poor { background: #FFEBEE; color: #C62828; }
.gps-signal.none { background: #ECEFF1; color: #607D8B; }

.signal-bars { display: flex; align-items: flex-end; gap: 2px; height: 18px; }

.signal-bar {
    width: 4px; border-radius: 2px; background: #CFD8DC; transition: background 0.3s;
}

.signal-bar.active.excellent { background: #2E7D32; }
.signal-bar.active.good { background: #558B2F; }
.signal-bar.active.fair { background: #EF6C00; }
.signal-bar.active.poor { background: #C62828; }

.delivery-item {
    background: var(--card); border-radius: 14px;
    padding: 14px; margin: 8px 16px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
    display: flex; gap: 12px; align-items: flex-start; transition: all 0.2s;
}

.delivery-item.completed { background: var(--green-light); border-color: #C8E6C9; }

.delivery-number {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px; flex-shrink: 0;
}

.delivery-item.completed .delivery-number { background: var(--green); }

.delivery-info { flex: 1; min-width: 0; }
.delivery-client { font-weight: 700; font-size: 15px; }
.delivery-item.completed .delivery-client { text-decoration: line-through; opacity: 0.7; }
.delivery-address { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

.delivery-obs {
    background: #FFF8E1; padding: 6px 8px; border-radius: 6px;
    font-size: 11px; color: #F57F17; margin-top: 6px;
}

.delivery-stats {
    display: flex; gap: 12px; margin-top: 8px; padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: 12px; font-weight: 600; color: var(--green);
}

.delivery-btn {
    padding: 8px 14px; background: var(--green); color: white;
    border: none; border-radius: 10px; font-size: 13px;
    font-weight: 700; cursor: pointer; flex-shrink: 0; align-self: center;
}

.delivery-btn:active { transform: scale(0.95); }

.stat-card {
    display: flex; align-items: center; gap: 14px;
    background: var(--card); border-radius: var(--radius);
    padding: 14px 16px; margin: 6px 16px;
    box-shadow: var(--shadow); border: 1px solid var(--border);
}

.stat-icon {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}

.stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-value { font-size: 18px; font-weight: 800; }

.menu-btn {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 20px; margin: 8px 16px;
    background: var(--card); border-radius: 18px;
    border: 1px solid var(--border); box-shadow: var(--shadow);
    cursor: pointer; transition: all 0.2s;
    text-decoration: none; color: var(--text);
}

.menu-btn:active { transform: scale(0.98); }

.menu-icon {
    width: 48px; height: 48px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}

.menu-text { flex: 1; }
.menu-title { font-size: 16px; font-weight: 700; }
.menu-subtitle { font-size: 12px; color: var(--text-secondary); }
.menu-arrow { color: #BDBDBD; font-size: 20px; }

.history-card {
    background: var(--card); border-radius: var(--radius);
    padding: 16px; margin: 8px 16px;
    box-shadow: var(--shadow); border: 1px solid var(--border); cursor: pointer;
}

.history-card:active { transform: scale(0.98); }

.history-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}

.history-icon {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--green-light);
    display: flex; align-items: center; justify-content: center;
}

.history-stats {
    display: flex; justify-content: space-around;
    padding-top: 12px; border-top: 1px solid var(--border);
}

.history-stat {
    text-align: center; font-size: 13px; font-weight: 600; color: var(--text-secondary);
}

.history-date { font-size: 11px; color: #BDBDBD; margin-top: 8px; }

.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-secondary);
}

.empty-state .emoji { font-size: 64px; margin-bottom: 12px; }

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 1000; display: flex; align-items: flex-end;
    justify-content: center; animation: fadeIn 0.2s;
}

.modal {
    background: white; border-radius: 20px 20px 0 0;
    padding: 24px 20px; width: 100%; max-width: 480px;
    max-height: 85vh; overflow-y: auto; animation: slideUp 0.3s;
}

.modal-title { font-size: 20px; font-weight: 800; margin-bottom: 20px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.confirm-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 2000; display: flex; align-items: center;
    justify-content: center; padding: 20px; animation: fadeIn 0.2s;
}

.confirm-box {
    background: white; border-radius: 20px; padding: 24px;
    width: 100%; max-width: 340px; text-align: center;
}

.confirm-title { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.confirm-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btns .btn { flex: 1; padding: 12px; }

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px 4px;
}

.section-title { font-size: 17px; font-weight: 800; }

.section-action {
    background: none; border: none; color: var(--primary);
    font-size: 14px; font-weight: 700; cursor: pointer;
}

.p-16 { padding: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); font-size: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.fw-700 { font-weight: 700; }

.success-banner {
    background: var(--green); color: white;
    padding: 20px; border-radius: 18px; margin: 16px; text-align: center;
}

.success-banner .emoji { font-size: 48px; }
.success-banner h2 { font-size: 22px; margin-top: 8px; }
.success-banner p { opacity: 0.8; font-size: 14px; }

.toast {
    position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: #323232; color: white; padding: 12px 24px;
    border-radius: 12px; font-size: 14px; font-weight: 600;
    z-index: 5000; animation: slideUp 0.3s, fadeIn 0.3s;
    max-width: 90%; text-align: center;
}

.toast.success { background: var(--green); }
.toast.error { background: var(--red); }

.delete-btn {
    background: none; border: none; color: var(--red);
    font-size: 13px; font-weight: 600; cursor: pointer; padding: 8px;
}

.home-header {
    padding: 30px 20px 10px; display: flex; align-items: center; gap: 14px;
}

.home-logo {
    width: 56px; height: 56px; border-radius: 16px;
    background: rgba(21,101,192,0.1);
    display: flex; align-items: center; justify-content: center; font-size: 32px;
}

.home-title { font-size: 26px; font-weight: 800; }
.home-subtitle { font-size: 13px; color: var(--text-secondary); }

.home-version {
    text-align: center; color: #BDBDBD; font-size: 11px; padding: 20px;
}

.page-content { padding-bottom: 30px; }
/* ========== NAVEGAÇÃO GPS ========== */
.delivery-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.nav-btn {
    padding: 6px 12px;
    background: #E3F2FD;
    color: #1565C0;
    border: 1px solid #BBDEFB;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

.nav-btn:active {
    transform: scale(0.95);
    background: #BBDEFB;
}

.delivery-item.completed .nav-btn {
    background: #C8E6C9;
    color: #2E7D32;
    border-color: #A5D6A7;
}

.delivery-item .delivery-btn {
    margin-left: auto;
}
