/* ============================================================
   Rapidlink Fleet — staff PWA
   Deep green + warm paper + one amber accent. One typeface (Manrope).
   Built for one-handed use on mid-range Android phones.
   ============================================================ */

/* ============================================================
   BRAND COLOURS — Rapidlink blue / orange / white.
   Edit --blue and --orange to the exact logo hex if you have them;
   the tint/dark shades derive from those.
   ============================================================ */
:root {
    --blue: #0B4DA2;         /* Rapidlink blue — primary */
    --blue-800: #083A7D;     /* darker shade (pressed, deep bg) */
    --blue-600: #1565C4;     /* lighter shade (labels, links) */
    --blue-tint: #E7F0FB;    /* very light blue background wash */
    --paper: #F4F6FA;        /* off-white with a cool tint */
    --surface: #FFFFFF;
    --ink: #16202E;
    --muted: #5C6B7F;
    --line: #D5DEEA;
    --orange: #F58220;       /* Rapidlink orange — action colour */
    --orange-dark: #D96D0F;
    --danger: #B23A2E;
    --danger-tint: #F7E4E1;
    --wait: #8A6100;
    --wait-tint: #FBEFCE;
    --ok: #1E6B45;
    --ok-tint: #DDEFE4;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 6px 24px rgba(11, 77, 162, 0.12);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
    -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 32rem; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }

/* ---------- Top bar ---------- */
.topbar {
    background: var(--blue);
    color: #fff;
    padding-top: env(safe-area-inset-top, 0px);
}

.topbar__inner { display: flex; align-items: center; height: 56px; }

.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand__mark {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    color: #fff;
}
.brand__name { font-weight: 800; letter-spacing: -0.01em; font-size: 1.05rem; }

/* ---------- Tabs ---------- */
.tabbar {
    display: flex;
    gap: 0.4rem;
    background: var(--blue);
    padding-bottom: 0.75rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.tabbar__btn {
    flex: 1;
    border: 0;
    background: rgba(255, 255, 255, 0.10);
    color: #DCE7E2;
    font: inherit;
    font-weight: 700;
    padding: 0.65rem 0;
    border-radius: 999px;
    cursor: pointer;
}
.tabbar__btn.is-active { background: #fff; color: var(--blue); }

/* ---------- Panes ---------- */
main { padding-top: 1.25rem; }
.pane { display: none; }
.pane.is-active { display: block; animation: rise 0.25s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pane.is-active { animation: none; } }

.intro { margin-bottom: 1.25rem; }
.intro__title { margin: 0; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.intro__sub { margin: 0.25rem 0 0; color: var(--muted); }

/* ---------- Forms ---------- */
.form { display: block; }

.group { border: 0; margin: 0 0 1.25rem; padding: 0; }
.group legend {
    padding: 0;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--blue-600);
    text-transform: none;
    margin-bottom: 0.6rem;
}

.field { display: block; margin-bottom: 0.9rem; }
.field__label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.field__label em { color: var(--muted); font-style: normal; font-weight: 400; }
.field__hint { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 0.3rem; }

.field__err { display: none; color: var(--danger); font-size: 0.8rem; font-weight: 600; margin-top: 0.3rem; }
.field__err.show { display: block; }

.row { display: grid; grid-template-columns: 1fr; gap: 0 0.75rem; }
@media (min-width: 26rem) { .row { grid-template-columns: 1fr 1fr; } }

input, textarea, select {
    width: 100%;
    font: inherit;
    font-size: 16px; /* keeps iOS from zooming on focus */
    color: var(--ink);
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.72rem 0.85rem;
    min-height: 3rem;
}
textarea { resize: vertical; min-height: 4.5rem; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235F6F68' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.85rem center; padding-right: 2.4rem; }

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(18, 86, 74, 0.15);
}
.field--invalid input, .field--invalid textarea, .field--invalid select { border-color: var(--danger); }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font: inherit;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    background: var(--orange);
    border: 0;
    border-radius: var(--radius-sm);
    padding: 0.85rem 1.25rem;
    min-height: 3rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--orange-dark); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn--block { width: 100%; }
.btn--ghost { background: transparent; color: var(--blue-600); border: 1.5px solid var(--line); }
.btn--ghost:hover { background: var(--blue-tint); }

button:focus-visible, .btn:focus-visible, .tabbar__btn:focus-visible {
    outline: 3px solid var(--orange);
    outline-offset: 2px;
}

/* ---------- Banners ---------- */
.banner { border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin-bottom: 1rem; font-weight: 600; font-size: 0.9rem; }
.banner--error { background: var(--danger-tint); color: var(--danger); }

/* ---------- Number plate (the signature element) ---------- */
.plate {
    display: inline-flex;
    align-items: stretch;
    background: #fff;
    border: 3px solid var(--ink);
    border-radius: 10px;
    overflow: hidden;
    font-weight: 800;
    letter-spacing: 0.08em;
    box-shadow: var(--shadow);
}
.plate__tag {
    display: flex; align-items: center;
    background: var(--blue);
    color: #fff;
    padding: 0 0.55rem;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
}
.plate__num { padding: 0.6rem 1rem; font-size: 2rem; font-variant-numeric: tabular-nums; }
.plate--sm .plate__num { font-size: 1.2rem; padding: 0.35rem 0.7rem; }

/* ---------- Sent screen ---------- */
.sent { text-align: center; padding: 1.5rem 0; }
.sent__check {
    width: 68px; height: 68px; margin: 0 auto 1rem;
    display: grid; place-items: center;
    background: var(--ok-tint); color: var(--ok);
    border-radius: 50%;
}
.sent h2 { margin: 0 0 0.35rem; font-size: 1.4rem; }
.sent__lead { margin: 0 0 1.25rem; color: var(--muted); }
.sent .plate { margin: 0 auto 1rem; }
.sent__meta { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.5rem; }
.sent__actions { display: grid; gap: 0.6rem; }
@media (min-width: 26rem) { .sent__actions { grid-template-columns: 1fr 1fr; } .sent__actions .btn--block { grid-column: 1 / -1; } }

/* ---------- Track result ---------- */
.result { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-top: 1.25rem; box-shadow: var(--shadow); }

.status-pill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.85rem; border-radius: 999px;
    font-weight: 700; font-size: 0.9rem;
}
.status-pill::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; }
.status-pill--pending { background: var(--wait-tint); color: var(--wait); }
.status-pill--approved, .status-pill--completed { background: var(--ok-tint); color: var(--ok); }
.status-pill--rejected { background: var(--danger-tint); color: var(--danger); }
.status-pill--cancelled { background: var(--blue-tint); color: var(--muted); }

