:root {
    --rota-blue: #132b5b;
    --rota-cyan: #2ea7ad;
    --rota-lime: #c8f66a;
    --rota-green: #7fd37c;
    --rota-yellow: #f4d000;
    --rota-red: #ff2d2d;
    --bg: #f6f8fb;
    --panel: #ffffff;
    --panel-strong: #fbfdff;
    --line: #e5e7eb;
    --text: #0f172a;
    --muted: #64748b;
    --brand: var(--rota-cyan);
    --brand-strong: var(--rota-blue);
    --accent: var(--rota-green);
    --danger: var(--rota-red);
    --success: var(--rota-green);
    --shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body,
body.app-body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
    background:
        radial-gradient(900px 420px at 80% 0%, rgba(46, 167, 173, 0.10), transparent 60%),
        radial-gradient(900px 420px at 10% 0%, rgba(200, 246, 106, 0.12), transparent 60%),
        var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    align-items: center;
    min-height: 64px;
    padding: 0 20px;
    background: linear-gradient(90deg, #7fd37c 0%, #2ea7ad 45%, #132b5b 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.brand,
.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 34px;
    width: auto;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.22));
}

.brand-copy {
    line-height: 1.1;
}

.brand-copy strong {
    display: block;
    font-size: 1rem;
    font-weight: 900;
}

.brand-copy span {
    display: block;
    font-size: 0.78rem;
}

.topbar .brand-copy strong {
    color: #ffffff;
}

.topbar .brand-copy span {
    color: rgba(255, 255, 255, 0.78);
}

.login-brand .brand-copy strong {
    color: var(--rota-blue);
}

.login-brand .brand-copy span {
    color: var(--muted);
}

.topnav {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.topnav a {
    padding: 7px 14px;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.92);
    font-weight: 800;
    font-size: 0.82rem;
    border: 1px solid transparent;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.topnav a.active,
.topnav a:hover {
    background: rgba(0, 0, 0, 0.16);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.30);
}

.topnav a:hover {
    transform: translateY(-1px);
}

.userbox {
    display: flex;
    gap: 14px;
    align-items: center;
}

.user-meta {
    text-align: right;
}

.user-meta strong {
    display: block;
    font-size: 0.95rem;
    color: #ffffff;
}

.user-meta span {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.82rem;
}

.topbar-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(0, 0, 0, 0.14);
    color: #ffffff;
    font-weight: 900;
    font-size: 0.82rem;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.topbar-button:hover {
    transform: translateY(-1px);
    background: rgba(0, 0, 0, 0.22);
    border-color: rgba(255, 255, 255, 0.30);
}

.topbar-button-logout {
    border-color: rgba(255, 45, 45, 0.45);
    background: rgba(255, 45, 45, 0.14);
}

.topbar-button-logout:hover {
    background: rgba(255, 45, 45, 0.20);
}

.page {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.hero-panel,
.panel,
.login-card {
    background: var(--panel);
    border: 1px solid rgba(229, 231, 235, 0.95);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.hero-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 28px;
}

.hero-panel.compact {
    padding: 24px 28px;
}

.hero-panel h1 {
    margin: 8px 0 10px;
    font-size: clamp(1.75rem, 2vw, 2.6rem);
}

.hero-copy {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    line-height: 1.6;
}

.hero-actions,
.process-box,
.filters-row,
.stops-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.eyebrow {
    margin: 0;
    color: var(--rota-cyan);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.primary-button,
.ghost-button,
input,
select,
textarea {
    font: inherit;
}

.primary-button,
.ghost-button {
    border: none;
    border-radius: 16px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--rota-cyan) 0%, var(--rota-blue) 100%);
    color: #fff;
    box-shadow: 0 14px 26px rgba(19, 43, 91, 0.18);
}

.ghost-button {
    background: rgba(46, 167, 173, 0.08);
    color: var(--rota-blue);
    border: 1px solid rgba(46, 167, 173, 0.16);
}

.primary-button:hover,
.ghost-button:hover {
    transform: translateY(-1px);
}

.full-width {
    width: 100%;
}

