:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #ccfbf1;
    --accent: #f97316;
    --accent-dark: #ea580c;
    --danger: #dc2626;
    --success: #16a34a;
    --amber: #d97706;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --radius: 18px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { text-decoration: none; color: inherit; }

/* ---------- Header ---------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: #fff;
    box-shadow: 0 4px 20px rgba(15, 94, 89, 0.35);
}
.app-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    max-width: 760px;
    margin: 0 auto;
}
.app-header__brand { display: flex; align-items: center; gap: 12px; }
.app-header__logo {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.18);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
}
.app-header__title { font-size: 17px; font-weight: 800; letter-spacing: -0.2px; }
.app-header__subtitle { font-size: 12px; color: #99f6e4; font-weight: 500; }
.app-header__actions { display: flex; align-items: center; gap: 10px; }
.app-header__driver { font-size: 13px; font-weight: 600; color: #ccfbf1; }
.icon-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: rgba(255,255,255,0.16);
    color: #fff;
    font-size: 18px;
    display: flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255,255,255,0.3); }
.logout-form { margin: 0; }

.app-main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 6px;
    background: #e2e8f0;
    border-radius: 16px;
    padding: 5px;
    margin-bottom: 14px;
}
.tab {
    flex: 1;
    padding: 13px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--muted);
    display: flex; align-items: center; justify-content: center; gap: 7px;
    transition: all .18s ease;
}
.tab.is-active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(15,23,42,.1); }
.tab__badge {
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 7px;
}
.tab:not(.is-active) .tab__badge { background: #94a3b8; }

/* ---------- Toolbar / buttons ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
    user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(15,118,110,.35); }
.btn--primary:active { background: var(--primary-dark); }
.btn--block { width: 100%; }
.btn--ghost { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn--map { background: linear-gradient(135deg, var(--accent), #f43f5e); color: #fff; flex: 1; box-shadow: 0 6px 16px rgba(249,115,22,.35); }
.btn--phone { flex: 1; background: #dbeafe; color: #1d4ed8; }
.btn--nav { flex: 1; background: #dcfce7; color: #15803d; }
.btn--enroute { width: 100%; background: #0ea5e9; color: #fff; font-size: 16px; padding: 15px; border-radius: 14px; box-shadow: 0 6px 16px rgba(14,165,233,.3); }
.btn--delivered { width: 100%; background: var(--success); color: #fff; font-size: 16px; padding: 15px; border-radius: 14px; box-shadow: 0 6px 16px rgba(22,163,74,.3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Route summary ---------- */
.route-summary {
    background: linear-gradient(135deg, #ecfeff, #f0fdfa);
    border: 1.5px solid #99f6e4;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}
.route-summary__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.route-summary__title { font-weight: 800; font-size: 14px; color: var(--primary-dark); }
.route-summary__dist { font-weight: 800; font-size: 14px; color: var(--accent-dark); }
.route-summary__chain { display: flex; flex-wrap: wrap; gap: 8px; }
.route-summary__hint { font-size: 13px; color: var(--muted); }
.route-stop {
    display: inline-flex; align-items: center; gap: 6px;
    background: #fff; border-radius: 999px;
    padding: 7px 12px 7px 8px;
    box-shadow: 0 1px 4px rgba(15,23,42,.08);
    font-size: 13px;
    max-width: 100%;
}
.route-stop__icon { font-size: 15px; }
.route-stop__label { font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.route-stop__leg { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.route-stop__leg::before { content: "· "; color: var(--accent); }

/* ---------- Job cards ---------- */
.job-list { display: flex; flex-direction: column; gap: 14px; }
.job-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.job-card--done { background: linear-gradient(135deg, #f0fdf4, #ecfccb); border-color: #bbf7d0; }
.job-card__top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.job-card__order { font-size: 20px; font-weight: 900; letter-spacing: -0.3px; color: var(--primary-dark); }
.job-card__name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.job-card__total { font-size: 26px; font-weight: 900; color: var(--text); tabular-nums: tabular-nums; }
.job-card__badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.badge {
    font-size: 12px; font-weight: 800;
    padding: 6px 11px;
    border-radius: 999px;
}
.badge--paid { background: #dcfce7; color: #15803d; }
.badge--unpaid { background: #fee2e2; color: #b91c1c; }
.badge--enroute { background: #e0f2fe; color: #0369a1; }
.job-card__address { font-size: 14px; color: var(--text); margin-bottom: 6px; line-height: 1.35; }
.job-card__instructions { font-size: 13px; color: var(--amber); background: #fffbeb; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; font-weight: 600; }
.job-card__delivered { font-size: 12px; color: var(--muted); margin-top: 8px; }

.job-card__items { border-top: 1px dashed var(--border); padding-top: 10px; margin-bottom: 12px; }
.job-item { padding: 5px 0; }
.job-item__main { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.job-item__qty { font-weight: 800; color: var(--accent-dark); }
.job-item__name { font-weight: 600; }
.job-item__meta { color: var(--muted); font-size: 13px; }
.job-item__price { margin-left: auto; font-weight: 700; tabular-nums: tabular-nums; }
.job-item__adds { font-size: 12px; color: var(--muted); margin-left: 26px; }
.job-item__subs { font-size: 12px; color: var(--muted); margin-left: 26px; }
.job-item__notes { font-size: 12px; color: var(--amber); margin-left: 26px; font-weight: 600; }

.job-card__actions { display: flex; gap: 10px; margin-bottom: 12px; }
.job-card__primary { margin-top: 4px; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state__icon { font-size: 56px; margin-bottom: 12px; }
.empty-state__title { font-size: 18px; font-weight: 800; }
.empty-state__text { font-size: 14px; color: var(--muted); margin-top: 6px; }

/* ---------- Tab panels ---------- */
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #0f172a;
    color: #fff;
    padding: 13px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: all .25s ease;
    z-index: 100;
    max-width: 90vw;
}
.toast.is-showing { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Alerts ---------- */
.alert { border-radius: 14px; padding: 13px 15px; font-size: 14px; margin-bottom: 14px; font-weight: 600; }
.alert--error { background: #fee2e2; color: #b91c1c; }
.alert--info { background: #e0f2fe; color: #075985; }

/* ---------- Login ---------- */
.login-body {
    background: linear-gradient(150deg, #115e59 0%, #0f766e 45%, #14b8a6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}
.login-screen { width: 100%; max-width: 460px; }
.login-card {
    background: #fff;
    border-radius: 28px;
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
}
.login-hero { text-align: center; margin-bottom: 22px; }
.login-logo {
    width: 74px; height: 74px;
    background: linear-gradient(135deg, var(--accent), #f43f5e);
    border-radius: 22px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    margin: 0 auto 14px;
    box-shadow: 0 10px 24px rgba(249,115,22,.35);
}
.login-title { font-size: 26px; font-weight: 900; letter-spacing: -0.5px; }
.login-subtitle { font-size: 14px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.login-label { display: block; font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 10px; }
.pin-for { color: var(--primary); font-weight: 900; text-transform: none; letter-spacing: 0; }

.driver-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.driver-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    transition: all .15s ease;
}
.driver-chip.is-active { border-color: var(--primary); background: var(--primary-light); }
.driver-chip:active { transform: scale(0.97); }
.driver-chip__avatar {
    width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15px;
}
.driver-chip__name { font-weight: 700; font-size: 14px; text-align: left; line-height: 1.2; }

.pin-zone { display: none; margin-top: 4px; }
.pin-zone.is-visible { display: block; }
.pin-dots {
    display: flex; justify-content: center; gap: 12px;
    min-height: 26px;
    margin-bottom: 18px;
}
.pin-dots span {
    width: 16px; height: 16px;
    border-radius: 50%;
    border: 2px solid #cbd5e1;
    transition: all .15s ease;
}
.pin-dots span.is-filled { background: var(--primary); border-color: var(--primary); transform: scale(1.15); }

.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.pin-key {
    height: 62px;
    border-radius: 16px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    display: flex; align-items: center; justify-content: center;
    transition: all .1s ease;
}
.pin-key:active { background: var(--primary-light); transform: scale(0.94); }
.pin-key--muted { color: var(--muted); }
.pin-key--go { background: var(--primary); color: #fff; border-color: var(--primary); }
.pin-key--go:active { background: var(--primary-dark); }

@media (min-width: 600px) {
    .driver-grid { grid-template-columns: repeat(3, 1fr); }
}