.result__ref { margin: 0.75rem 0 1rem; font-weight: 800; font-size: 1.1rem; }

.dl { display: grid; gap: 0; margin: 0; }
.dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--paper); }
.dl dt { color: var(--muted); font-size: 0.88rem; }
.dl dd { margin: 0; font-weight: 600; text-align: right; }

.assigned { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.assigned__photo { width: 100%; max-height: 180px; object-fit: cover; border-radius: var(--radius-sm); margin-bottom: 0.75rem; background: var(--blue-tint); }
.assigned__driver { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 0.75rem; }

.note {
    margin-top: 1rem;
    background: var(--paper);
    border-left: 3px solid var(--blue-600);
    border-radius: 6px;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
}
.note strong { display: block; color: var(--muted); font-size: 0.8rem; margin-bottom: 0.2rem; }

.result__actions { margin-top: 1.25rem; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%) translateY(1rem);
    background: var(--blue-800);
    color: #fff;
    padding: 0.75rem 1.15rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 20;
    max-width: calc(100vw - 2rem);
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Loading spinner in buttons ---------- */
.spinner {
    width: 1.05rem; height: 1.05rem;
    border: 2.5px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

/* ---------- Install prompt ---------- */
.install {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--orange);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.85rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.install__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install__text strong { font-size: 0.95rem; }
.install__text span { font-size: 0.82rem; color: var(--muted); }
.install__actions { display: flex; align-items: center; gap: 0.35rem; flex-shrink: 0; }
.btn--sm { padding: 0.5rem 0.9rem; min-height: 2.4rem; font-size: 0.9rem; }
.install__x {
    border: 0; background: transparent; color: var(--muted);
    font-size: 1.5rem; line-height: 1; width: 2rem; height: 2rem;
    cursor: pointer; border-radius: 6px;
}
.install__x:hover { background: var(--paper); }

/* ---------- iOS instructions sheet ---------- */
.sheet {
    position: fixed; inset: 0; z-index: 30;
    background: rgba(8, 58, 125, 0.45);
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; transition: opacity 0.2s ease;
}
.sheet[hidden] { display: none; }          /* closed: fully hidden, non-interactive */
.sheet.is-open { opacity: 1; }
.sheet__panel {
    position: relative;
    background: var(--surface);
    width: 100%; max-width: 32rem;
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 1.5rem 1.25rem calc(1.75rem + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    animation: sheetUp 0.28s ease-out;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .sheet__panel { animation: none; } }
.sheet__panel h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.sheet__panel > p { margin: 0 0 1.25rem; color: var(--muted); font-size: 0.92rem; }
.sheet__x {
    position: absolute; top: 0.85rem; right: 0.85rem;
    border: 0; background: transparent; color: var(--muted);
    font-size: 1.75rem; line-height: 1; width: 2.2rem; height: 2.2rem;
    cursor: pointer; border-radius: 8px;
}
.sheet__x:hover { background: var(--paper); }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.steps li { display: flex; align-items: center; gap: 0.85rem; font-size: 0.95rem; }
.steps__icon {
    flex-shrink: 0;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    background: var(--blue-tint); color: var(--blue-600);
    border-radius: 10px;
}
.steps strong { font-weight: 700; }