.panel {
    padding: 22px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2,
.panel h3 {
    margin: 6px 0 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stats-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    margin-bottom: 18px;
}

.stat-card {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, var(--panel-strong) 0%, #ffffff 100%);
    border: 1px solid rgba(229, 216, 191, 0.8);
}

.stat-card strong {
    display: block;
    font-size: 1.7rem;
    margin-top: 10px;
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
}

.content-grid {
    display: grid;
    grid-template-columns: 1.1fr 1.4fr;
    gap: 20px;
}

.dashboard-layout {
    align-items: start;
}

.content-grid.two-columns {
    grid-template-columns: 1.1fr 1fr;
}

.history-layout {
    grid-template-columns: 0.9fr 1.4fr;
    align-items: start;
}

.stack-list,
.trip-grid,
.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.trip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.line-card,
.trip-card,
.timeline-item {
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(229, 216, 191, 0.8);
    background: #fffdf9;
}

.trip-card[data-trip-id] {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.trip-card[data-trip-id]:hover {
    transform: translateY(-1px);
    border-color: rgba(23, 107, 111, 0.35);
    box-shadow: 0 12px 24px rgba(29, 41, 52, 0.08);
}

.line-card .line-top,
.trip-card .trip-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
}

.tag-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 7px 10px;
    background: rgba(23, 107, 111, 0.08);
    color: var(--brand-strong);
    font-size: 0.82rem;
    font-weight: 800;
}

.subtle {
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.map-frame {
    width: 100%;
    min-height: 420px;
    border-radius: 24px;
    border: 1px solid rgba(229, 216, 191, 0.8);
    overflow: hidden;
}

.line-form,
.form-grid,
.filters-row,
.input-with-icon {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.form-grid .full-span {
    grid-column: 1 / -1;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

input,
select,
textarea {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(229, 216, 191, 1);
    background: #fffefb;
    padding: 12px 14px;
    color: var(--text);
}

select[multiple] {
    min-height: 180px;
    padding: 8px;
}

textarea {
    resize: vertical;
}

.helper-text {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.stops-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.stop-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr 0.8fr auto auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border-radius: 18px;
    background: var(--panel-strong);
    border: 1px dashed rgba(196, 143, 58, 0.5);
}

.remove-stop,
.danger-button {
    background: rgba(174, 79, 79, 0.08);
    color: var(--danger);
    border: none;
    border-radius: 14px;
    padding: 11px 12px;
    cursor: pointer;
    font-weight: 800;
}

.vehicle-live-row {
    padding: 10px 0;
}

.vehicle-live-row + .vehicle-live-row {
    border-top: 1px dashed rgba(229, 216, 191, 0.9);
}

.dashboard-vehicles-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dashboard-vehicles-list {
    max-height: min(72vh, calc(100vh - 280px));
    overflow-y: auto;
    padding-right: 4px;
}

.dashboard-map-panel {
    position: sticky;
    top: 96px;
}

.vehicle-status-card {
    padding: 16px;
    border-radius: 20px;
    border: 1px solid rgba(229, 216, 191, 0.8);
    background: linear-gradient(180deg, #fffdf9 0%, #f9fcff 100%);
}

.vehicle-status-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 12px;
}

.vehicle-status-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 10px 0 8px;
}

.vehicle-status-copy strong {
    color: var(--brand-strong);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.8rem;
    font-weight: 900;
    line-height: 1;
    border: 1px solid transparent;
}

.status-pill.is-moving,
.status-pill.is-reference-in-reference {
    background: rgba(127, 211, 124, 0.18);
    color: #235f49;
    border-color: rgba(43, 125, 93, 0.22);
}

.status-pill.is-stopped,
.status-pill.is-reference-out-reference {
    background: rgba(255, 45, 45, 0.12);
    color: #9a2323;
    border-color: rgba(154, 35, 35, 0.16);
}

.status-pill.is-reference-near-reference {
    background: rgba(196, 143, 58, 0.14);
    color: #8b641f;
    border-color: rgba(139, 100, 31, 0.18);
}

.status-pill.is-offline,
.status-pill.is-reference-offline {
    background: rgba(100, 116, 139, 0.12);
    color: #56657b;
    border-color: rgba(100, 116, 139, 0.16);
}

.timeline-item {
    position: relative;
    padding-left: 22px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 18px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand);
}

.timeline-item.unmatched::before {
    background: var(--danger);
}

.detail-panel {
    display: flex;
    flex-direction: column;
}

.history-results-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.history-results-list {
    max-height: min(72vh, calc(100vh - 280px));
    overflow-y: auto;
    padding-right: 4px;
}

.history-metrics {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
    margin-bottom: 12px;
}

.history-metrics .stat-card {
    padding: 14px 16px;
}

.history-metrics .stat-card strong {
    font-size: 1.1rem;
    margin-top: 6px;
}

.detail-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.detail-summary-item {
    padding: 12px 14px;
    border-radius: 18px;
    border: 1px solid rgba(229, 216, 191, 0.8);
    background: rgba(255, 253, 249, 0.95);
}

.detail-summary-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.86rem;
}

