* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0f1318;
    color: #fff;
}

.app-shell {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    position: relative;
}

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #2a3038;
    background: #161c24;
}

.brand {
    font-size: 14px;
    font-weight: 700;
}

.session-pill {
    font-size: 11px;
    color: #ffd166;
    border: 1px solid #4a4f57;
    border-radius: 999px;
    padding: 4px 8px;
}

.status-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 8px;
    background: #131920;
    border-bottom: 1px solid #252b33;
}

.status-item {
    text-align: center;
    font-size: 11px;
    background: #1b222c;
    border: 1px solid #2e3640;
    border-radius: 8px;
    padding: 6px 4px;
}

.map-mobile {
    width: 100%;
    height: 100%;
}

.mini-drawer {
    position: relative;
    z-index: 50;
    background: #121820;
    border-top: 1px solid #252b33;
    display: flex;
    flex-direction: column;
    /* collapsed: only handle visible */
    max-height: 56px;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.mini-drawer--open {
    max-height: 52vh;
}

.drawer-handle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    height: 56px;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.drawer-handle-bar {
    width: 36px;
    height: 4px;
    background: #3a4250;
    border-radius: 999px;
    flex-shrink: 0;
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.drawer-tab-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.drawer-tab {
    background: transparent;
    border: 1px solid transparent;
    color: #7a8290;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s, color 0.2s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.drawer-tab--active {
    background: #ff6b35;
    color: #fff;
    border-color: #ff6b35;
}

#tabVehiculos {
    color: #7dd3fc;
    background: rgba(14, 116, 144, 0.12);
    border-color: rgba(125, 211, 252, 0.2);
}

#tabVehiculos.drawer-tab--active {
    background: #0284c7;
    border-color: #0284c7;
    color: #fff;
}

#tabTiempos {
    color: #facc15;
    background: rgba(161, 98, 7, 0.12);
    border-color: rgba(250, 204, 21, 0.2);
}

#tabTiempos.drawer-tab--active {
    background: #ca8a04;
    border-color: #ca8a04;
    color: #fff;
}

.drawer-badge {
    background: rgba(255,255,255,0.25);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 999px;
    padding: 1px 5px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
}

.drawer-tab:not(.drawer-tab--active) .drawer-badge {
    background: #ff6b35;
    color: #fff;
}

.drawer-handle-chevron {
    font-size: 12px;
    color: #7a8290;
    transition: transform 0.3s;
}

.mini-drawer--open .drawer-handle-chevron {
    transform: rotate(180deg);
}

.mini-list-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 6px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
}

/* ── Vehicle cards ── */
.mini-card {
    display: flex;
    align-items: stretch;
    background: #1a212b;
    border: 1px solid #252b33;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: background 0.18s;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.mini-card:active {
    background: #222a36;
}

.mini-card-bar {
    width: 5px;
    flex-shrink: 0;
}

.mini-card-body {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
}

.mini-card-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-card-id {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
}

.mini-tc-badge {
    background: rgba(251,192,45,0.2);
    border: 1px solid rgba(251,192,45,0.5);
    color: #fbc02d;
    font-size: 9px;
    font-weight: 800;
    border-radius: 6px;
    padding: 1px 5px;
    line-height: 14px;
}

