:root {
    --ink: #070d14;
    --ink-2: #101820;
    --navy: #173044;
    --panel: rgba(16, 26, 36, 0.78);
    --teal: #7ec8c3;
    --gold: #f0b429;
    --gold-dark: #c9842a;
    --copper: #e8a87c;
    --cream: #f6f1e7;
    --paper: #121c27;
    --line: rgba(240, 180, 41, 0.28);
    --muted: #b7aa96;
    --ok: #8fd9b0;
    --ok-bg: rgba(47, 143, 99, 0.22);
    --wait: #f0c36a;
    --wait-bg: rgba(201, 132, 42, 0.22);
    --bad: #ff8b98;
    --bad-bg: rgba(155, 35, 48, 0.28);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
    --radius: 22px;
    --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
    --display: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
    --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--sans);
    color: var(--cream);
    background:
        radial-gradient(900px 480px at 8% -10%, rgba(240, 180, 41, 0.22), transparent 55%),
        radial-gradient(700px 420px at 100% 0%, rgba(126, 200, 195, 0.12), transparent 50%),
        linear-gradient(180deg, #0c1620 0%, var(--ink) 42%, #0a1218 100%);
    line-height: 1.5;
}
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(246, 241, 231, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(246, 241, 231, 0.035) 1px, transparent 1px);
    background-size: 72px 72px;
    mask-image: linear-gradient(180deg, #000 0%, transparent 70%);
    z-index: 0;
}
body > * { position: relative; z-index: 1; }

