:root {
    --bg: #0f172a;
    --topbar-bg: #111827;
    --surface: #ffffff;
    --content-bg: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.12);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--content-bg);
    font-size: 17px;
    -webkit-text-size-adjust: 100%;
}

h1 {
    font-size: 1.6rem;
    margin: 0 0 0.5rem;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.muted {
    color: var(--muted);
}

/* ---------- Shell ---------- */

.app {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--topbar-bg);
    color: #e5e7eb;
    padding: 0.75rem 1rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: inherit;
}

.brand:hover {
    text-decoration: none;
}

.brand .logo {
    font-size: 1.5rem;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand .title {
    font-weight: 700;
    color: #fff;
}

.brand .subtitle {
    font-size: 0.78rem;
    color: #94a3b8;
}

.content {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 1.25rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

/* ---------- Sign-in (Home) ---------- */

.lead {
    font-size: 1.05rem;
    margin: 0 0 1.25rem;
}

.signin {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.handle-input {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1.1rem;
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--surface);
    color: var(--text);
}

.handle-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary,
.btn-secondary {
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.6rem;
    padding: 0.85rem 1.1rem;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    display: inline-block;
}

.btn-secondary:hover {
    border-color: var(--accent);
    text-decoration: none;
}

.hint {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

/* ---------- Route header ---------- */

.route-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.route-head .muted {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 0;
}

.route-head .btn-secondary {
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.5rem 0.7rem;
    flex-shrink: 0;
}

/* ---------- Stops timeline ---------- */

.stops {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.stop {
    display: flex;
    gap: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    padding: 1rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.stop-next {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.stop-rail {
    flex-shrink: 0;
}

.stop-seq {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    background: var(--content-bg);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.95rem;
}

.stop-pickup .stop-seq {
    background: #dbeafe;
    color: #1d4ed8;
}

.stop-dropoff .stop-seq {
    background: #fef3c7;
    color: #b45309;
}

.stop-body {
    flex: 1;
    min-width: 0;
}

.stop-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.job-id {
    margin-left: auto;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.stop-address {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0.1rem 0 0.5rem;
    line-height: 1.3;
}

.stop-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
}

.meta {
    font-size: 0.92rem;
}

.meta-label {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.03em;
    font-weight: 700;
    margin-right: 0.2rem;
}

.stop-notes {
    margin: 0.6rem 0 0;
    padding: 0.5rem 0.7rem;
    background: var(--content-bg);
    border-radius: 0.5rem;
    font-size: 0.92rem;
}

.footnote {
    margin-top: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ---------- Empty / all caught up ---------- */

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
}

.empty-icon {
    font-size: 2.5rem;
}

.empty-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0.5rem 0 0.25rem;
}

/* ---------- Badges (shared with console palette) ---------- */

.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-grey { background: #e2e8f0; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-next { background: var(--accent); color: #fff; }

.alert {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
}

/* ---------- Confirm actions ---------- */

.stop-actions {
    margin-top: 0.85rem;
}

.btn-confirm {
    width: 100%;
}

/* ---------- Result banner ---------- */

.banner {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 0.6rem;
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.banner-ok {
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    color: #15803d;
}

.banner-err {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.banner-close {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 1rem;
    cursor: pointer;
    opacity: 0.7;
    padding: 0.2rem 0.3rem;
    line-height: 1;
}

.banner-close:hover {
    opacity: 1;
}

.text-danger {
    color: #b91c1c;
}

/* ---------- Blazor error UI ---------- */

#blazor-error-ui {
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.1);
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.75rem;
}