.detail-panel {
    position: sticky;
    top: 96px;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(460px, 100%);
    padding: 28px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 22px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
}

.input-with-icon input {
    padding-left: 42px;
}

.alert-danger {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(174, 79, 79, 0.08);
    color: var(--danger);
    font-weight: 700;
}

.empty-state {
    padding: 18px;
    border-radius: 18px;
    background: rgba(23, 107, 111, 0.05);
    color: var(--muted);
}

.process-feedback {
    margin-bottom: 18px;
    padding: 18px;
    border-radius: 18px;
}

.process-feedback strong {
    display: block;
    margin-bottom: 6px;
}

.process-feedback .subtle {
    color: inherit;
}

.process-feedback.is-success {
    background: rgba(43, 125, 93, 0.1);
    color: var(--success);
}

.process-feedback.is-warning {
    background: rgba(196, 143, 58, 0.14);
    color: #8b641f;
}

.process-feedback.is-danger {
    background: rgba(174, 79, 79, 0.1);
    color: var(--danger);
}

.process-feedback-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 10px;
}

.map-marker-shell {
    background: transparent;
    border: none;
}

.map-marker-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.map-marker-label {
    min-width: 52px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--rota-blue);
    text-align: center;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    box-shadow: 0 8px 18px rgba(33, 49, 60, 0.16);
}

.map-marker-icon {
    display: grid;
    place-items: center;
    color: #fff;
    box-shadow: 0 10px 20px rgba(33, 49, 60, 0.2);
}

.map-marker-icon i {
    position: relative;
    z-index: 1;
}

.map-marker-icon.is-vehicle {
    width: 40px;
    height: 40px;
    border-radius: 16px;
    border: 3px solid rgba(255, 255, 255, 0.96);
}

.map-marker-icon.is-start,
.map-marker-icon.is-end {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.96);
}

.map-marker-icon.is-vehicle.is-moving {
    background: linear-gradient(135deg, var(--success) 0%, #235f49 100%);
}

.map-marker-icon.is-vehicle.is-stopped {
    background: linear-gradient(135deg, var(--danger) 0%, #7e2d2d 100%);
}

.map-marker-icon.is-vehicle.is-offline,
.map-marker-icon.is-vehicle.is-default {
    background: linear-gradient(135deg, #8ea0b8 0%, #56657b 100%);
}

.map-marker-icon.is-school,
.map-marker-icon.is-stop,
.map-marker-icon.is-pickup {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
}

.map-marker-icon.is-school i,
.map-marker-icon.is-stop i,
.map-marker-icon.is-pickup i {
    transform: rotate(45deg);
}

.map-marker-icon.is-start.is-default,
.map-marker-icon.is-start.is-matched {
    background: linear-gradient(135deg, var(--success) 0%, #235f49 100%);
}

.map-marker-icon.is-end.is-default,
.map-marker-icon.is-end.is-matched {
    background: linear-gradient(135deg, var(--danger) 0%, #7e2d2d 100%);
}

.map-marker-icon.is-school.is-default,
.map-marker-icon.is-school.is-matched,
.map-marker-icon.is-school.is-unmatched {
    background: linear-gradient(135deg, var(--accent) 0%, #a86c1f 100%);
}

.map-marker-icon.is-pickup.is-default,
.map-marker-icon.is-pickup.is-matched {
    background: linear-gradient(135deg, #0f7a83 0%, #0a565d 100%);
}

.map-marker-icon.is-pickup.is-suggested {
    background: linear-gradient(135deg, var(--success) 0%, #235f49 100%);
}

.map-marker-icon.is-pickup.is-unmatched {
    background: linear-gradient(135deg, var(--danger) 0%, #7e2d2d 100%);
}

.map-marker-icon.is-stop.is-matched,
.map-marker-icon.is-stop.is-default {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
}

.map-marker-icon.is-stop.is-unmatched {
    background: linear-gradient(135deg, var(--danger) 0%, #7e2d2d 100%);
}

@media (max-width: 1100px) {
    .content-grid,
    .content-grid.two-columns,
    .history-layout {
        grid-template-columns: 1fr;
    }

    .dashboard-map-panel,
    .detail-panel {
        position: static;
    }
}

@media (max-width: 860px) {
    .topbar {
        grid-template-columns: 1fr;
    }

    .userbox,
    .user-meta {
        text-align: left;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .stop-row {
        grid-template-columns: 1fr;
    }

    .page {
        padding: 16px;
    }

    .detail-summary,
    .history-metrics {
        grid-template-columns: 1fr;
    }
}