a { color: var(--teal); }
code {
    font-family: var(--mono);
    font-size: 0.86em;
    color: var(--gold);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 1.1rem;
    background: rgba(7, 13, 20, 0.78);
    color: var(--cream);
    border-bottom: 1px solid rgba(240, 180, 41, 0.18);
    backdrop-filter: blur(16px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: inherit;
    text-decoration: none;
    flex: 0 0 auto;
}
.brand-mark {
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 8px;
    background:
        linear-gradient(160deg, var(--gold) 0 42%, transparent 42% 48%, var(--cream) 48% 100%);
    box-shadow: 0 0 0 1px rgba(240, 180, 41, 0.45), 0 8px 20px rgba(240, 180, 41, 0.18);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1.05; }
.brand-copy strong {
    font-family: var(--display);
    letter-spacing: 0.14em;
    font-weight: 600;
    font-size: 1.05rem;
}
.brand-copy small {
    color: var(--copper);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
}
.top-nav {
    display: flex;
    gap: 0.2rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a {
    color: #d9cbb6;
    text-decoration: none;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    font-size: 0.82rem;
    white-space: nowrap;
    border: 1px solid transparent;
}
.top-nav a.active, .top-nav a:hover {
    background: rgba(240, 180, 41, 0.12);
    color: var(--gold);
    border-color: rgba(240, 180, 41, 0.28);
}
.doc-link {
    color: var(--gold);
    text-decoration: none;
    font-size: 0.78rem;
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    border: 1px solid rgba(240, 180, 41, 0.45);
    border-radius: 999px;
    white-space: nowrap;
}
.doc-link:hover { background: rgba(240, 180, 41, 0.14); }
.top-user { display: flex; align-items: center; gap: 0.7rem; font-size: 0.88rem; flex: 0 0 auto; }
#user-label { color: #d9cbb6; }

#app { max-width: 1120px; margin: 0 auto; padding: 1.6rem 1.25rem 6rem; }
.view { animation: rise 0.35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.35rem;
}
.page-head h1, .auth-hero h1 {
    margin: 0.15rem 0 0;
    font-family: var(--display);
    font-weight: 560;
    font-size: clamp(2rem, 4.4vw, 3.4rem);
    letter-spacing: -0.03em;
    line-height: 0.98;
}
.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 0.68rem;
    color: var(--gold);
    font-weight: 700;
}
.lede { color: var(--muted); max-width: 40rem; }
.section-title {
    font-family: var(--display);
    font-size: 1.25rem;
    font-weight: 560;
    margin: 1.6rem 0 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 0;
    border-radius: 999px;
    padding: 0.68rem 1.2rem;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: linear-gradient(180deg, #f6c453, var(--gold) 40%, #d89a1e);
    color: #1a1204;
    box-shadow: 0 8px 22px rgba(240, 180, 41, 0.28);
}
.btn-primary:hover { background: #f6c453; }
.btn-secondary {
    background: transparent;
    color: var(--cream);
    border: 1px solid rgba(246, 241, 231, 0.28);
}
.btn-ghost { background: transparent; color: inherit; border: 1px solid currentColor; }
.btn-danger { background: #9b2330; color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.btn-lg { padding: 0.9rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.input, select.input {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid rgba(246, 241, 231, 0.16);
    border-radius: 14px;
    background: rgba(7, 13, 20, 0.55);
    color: var(--cream);
    font: inherit;
}
.input:focus { outline: 2px solid var(--gold); border-color: var(--gold-dark); }
option { color: #1a1204; background: #f6f1e7; }
label { display: block; font-weight: 600; font-size: 0.88rem; color: #e7dccb; }
.stack { display: grid; gap: 0.9rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 0; }

.auth-view { padding-top: 0.4rem; }
.auth-panel {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 1.25rem;
    align-items: stretch;
    min-height: 70vh;
}
.auth-hero {
    position: relative;
    overflow: hidden;
    color: var(--cream);
    border-radius: 32px;
    padding: 2.6rem 2.4rem;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        radial-gradient(500px 220px at 80% 10%, rgba(240, 180, 41, 0.28), transparent 60%),
        linear-gradient(165deg, #1a2836 0%, #0b1219 55%, #070d14 100%);
    box-shadow: var(--shadow);
    border: 1px solid rgba(240, 180, 41, 0.22);
}
.auth-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    top: 36px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 1px solid rgba(240, 180, 41, 0.35);
    box-shadow: inset 0 0 0 28px rgba(240, 180, 41, 0.05);
}
.auth-hero .eyebrow { color: var(--gold); }
.auth-hero p { color: #e4d7c4; max-width: 28rem; font-size: 1.05rem; }
.route-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.4rem;
    list-style: none;
    margin: 1.6rem 0 0;
    padding: 0;
    position: relative;
}
.route-line li {
    position: relative;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--copper);
}
.route-line li::before {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 0 4px rgba(240, 180, 41, 0.18);
}
.auth-card {
    background: var(--panel);
    border-radius: 32px;
    padding: 1.6rem;
    box-shadow: var(--shadow);
    border: 1px solid rgba(246, 241, 231, 0.08);
    backdrop-filter: blur(18px);
    align-self: center;
}
.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(7, 13, 20, 0.55);
    border-radius: 999px;
    padding: 0.22rem;
    margin-bottom: 1.15rem;
    border: 1px solid rgba(246, 241, 231, 0.08);
}
.seg-btn {
    border: 0;
    background: transparent;
    border-radius: 999px;
    padding: 0.55rem;
    font: inherit;
    font-weight: 650;
    color: var(--muted);
    cursor: pointer;
}
.seg-btn.active { background: var(--gold); color: #1a1204; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.8rem;
}
.stat {
    background: linear-gradient(180deg, rgba(23, 48, 68, 0.55), rgba(12, 20, 28, 0.8));
    border-radius: 18px;
    padding: 1.05rem 1rem 0.95rem;
    border: 1px solid rgba(240, 180, 41, 0.16);
    box-shadow: var(--shadow);
}
.stat strong {
    display: block;
    font-family: var(--display);
    font-size: 2.15rem;
    letter-spacing: -0.04em;
    color: var(--cream);
}
.stat span {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.stat-ok strong { color: var(--ok); }
.stat-warn strong { color: var(--wait); }

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 0.8rem;
}
.type-card {
    text-align: left;
    background: rgba(16, 26, 36, 0.72);
    border: 1px solid rgba(246, 241, 231, 0.1);
    border-radius: 18px;
    padding: 1.05rem 1rem;
    cursor: pointer;
    font: inherit;
    color: var(--cream);
    box-shadow: var(--shadow);
}
.type-card strong { display: block; font-family: var(--display); font-size: 1.15rem; }
.type-card small { color: var(--muted); }
.type-card .amt { display: block; margin-top: 0.7rem; font-weight: 700; color: var(--gold); }
.type-card.selected {
    border-color: var(--gold);
    background: linear-gradient(180deg, rgba(240, 180, 41, 0.16), rgba(16, 26, 36, 0.9));
}

.zone-label { max-width: 28rem; }
.price-bar {
    position: sticky;
    bottom: 4.5rem;
    margin-top: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background:
        linear-gradient(90deg, rgba(240, 180, 41, 0.16), transparent 28%),
        #101820;
    color: var(--cream);
    padding: 1rem 1.25rem;
    border-radius: 22px;
    border: 1px solid rgba(240, 180, 41, 0.35);
    box-shadow: var(--shadow);
}
.price {
    margin: 0;
    font-family: var(--display);
    font-size: 2.2rem;
    color: var(--gold);
    letter-spacing: -0.03em;
}
.price-bar .hint { color: #d9cbb6; }

.ticket-list { display: grid; gap: 0.9rem; }
.ticket-card {
    display: grid;
    grid-template-columns: 12px 1fr auto;
    background: linear-gradient(180deg, #182838, #101820);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow);
    min-height: 124px;
    border: 1px solid rgba(246, 241, 231, 0.08);
    cursor: pointer;
}
.ticket-stripe {
    background: repeating-linear-gradient(180deg, var(--gold) 0 8px, #1a1204 8px 12px);
}
.ticket-body { padding: 1rem 1.05rem; }
.ticket-body h3 { margin: 0 0 0.25rem; font-family: var(--display); font-size: 1.25rem; font-weight: 560; }
.ticket-meta { color: var(--muted); font-size: 0.85rem; margin: 0.15rem 0; }
.ticket-id { font-family: var(--mono); letter-spacing: 0.06em; color: var(--copper); }
.ticket-stub {
    width: 126px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background:
        radial-gradient(circle at 0 14px, #070d14 8px, transparent 9px) 0 0 / 100% 28px,
        linear-gradient(180deg, #243246, #15202c);
    color: var(--cream);
    padding: 0.6rem;
    text-align: center;
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border-left: 1px dashed rgba(240, 180, 41, 0.35);
}
.chip {
    width: 32px;
    height: 24px;
    border-radius: 5px;
    background: linear-gradient(135deg, #f6d98a, #a8742a 55%, #f0b429);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.status {
    display: inline-block;
    padding: 0.16rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.status-ACTIVATED { background: var(--ok-bg); color: var(--ok); }
.status-UNACTIVATED { background: var(--wait-bg); color: var(--wait); }
.status-USED { background: rgba(126, 200, 195, 0.16); color: var(--teal); }
.status-EXPIRED, .status-CANCELLED { background: var(--bad-bg); color: var(--bad); }

.empty {
    text-align: center;
    padding: 2.6rem 1rem;
    background: rgba(16, 26, 36, 0.65);
    border-radius: var(--radius);
    color: var(--muted);
    border: 1px dashed rgba(240, 180, 41, 0.28);
}
.empty::before {
    content: "";
    display: block;
    width: 72px;
    height: 44px;
    margin: 0 auto 0.85rem;
    border-radius: 8px;
    background: linear-gradient(var(--gold) 0 32%, #173044 32% 100%);
}

.check-form {
    display: flex;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.check-form label { flex: 1; min-width: 12rem; }

.filter-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin: 0 0 1.25rem;
}
.sim-panel {
    background:
        radial-gradient(420px 160px at 100% 0%, rgba(240, 180, 41, 0.16), transparent 60%),
        #0d1722;
    color: var(--cream);
    border-radius: 22px;
    padding: 1.1rem 1.15rem 1.2rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(240, 180, 41, 0.2);
}
.sim-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.sim-head h2 { margin: 0; font-family: var(--display); font-size: 1.35rem; font-weight: 560; color: var(--cream); }
.sim-badge {
    margin: 0;
    background: var(--gold);
    color: #1a1204;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-size: 0.68rem;
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
}
.sim-city { display: block; margin: 0.75rem 0 0.4rem; max-width: 28rem; color: #e4d7c4; }
.sim-panel .hint { color: #d9cbb6; }
.sim-map {
    height: 440px;
    width: 100%;
    border-radius: 16px;
    margin: 0.75rem 0 0.4rem;
    background: #0b1520;
    border: 1px solid rgba(246, 241, 231, 0.08);
    z-index: 1;
}
.fleet-board {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.ops-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin: 0 0 1rem;
}
.ops-form label { flex: 1; min-width: 10rem; }
.depot-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.depot-card, .vehicle-card {
    background: rgba(16, 26, 36, 0.78);
    border: 1px solid rgba(246, 241, 231, 0.1);
    border-radius: 18px;
    padding: 0.95rem 1rem;
    box-shadow: var(--shadow);
}
.depot-card h3, .vehicle-card h3 { margin: 0 0 0.35rem; font-family: var(--display); font-weight: 560; }
.vehicle-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}
.vehicle-card p { margin: 0.15rem 0; font-size: 0.9rem; color: #e4d7c4; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(16, 26, 36, 0.78);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(246, 241, 231, 0.08);
}
.data-table th, .data-table td {
    text-align: left;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid rgba(246, 241, 231, 0.08);
    font-size: 0.88rem;
}
.data-table th {
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* REACH-3014: Management dashboard stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}
.stat-card {
    background: rgba(16, 26, 36, 0.78);
    border: 1px solid rgba(246, 241, 231, 0.08);
    border-radius: 16px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}
.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent, #e8b931);
}
.stat-label {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.status-available { background: var(--ok-bg); color: var(--ok); }
.status-in_service { background: rgba(126, 200, 195, 0.16); color: var(--teal); }
.status-workshop, .status-out_of_service { background: var(--bad-bg); color: var(--bad); }
.status-charging { background: var(--wait-bg); color: var(--wait); }
.result {
    padding: 1rem 1.1rem;
    border-radius: 16px;
    margin: 0.75rem 0 1.25rem;
}
.result-ok { background: var(--ok-bg); color: var(--ok); }
.result-bad { background: var(--bad-bg); color: var(--bad); }

.sheet {
    border: 1px solid rgba(240, 180, 41, 0.28);
    border-radius: 24px;
    width: min(520px, 94vw);
    padding: 0;
    background: #121c27;
    color: var(--cream);
    box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(4, 8, 12, 0.72); }
.sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.1rem 0.4rem;
}
.sheet-head h2 { margin: 0; font-family: var(--display); font-size: 1.35rem; font-weight: 560; }
#detail-body { padding: 0.4rem 1.1rem 1rem; }
.kv { display: grid; grid-template-columns: 8rem 1fr; gap: 0.4rem 0.75rem; font-size: 0.92rem; }
.kv dt { color: var(--muted); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1.1rem 1.1rem; }

.toasts {
    position: fixed;
    top: 4.4rem;
    right: 1rem;
    z-index: 40;
    display: grid;
    gap: 0.5rem;
    width: min(360px, calc(100vw - 2rem));
}
.toast {
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    background: #173044;
    color: var(--cream);
    box-shadow: var(--shadow);
    border: 1px solid rgba(246, 241, 231, 0.1);
}
.toast-error { background: #6e2430; }
.toast-success { background: #1c5c40; }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 13, 20, 0.72);
    display: grid;
    place-items: center;
    z-index: 50;
    color: var(--cream);
}
.loading-overlay[hidden] { display: none; }
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(246, 241, 231, 0.2);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bottom-nav {
    display: none;
    position: fixed;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 0.55rem;
    background: rgba(7, 13, 20, 0.88);
    padding: 0.4rem 0.35rem calc(0.4rem + env(safe-area-inset-bottom));
    grid-template-columns: repeat(5, 1fr);
    z-index: 25;
    border: 1px solid rgba(240, 180, 41, 0.22);
    border-radius: 18px;
    backdrop-filter: blur(16px);
}
.bottom-nav a {
    color: #d9cbb6;
    text-align: center;
    text-decoration: none;
    font-size: 0.72rem;
    padding: 0.45rem 0.15rem;
    border-radius: 12px;
}
.bottom-nav a.active { color: #1a1204; background: var(--gold); }

.site-foot {
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding: 0 1rem 5.5rem;
}

@media (max-width: 800px) {
    .auth-panel { grid-template-columns: 1fr; min-height: 0; }
    .auth-hero { min-height: 280px; padding: 1.6rem; }
    .auth-hero::after { width: 140px; height: 140px; }
    .stats { grid-template-columns: 1fr 1fr; }
    .top-nav { display: none; }
    .doc-link { font-size: 0.72rem; }
    .bottom-nav { display: grid; }
    .price-bar { bottom: 5rem; flex-wrap: wrap; }
    .check-form { flex-direction: column; align-items: stretch; }
    .filter-bar { grid-template-columns: 1fr; }
    .sim-map { height: 280px; }
    .fleet-board { grid-template-columns: 1fr; }
    .ops-form { flex-direction: column; align-items: stretch; }
    .depot-list { grid-template-columns: 1fr; }
    .data-table { display: block; overflow-x: auto; }
    .ticket-card { grid-template-columns: 8px 1fr; }
    .ticket-stub {
        width: auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 0.55rem 0.9rem;
        grid-column: 1 / -1;
    }
}

@media (min-width: 801px) {
    .site-foot { padding-bottom: 2rem; }
    .price-bar { bottom: 1.2rem; }
}