.mini-card-status {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.status--moving  { background: rgba(0,200,83,0.15); color: #00c853; }
.status--stopped { background: rgba(211,47,47,0.12); color: #ef5350; }
.status--finished{ background: rgba(255,107,53,0.12); color: #ff6b35; }
.status--offline { background: rgba(251,192,45,0.12); color: #fbc02d; }

.mini-card-name {
    font-size: 11px;
    color: #7a8290;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-card-arrow {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: #3a4250;
    font-size: 12px;
}

.mini-card--empty {
    justify-content: center;
    padding: 16px;
    color: #4a5060;
    font-size: 13px;
    cursor: default;
    border: none;
    background: transparent;
}

/* ── TC Layer button in drawer tabs ── */
.mob-fab-tc {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    min-height: 30px;
    background: transparent;
    color: #7a8290;
    border: 1px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    box-shadow: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

.mob-fab-tc {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border-color: rgba(134, 239, 172, 0.22);
}

.mob-fab-tc:active {
    transform: scale(0.96);
}

.mob-fab-tc[aria-expanded="true"] {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.mob-fab-tc:not([aria-expanded="true"]) {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
}

/* ── TC Panel backdrop ── */
.tc-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 920;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ── TC Panel drawer ── */
.tc-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #141b24;
    border-right: 1px solid #252b33;
    z-index: 930;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
}

.tc-panel--open {
    transform: translateX(0);
}

.tc-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px 12px;
    border-bottom: 1px solid #252b33;
    flex-shrink: 0;
}

.tc-panel-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tc-panel-title-icon {
    font-size: 16px;
    color: #ff6b35;
}

.tc-panel-title {
    font-size: 15px;
    font-weight: 700;
    color: #e0e6ef;
    margin: 0;
}

.tc-panel-close {
    background: rgba(255,255,255,0.07);
    border: none;
    color: #7a8290;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

.tc-panel-hint {
    padding: 8px 14px 4px;
    font-size: 11px;
    color: #4a5568;
    line-height: 1.4;
    flex-shrink: 0;
}

.tc-panel-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 10px 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tc-panel-empty {
    font-size: 13px;
    color: #4a5568;
    text-align: center;
    padding: 20px 0;
}

.tc-panel-row {
    width: 100%;
    border: 1px solid #252b33;
    background: #1a212b;
    color: #c0c8d8;
    border-radius: 11px;
    padding: 9px;
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.tc-panel-row--active {
    border-color: rgba(34, 197, 94, 0.58);
    background: rgba(34, 197, 94, 0.1);
}

.tc-panel-order {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    color: #7a8290;
    border: 1px solid rgba(255,255,255,0.2);
}

.tc-panel-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,0.2);
}

.tc-panel-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 4px;
}

.tc-panel-name {
    font-size: 13px;
    font-weight: 600;
    color: #c0c8d8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tc-panel-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.tc-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 9px;
    color: #9aa4b3;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    padding: 2px 6px;
}

.tc-chip--type {
    color: #86efac;
    border-color: rgba(134, 239, 172, 0.24);
}

.tc-panel-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.tc-badge {
    font-size: 9px;
    border-radius: 999px;
    padding: 2px 7px;
    border: 1px solid;
}

.tc-badge--next {
    color: #86efac;
    border-color: rgba(134, 239, 172, 0.42);
    background: rgba(34, 197, 94, 0.18);
}

.tc-badge--past {
    color: #fda4af;
    border-color: rgba(251, 113, 133, 0.4);
    background: rgba(190, 24, 93, 0.14);
}

.tc-badge--upcoming {
    color: #fcd34d;
    border-color: rgba(250, 204, 21, 0.4);
    background: rgba(161, 98, 7, 0.18);
}

.tc-panel-state {
    font-size: 9px;
    color: #7a8290;
}


.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 14, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.confirm-card {
    width: 100%;
    max-width: 420px;
    background: #181f28;
    border: 1px solid #2f3742;
    border-radius: 14px;
    padding: 18px;
}

.confirm-card h1 {
    font-size: 18px;
    margin-bottom: 10px;
}

.confirm-card p {
    font-size: 14px;
    line-height: 1.4;
    color: #cbd3dd;
    margin-bottom: 14px;
}

.confirm-btn {
    width: 100%;
    border: 0;
    border-radius: 10px;
    background: #ff6b35;
    color: #fff;
    font-weight: 700;
    padding: 10px 12px;
    font-size: 14px;
}

.leaflet-container {
    background: #202833;
}

/* ── Drawer panels (tab switching) ── */
.mini-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.mini-panel--active {
    display: flex;
    flex-direction: column;
}

/* mini-list-wrap is already a mini-panel; keep its scroll */
.mini-panel.mini-list-wrap {
    overflow-y: auto;
}

/* ── Timing panel ── */
.timing-panel {
    flex-direction: column;
    overflow: hidden;
}

.stage-summary-wrap {
    padding: 6px 8px 4px;
    flex-shrink: 0;
}

.stage-summary-card {
    border: 1px solid rgba(255,255,255,0.14);
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,107,53,0.1) 100%);
    border-radius: 11px;
    padding: 8px;
}

.stage-summary-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 7px;
}

.stage-summary-code {
    font-size: 9px;
    color: #fdba74;
    border: 1px solid rgba(251, 146, 60, 0.4);
    border-radius: 999px;
    padding: 2px 7px;
}

.stage-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
    font-size: 11px;
    color: #aab4c2;
}

.stage-summary-grid span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stage-summary-empty {
    margin: 0;
    color: #7a8290;
    font-size: 11px;
}

.timing-table-wrap {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 4px 8px;
}

.timing-block {
    margin-top: 10px;
}

.timing-block:first-child {
    margin-top: 0;
}

.timing-block-title {
    margin: 0 0 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7a8290;
}

.timing-empty {
    color: #7a8290;
    font-size: 12px;
    text-align: center;
    padding: 16px;
    margin: 0;
}

/* ── Timing leaderboard table ── */
.timing-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    white-space: nowrap;
}

.timing-tbl thead th {
    background: #1a212b;
    color: #7a8290;
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    padding: 5px 6px;
    border-bottom: 1px solid #252b33;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 1;
}

.timing-tbl tbody tr {
    border-bottom: 1px solid #1e2530;
}

.timing-tbl tbody tr:nth-child(odd) {
    background: #121820;
}

.timing-tbl tbody tr:nth-child(even) {
    background: #141c24;
}

.timing-cell {
    padding: 5px 6px;
    color: #c8d0da;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

.timing-cell--num {
    color: #ff6b35;
    font-weight: 800;
    min-width: 28px;
}

.timing-cell--name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #e0e6ef;
    font-weight: 600;
}

.timing-cell--name small.timing-dep {
    display: block;
    font-size: 9px;
    color: #6a7380;
    font-weight: 400;
}

.timing-cell--focus {
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.timing-cell--focus:active,
.timing-cell--focus:hover {
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
}

.timing-col-status {
    min-width: 120px;
}

.timing-cell--status {
    min-width: 120px;
}

.timing-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.timing-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.7);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}

.timing-status--moving {
    color: #86efac;
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.42);
}

.timing-status--stopped {
    color: #fde68a;
    background: rgba(234, 179, 8, 0.14);
    border: 1px solid rgba(234, 179, 8, 0.35);
}

.timing-status--offline,
.timing-status--finished {
    color: #fda4af;
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.4);
}

.timing-status--unknown {
    color: #9ca3af;
    background: rgba(148, 163, 184, 0.14);
    border: 1px solid rgba(148, 163, 184, 0.28);
}

.timing-col-split {
    text-align: right;
    min-width: 70px;
}

.timing-cell.timing--fastest {
    color: #00e676;
    font-weight: 800;
}

.timing-cell.timing--pending {
    color: #3a4250;
}

.timing-rank {
    font-size: 9px;
    color: #7a8290;
    margin-right: 2px;
}

