:root {
    --primary: #1a73e8;
    --primary-dark: #0d47a1;
    --success: #1e8e3e;
    --warning: #f9a825;
    --danger: #d93025;
    --bg: #f5f6f8;
    --card-bg: #ffffff;
    --text: #202124;
    --text-muted: #5f6368;
    --border: #e0e0e0;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* ── Top bar ─────────────────────────────────────────────────────── */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.topbar .driver-name { font-size: 12px; opacity: .85; }
.topbar button {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
}

/* ── Offline / sync banner ──────────────────────────────────────── */
.status-banner {
    padding: 8px 16px;
    font-size: 13px;
    text-align: center;
    font-weight: 500;
}
.status-banner.offline { background: #fce8e6; color: var(--danger); }
.status-banner.pending { background: #fef7e0; color: #a15c00; }
.status-banner.syncing { background: #e8f0fe; color: var(--primary-dark); }
.status-banner.synced { background: #e6f4ea; color: var(--success); }

/* ── Main content ────────────────────────────────────────────────── */
main { flex: 1; padding: 12px; padding-bottom: 32px; max-width: 640px; margin: 0 auto; width: 100%; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 28px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.login-card h2 { text-align: center; margin: 0 0 4px; color: var(--primary); }
.login-card p.subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.field input, .field textarea, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:disabled { opacity: .6; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; }
.link-btn { background: none; border: none; color: var(--primary); font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; }

/* ── Section headers ─────────────────────────────────────────────── */
.section-title {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin: 18px 4px 8px;
    font-weight: 600;
}
.section-title:first-child { margin-top: 4px; }
.empty-note { color: var(--text-muted); font-size: 14px; text-align: center; padding: 24px 12px; }

/* ── Order card ──────────────────────────────────────────────────── */
.order-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.order-card .order-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.order-card .ref { font-weight: 700; font-size: 15px; }
.order-card .store { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}
.badge-comprado { background: #e8eaed; color: #3c4043; }
.badge-procesando { background: #e8f0fe; color: var(--primary-dark); }
.badge-en_entrega { background: #fef7e0; color: #a15c00; }
.badge-entregado { background: #e6f4ea; color: var(--success); }
.badge-pending-sync { background: #fce8e6; color: var(--danger); }

.order-detail { margin-top: 10px; font-size: 13.5px; color: var(--text); line-height: 1.5; }
.order-detail .row { display: flex; gap: 6px; }
.order-detail .row .icon { width: 16px; flex-shrink: 0; opacity: .6; }
.order-items { margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.order-items ul { margin: 4px 0 0; padding-left: 18px; }

.order-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.countdown { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Deliver screen ──────────────────────────────────────────────── */
.deliver-screen .order-summary {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
}
.type-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.type-toggle button {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}
.type-toggle button.active { border-color: var(--primary); background: var(--primary); color: #fff; }

.sig-pad-wrap {
    background: #fff;
    border: 1px dashed var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}
canvas#sigPad { width: 100%; height: 180px; display: block; touch-action: none; }

.photo-capture {
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 8px;
}
.photo-capture img { max-width: 100%; max-height: 160px; border-radius: 6px; }

.back-link { display: inline-block; margin-bottom: 12px; color: var(--primary); font-size: 14px; text-decoration: none; }

/* ── Toast ───────────────────────────────────────────────────────── */
#toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #202124;
    color: #fff;
    padding: 10px 18px;
    border-radius: 24px;
    font-size: 13.5px;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}
#toast.show { opacity: 1; }
