:root {
    --bg: #eef6ff;
    --panel: #ffffff;
    --ink: #1f2440;
    --muted: #5b6280;
    --pink: #c21051;
    --violet: #7f57ff;
    --orange: #ff7a1a;
    --lime: #baf06b;
    --green: #0fc25b;
    --line: #dae5f4;
    --shadow: 0 16px 40px rgba(31, 36, 64, 0.12);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --safe-top: max(10px, env(safe-area-inset-top));
    --safe-bottom: max(10px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: 'Trebuchet MS', 'Segoe UI', Arial, sans-serif; color: var(--ink); }
body { background: linear-gradient(180deg, #fff0f7 0%, #f4f7ff 30%, #edf8ff 100%); }

.child-body { overflow: hidden; }
.journey-screen {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-rows: minmax(70px, 0.9fr) minmax(168px, 2.55fr) minmax(48px, 0.58fr) minmax(76px, 0.95fr) minmax(180px, 2.7fr) minmax(36px, 0.42fr);
    gap: 8px;
    padding: calc(var(--safe-top) + 6px) 10px var(--safe-bottom);
}

.screen-header,
.overview-panel,
.progress-panel,
.stats-row,
.detail-panel,
.status-strip,
.card,
.admin-header {
    width: min(980px, 100%);
    margin-inline: auto;
}

.screen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.eyebrow {
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pink);
    font-weight: 800;
    font-size: clamp(0.76rem, 1.4vw, 0.96rem);
}
.screen-header h1 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    line-height: 1;
}
.header-pill {
    background: rgba(255,255,255,0.86);
    border: 2px solid #ffd2e2;
    padding: 10px 14px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    font-weight: 700;
    color: var(--pink);
    white-space: nowrap;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-panel,
.detail-panel {
    position: relative;
    background: var(--panel);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.8);
    min-height: 0;
}
.panel-heading {
    position: absolute;
    z-index: 20;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    pointer-events: none;
}
.panel-heading span:first-child,
.panel-heading span:last-child {
    background: rgba(255,255,255,0.9);
    border-radius: 999px;
    padding: 7px 12px;
    font-weight: 800;
    font-size: clamp(0.72rem, 1.4vw, 0.92rem);
    color: var(--ink);
}
.map-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.map-overlay {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 30;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    pointer-events: none;
}
.overlay-chip,
.detail-badge {
    background: rgba(255,255,255,0.92);
    border-radius: 999px;
    padding: 9px 13px;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(31,36,64,0.12);
    border: 2px solid rgba(255,255,255,0.85);
}
.overlay-chip.success { color: #0b7840; }
.map-action {
    pointer-events: auto;
    margin-left: auto;
    border: 0;
    background: linear-gradient(90deg, var(--pink), #ef4a8b);
    color: #fff;
    border-radius: 999px;
    padding: 10px 14px;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.progress-panel {
    background: linear-gradient(180deg, #ffe2ef, #ffd4e7);
    border-radius: 999px;
    padding: 8px 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
}
.progress-track {
    position: relative;
    width: 100%;
    height: 26px;
    background: rgba(255,255,255,0.82);
    border: 4px solid #1f2440;
    border-radius: 999px;
    overflow: visible;
}
.progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: repeating-linear-gradient(135deg, #ffce2f 0 16px, #ff9f1a 16px 28px);
    border-radius: 999px;
}
.progress-marker {
    position: absolute;
    top: 31px;
    transform: translateX(-50%);
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--ink);
}
.progress-marker.start { left: 0%; transform: translateX(0); }
.progress-marker.pause { left: 55%; }
.progress-marker.end { left: 100%; transform: translateX(-100%); }
.progress-car {
    position: absolute;
    top: -23px;
    left: 0%;
    transform: translateX(-10%);
    font-size: 2rem;
    transition: left 0.3s ease;
}

.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-height: 0;
}
.stat-card {
    background: var(--panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
}
.stat-card.goal { background: linear-gradient(180deg, #ff8c22, #ff7115); color: #fff; }
.stat-card.pause { background: linear-gradient(180deg, #8e60ff, #7a49f0); color: #fff; }
.stat-kicker { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.82rem; opacity: 0.92; }
.stat-card strong { font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1; margin-top: 4px; }
.stat-card small { font-size: clamp(0.8rem, 1.7vw, 1rem); margin-top: 4px; opacity: 0.96; }

.status-strip {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.88);
    border-radius: 999px;
    padding: 6px 14px;
    box-shadow: var(--shadow);
    color: var(--muted);
    font-size: 0.92rem;
    text-align: center;
}

.leaflet-container { width: 100%; height: 100%; background: #d8f0ff; }
.leaflet-control-attribution { display: none; }
.leaflet-control-zoom a { border-radius: 12px !important; }

.vehicle-marker,
.destination-marker,
.break-marker,
.next-marker {
    display: grid;
    place-items: center;
}
.vehicle-marker > div,
.destination-marker > div,
.break-marker > div,
.next-marker > div {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 10px 22px rgba(31,36,64,0.18);
    border: 3px solid #fff;
    font-size: 28px;
}
.destination-marker > div { background: rgba(255, 242, 246, 0.97); }
.break-marker > div { background: rgba(244, 238, 255, 0.97); }
.next-marker > div { width: auto; min-width: 58px; padding: 8px 12px; border-radius: 14px; font-size: 18px; font-weight: 800; }

.admin-page { padding: 16px; overflow-x: hidden; }
.admin-shell { width: min(1120px, 100%); margin: 0 auto; display: grid; gap: 16px; }
.card, .admin-header {
    border-radius: var(--radius-xl);
    padding: 16px;
    background: rgba(255,255,255,0.96);
    border: 2px solid #eef2fb;
    box-shadow: var(--shadow);
}
.admin-header h1, .card h2 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.admin-form { display: grid; gap: 10px; }
.admin-form input,
.admin-form select,
.admin-form button,
.admin-form textarea,
.search-results button,
.button-link {
    width: 100%;
    border-radius: 14px;
    font-size: 1rem;
}
.admin-form input,
.admin-form select,
.admin-form textarea {
    border: 2px solid #dbe6f5;
    background: #f7fbff;
    padding: 12px 14px;
}
.admin-form button,
.button-link,
.search-results button {
    border: 0;
    min-height: 48px;
    padding: 12px 14px;
    color: #fff;
    background: linear-gradient(90deg, var(--pink), #ef4a8b);
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.admin-form .secondary,
.search-results button.secondary {
    background: linear-gradient(90deg, #8fa0bd, #7e90b0);
}
.inline { display: inline-flex; align-items: center; gap: 8px; }
.row.two-col, .admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.message { margin-top: 8px; padding: 12px; border-radius: 14px; background: #f5f8ff; border: 2px solid #dce6ff; }
.message.error { background: #fff1f3; border-color: #ffc8d8; }
.hidden { display: none; }
.break-list { display: grid; gap: 14px; }
.break-list form { padding: 14px; border-radius: 18px; border: 2px dashed #dce6ff; }
.vehicle-icon-preview { width: 88px; height: 88px; object-fit: contain; background: #f7fbff; border-radius: 16px; border: 2px solid #dce6ff; padding: 8px; }
.backend-map-wrap { position: relative; min-height: 320px; border-radius: 22px; overflow: hidden; border: 2px solid #e4e9f8; }
.backend-map { position: absolute; inset: 0; }
.search-results { display: grid; gap: 8px; }
.search-results button { justify-content: flex-start; text-align: left; background: #fff; color: var(--ink); border: 2px solid #dbe6f5; }
.search-results button.active { border-color: var(--pink); box-shadow: var(--shadow); }
.coord-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.small-note { font-size: 0.9rem; color: var(--muted); }

@media (max-width: 820px) {
    .journey-screen {
        grid-template-rows: minmax(64px, 0.88fr) minmax(152px, 2.2fr) minmax(44px, 0.54fr) minmax(70px, 0.88fr) minmax(170px, 2.45fr) minmax(34px, 0.4fr);
        padding-inline: 8px;
    }
    .header-pill { max-width: 48%; font-size: 0.9rem; }
    .panel-heading span:last-child { display: none; }
}

@media (max-width: 620px) {
    .screen-header { align-items: flex-start; flex-direction: column; gap: 6px; }
    .header-pill { max-width: 100%; }
    .stats-row, .row.two-col, .admin-grid, .coord-grid { grid-template-columns: 1fr; }
    .journey-screen {
        grid-template-rows: minmax(72px, 1fr) minmax(138px, 2fr) minmax(46px, 0.65fr) minmax(82px, 1fr) minmax(166px, 2.25fr) minmax(34px, 0.45fr);
        gap: 7px;
    }
    .stat-card strong { font-size: 2rem; }
    .overlay-chip, .detail-badge, .map-action { font-size: 0.88rem; }
}
