* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #0B1220; color: #E6EEF8; overflow: hidden; -webkit-tap-highlight-color: transparent; }
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; flex-direction: column; height: 100%; }
.hidden { display: none !important; }

/* LOGIN */
.login-container { flex: 1; display: flex; flex-direction: column; height: 100%; justify-content: center; padding: 2rem; max-width: 400px; margin: 0 auto; width: 100%; }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo h1 { font-size: 1.75rem; font-weight: 700; color: #22C3D6; margin-top: 0.75rem; }
.login-logo p { color: rgba(230, 238, 248, 0.52); font-size: 0.875rem; margin-top: 0.25rem; }
.input-group { margin-bottom: 1rem; }
.input-group label { display: block; font-size: 0.8rem; color: rgba(230, 238, 248, 0.72); margin-bottom: 0.35rem; font-weight: 500; }
.input-group input { width: 100%; padding: 0.75rem 1rem; background: #0F1B31; border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 0.75rem; color: #E6EEF8; font-size: 1rem; outline: none; transition: border 0.2s; }
.input-group input:focus { border-color: #22C3D6; }
#login-btn { width: 100%; padding: 0.85rem; background: linear-gradient(135deg, #22C3D6, #0891B2); color: #0B1220; border: none; border-radius: 0.75rem; font-size: 1rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 0.5rem; }
#login-btn:active { transform: scale(0.98); }
.error-text { color: #f87171; font-size: 0.8rem; text-align: center; margin-top: 0.75rem; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* TOP BAR */
#top-bar { display: flex; align-items: center; padding: 0.5rem 0.75rem; background: linear-gradient(135deg, #0891B2, #22C3D6); z-index: 1000; min-height: 52px; gap: 0.5rem; }
#top-bar h2 { flex: 1; font-size: 1.1rem; font-weight: 700; color: white; }
.header-right { display: flex; gap: 0.25rem; }
.icon-btn { background: none; border: none; color: white; padding: 0.5rem; border-radius: 0.5rem; cursor: pointer; position: relative; }
.icon-btn:active { background: rgba(255,255,255,0.15); }
.icon-btn-sm { background: none; border: none; color: rgba(230, 238, 248, 0.72); font-size: 1.5rem; line-height: 1; padding: 0.25rem 0.5rem; cursor: pointer; }
.badge { position: absolute; top: 2px; right: 2px; background: #ef4444; color: white; font-size: 0.65rem; font-weight: 700; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* MAP */
#map { flex: 1; z-index: 1; }
.leaflet-container { background: #0F172A; }

/* MAP TYPE SELECTOR */
#map-type-selector { position: absolute; bottom: 90px; right: 12px; z-index: 1000; display: flex; flex-direction: column; height: 100%; gap: 4px; background: rgba(11,18,32,0.95); border-radius: 10px; padding: 6px; backdrop-filter: blur(10px); border: 1px solid rgba(148, 163, 184, 0.18); }
.map-type-btn { background: transparent; border: none; color: rgba(230, 238, 248, 0.72); padding: 8px 12px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.map-type-btn.active { background: #22C3D6; color: #0B1220; }

/* CAR INFO BAR */
#car-info-bar { position: absolute; bottom: 0; left: 0; right: 0; z-index: 1000; background: rgba(11,18,32,0.97); backdrop-filter: blur(12px); border-top: 1px solid rgba(34,195,214,0.28); border-radius: 16px 16px 0 0; padding: 1rem; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); transition: transform 0.3s ease; }
.car-info-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.car-info-plate { font-size: 1.25rem; font-weight: 800; color: #E6EEF8; font-family: 'IBM Plex Mono', 'SF Mono', 'Fira Code', monospace; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.car-info-model { flex: 1; color: rgba(230, 238, 248, 0.52); font-size: 0.85rem; }
.car-info-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.stat { text-align: center; background: rgba(15,27,49,0.8); border-radius: 10px; padding: 0.5rem 0.25rem; border: 1px solid rgba(148, 163, 184, 0.10); }
.stat-icon { display: flex; justify-content: center; margin-bottom: 0.25rem; color: #22C3D6; }
.stat-value { font-size: 0.85rem; font-weight: 700; color: #E6EEF8; line-height: 1.2; font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.6rem; color: rgba(230, 238, 248, 0.52); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.speed-icon { color: #2DD4BF; }
.park-icon { color: #60A5FA; }
.car-info-actions { display: flex; gap: 0.5rem; }
.action-btn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.65rem; background: #0F1B31; border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 10px; color: #E6EEF8; font-size: 0.8rem; font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s; }
.action-btn:active { background: #111C33; transform: scale(0.98); }
.engine-btn { border-color: #FB7185; color: #FB7185; }
.engine-btn.blocked { background: #991b1b; border-color: #A3E635; color: #A3E635; }

/* SIDE PANELS */
.side-panel { position: absolute; top: 52px; left: 0; bottom: 0; width: 85vw; max-width: 340px; background: rgba(11,18,32,0.98); backdrop-filter: blur(12px); z-index: 1001; transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4,0,0.2,1); display: flex; flex-direction: column; height: 100%; border-right: 1px solid rgba(148, 163, 184, 0.18); }
.side-panel.open { transform: translateX(0); }
.right-panel { left: auto; right: 0; transform: translateX(100%); border-right: none; border-left: 1px solid rgba(148, 163, 184, 0.18); }
.right-panel.open { transform: translateX(0); }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid #0F1B31; }
.panel-header h3 { font-size: 1.1rem; font-weight: 700; }
.panel-search { padding: 0.75rem; }
.panel-search input { width: 100%; padding: 0.6rem 0.75rem; background: #0F1B31; border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 8px; color: #E6EEF8; font-size: 0.875rem; outline: none; }
.panel-search input:focus { border-color: #22C3D6; }
.panel-sort { display: flex; padding: 0 0.75rem 0.5rem; gap: 0.5rem; }
.sort-btn { background: #0F1B31; border: 1px solid rgba(148, 163, 184, 0.18); color: rgba(230, 238, 248, 0.72); padding: 0.35rem 0.75rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.sort-btn.active { background: #22C3D6; color: #0B1220; border-color: #22C3D6; }
.panel-tabs { display: flex; border-bottom: 1px solid #0F1B31; }
.tab-btn { flex: 1; padding: 0.65rem; background: none; border: none; border-bottom: 2px solid transparent; color: rgba(230, 238, 248, 0.52); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.tab-btn.active { color: #22C3D6; border-bottom-color: #22C3D6; }
.panel-list { flex: 1; overflow-y: auto; padding: 0.5rem; }
  flex: 1;
  min-height: 0;

/* CAR LIST ITEM */
.car-item { display: flex; align-items: center; padding: 0.75rem; margin-bottom: 4px; border-radius: 10px; cursor: pointer; transition: background 0.15s; gap: 0.75rem; }
.car-item:active, .car-item.selected { background: rgba(34,195,214,0.12); }
.car-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.car-status-dot.moving { background: #2DD4BF; box-shadow: 0 0 6px #2DD4BF; }
.car-status-dot.parked { background: #A3E635; }
.car-status-dot.offline { background: rgba(230, 238, 248, 0.35); }
.car-item-info { flex: 1; min-width: 0; }
.car-item-plate { font-weight: 700; font-size: 0.95rem; color: #E6EEF8; font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.car-item-model { font-size: 0.75rem; color: rgba(230, 238, 248, 0.52); }
.car-item-speed { font-size: 0.8rem; font-weight: 600; color: #2DD4BF; font-family: 'IBM Plex Mono', monospace; }
.car-item-speed.parked { color: #60A5FA; }

/* ALERT ITEM */
.alert-item { padding: 0.75rem; margin-bottom: 4px; border-radius: 10px; background: rgba(15,27,49,0.5); border-left: 3px solid #FBBF24; }
.alert-item.danger { border-left-color: #FB7185; }
.alert-item.info { border-left-color: #38BDF8; }
.alert-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; }
.alert-car { font-weight: 700; font-size: 0.85rem; color: #E6EEF8; }
.alert-time { font-size: 0.7rem; color: rgba(230, 238, 248, 0.52); font-family: 'IBM Plex Mono', monospace; }
.alert-text { font-size: 0.8rem; color: rgba(230, 238, 248, 0.72); }
.alert-value { font-size: 0.75rem; color: #FBBF24; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }

/* OVERLAY */
#panel-overlay { position: absolute; top: 52px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; }

/* CUSTOM MARKERS */
.car-marker { background: none; border: none; }
.marker-content { position: relative; display: flex; flex-direction: column; height: 100%; align-items: center; }
.marker-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 800; color: #0B1220; box-shadow: 0 2px 8px rgba(0,0,0,0.4); border: 2px solid white; }
.marker-icon.moving { background: #2DD4BF; }
.marker-icon.parked { background: #A3E635; }
.marker-icon.offline { background: rgba(230, 238, 248, 0.35); }
.marker-label { background: rgba(11,18,32,0.95); color: #E6EEF8; padding: 2px 6px; border-radius: 4px; font-size: 0.65rem; font-weight: 700; white-space: nowrap; margin-top: 2px; font-family: 'IBM Plex Mono', monospace; backdrop-filter: blur(6px); border: 1px solid rgba(148, 163, 184, 0.18); }

/* HISTORY LINE */
.history-line { stroke: #22C3D6; stroke-width: 3; fill: none; stroke-dasharray: 8 4; }

/* PWA install banner */
.install-banner { position: fixed; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #0891B2, #22C3D6); padding: 1rem; display: flex; align-items: center; justify-content: space-between; z-index: 2000; }
.install-banner p { color: white; font-size: 0.85rem; font-weight: 600; }
.install-banner button { background: white; color: #0891B2; border: none; padding: 0.5rem 1rem; border-radius: 8px; font-weight: 700; font-size: 0.85rem; cursor: pointer; }

/* Empty state */
.empty-state { text-align: center; padding: 2rem 1rem; color: rgba(230, 238, 248, 0.52); }
.empty-state svg { margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state p { font-size: 0.85rem; }

/* Loading */
.loading-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(11,18,32,0.9); display: flex; align-items: center; justify-content: center; z-index: 2000; }
.loading-overlay .spinner { width: 40px; height: 40px; border-width: 3px; }

/* Scrollbar */
.panel-list::-webkit-scrollbar { width: 4px; }
.panel-list::-webkit-scrollbar-track { background: transparent; }
.panel-list::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.28); border-radius: 2px; }
