* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; height: 100vh; overflow: hidden; }
.hidden { display: none !important; }
.screen { width: 100%; height: 100vh; }

/* ===== LOGIN ===== */
.login-bg {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #1a1a2e;
}
.login-card {
  background: white; border-radius: 12px; padding: 48px 40px 32px;
  width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.login-logo { text-align: center; margin-bottom: 36px; }
.logo-icon {
  display: inline-block; background: #0a0a0a; color: white; font-weight: 800;
  border-radius: 4px; padding: 6px 10px; font-size: 16px; margin-right: 8px; vertical-align: middle;
}
.logo-sm { font-size: 13px; padding: 4px 7px; }
.logo-text { font-size: 20px; font-weight: 700; color: #0a0a0a; vertical-align: middle; }
.logo-text-sm { font-size: 16px; }
#login-form input {
  width: 100%; padding: 14px 16px; border: 1px solid #d1d5db;
  border-radius: 8px; font-size: 14px; margin-bottom: 12px; outline: none;
}
#login-form input:focus { border-color: #374151; }
.btn-primary {
  width: 100%; padding: 14px; background: #d1d5db; color: #374151;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 8px;
}
.btn-primary:hover { background: #9ca3af; }
.error { color: #dc2626; font-size: 13px; margin-top: 8px; text-align: center; }
.forgot-link { display: block; text-align: center; margin-top: 16px; color: #6b7280; font-size: 13px; text-decoration: underline; }
.login-footer { text-align: center; margin-top: 32px; font-size: 11px; color: #9ca3af; }
.login-footer strong { color: #374151; letter-spacing: 1px; }

/* ===== APP LAYOUT ===== */
#app-screen { position: relative; }
#map { position: absolute; top: 0; left: 0; width: 100%; height: calc(100% - 32px); z-index: 0; }

/* ===== HEADER (floating over map) ===== */
#header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; flex-direction: column; pointer-events: none;
}
.header-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: white; pointer-events: auto;
}
.header-left { display: flex; align-items: center; gap: 6px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.client-badge { font-size: 18px; font-weight: 800; color: #1e293b; }
.notification-bell { position: relative; cursor: pointer; }
.bell-icon { font-size: 22px; }
.bell-count {
  position: absolute; top: -6px; right: -8px;
  background: #dc2626; color: white; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}

.header-nav {
  display: flex; align-items: center; gap: 8px; padding: 8px 20px;
  pointer-events: auto; flex-wrap: nowrap;
}
.flight-pill {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.95); border: 1px solid #e5e7eb;
  border-radius: 8px; padding: 6px 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.flight-info-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: #2563eb; color: white; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.flight-selector {
  border: none; background: transparent; font-size: 13px; font-weight: 500;
  color: #1e293b; outline: none; cursor: pointer;
}
.flight-menu-btn { border: none; background: none; cursor: pointer; font-size: 16px; color: #6b7280; }

#nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 7px 14px; border: 1px solid rgba(0,0,0,0.08); border-radius: 20px;
  background: rgba(255,255,255,0.95); font-size: 12px; cursor: pointer;
  color: #374151; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  pointer-events: auto;
}
.nav-btn.active { background: #2563eb; color: white; border-color: #2563eb; }
.nav-btn:hover:not(.active):not(.disabled) { background: #f3f4f6; }
.nav-btn.disabled { color: #a1a1aa; cursor: default; opacity: 0.7; }

/* ===== SIDEBAR (floating over map) ===== */
#sidebar {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: 360px; background: white; z-index: 900;
  overflow-y: auto; padding: 20px;
  box-shadow: 4px 0 16px rgba(0,0,0,0.1);
  padding-top: 110px; bottom: 32px;
}
.sidebar-header { margin-bottom: 12px; }
.sidebar-header h3 { font-size: 13px; color: #6b7280; font-weight: 400; }
.sidebar-header h2 { font-size: 28px; font-weight: 700; color: #0a0a0a; }
#alert-filters { display: flex; gap: 8px; margin-bottom: 10px; }
#alert-filters select {
  flex: 1; padding: 6px 8px; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 11px; color: #374151;
}
.alert-list-header {
  display: grid; grid-template-columns: 40px 36px 60px 1fr;
  gap: 6px; padding: 6px 4px; font-size: 10px; color: #9ca3af;
  text-transform: uppercase; letter-spacing: 0.3px;
  border-bottom: 1px solid #e5e7eb; margin-bottom: 4px;
}

/* Alert items (table-like) */
.alert-item {
  display: grid; grid-template-columns: 40px 36px 60px 1fr;
  align-items: center; gap: 6px; padding: 9px 4px;
  border-bottom: 1px solid #f3f4f6; cursor: pointer;
  transition: background 0.1s;
}
.alert-item:hover { background: #f8fafc; }
.alert-item.selected { background: #eff6ff; }
.alert-item-status { font-size: 12px; font-weight: 600; text-align: center; }
.alert-dot {
  width: 30px; height: 22px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 10px; font-weight: 700;
}
.alert-item-km { font-weight: 600; color: #1e293b; font-size: 13px; }
.alert-item-category { font-size: 12px; color: #374151; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.severity-muy_alto, .severity-alto { background: #dc2626; }
.severity-medio { background: #f59e0b; }
.severity-bajo, .severity-muy_bajo { background: #22c55e; }
.status-abierto { color: #991b1b; }
.status-en_curso { color: #92400e; }
.status-resuelto { color: #166534; }
.status-cerrado { color: #6b7280; }

/* Alert detail panel */
.btn-back {
  padding: 6px 12px; border: 1px solid #d1d5db; border-radius: 6px;
  background: white; font-size: 12px; cursor: pointer; margin-bottom: 12px;
}
.btn-back:hover { background: #f3f4f6; }
#detail-content { }
.detail-image {
  width: 100%; border-radius: 8px; margin-bottom: 12px;
  background: #e2e8f0; min-height: 200px;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; color: #64748b; font-size: 13px;
}
.detail-severity-bar {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
  color: white; font-weight: 600; font-size: 14px;
}
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px;
}
.detail-label { color: #6b7280; display: flex; align-items: center; gap: 6px; }
.detail-value { color: #1e293b; font-weight: 500; }
.detail-report {
  background: #f8fafc; border-left: 3px solid #d1d5db;
  padding: 12px 16px; margin: 14px 0; border-radius: 0 8px 8px 0;
}
.detail-report-title { font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.detail-report-text { font-size: 13px; color: #374151; line-height: 1.6; }
.detail-contact {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #f1f5f9;
}
.detail-contact-name { font-size: 13px; color: #1e293b; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.detail-contact-icons { display: flex; gap: 8px; }
.contact-icon {
  width: 28px; height: 28px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 14px; cursor: pointer;
}
.icon-email { background: #fbbf24; }
.icon-phone { background: #2563eb; color: white; }
.icon-whatsapp { background: #22c55e; color: white; }
.detail-actions { display: flex; gap: 8px; margin-top: 16px; }
.btn-action {
  flex: 1; padding: 11px; border: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-seguimiento { background: #2563eb; color: white; }
.btn-seguimiento:hover { background: #1d4ed8; }
.btn-cerrar { background: #dc2626; color: white; }
.btn-cerrar:hover { background: #b91c1c; }

/* History carousel */
.detail-history { margin-top: 16px; }
.detail-history-title { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.history-carousel {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px;
}
.history-item {
  flex-shrink: 0; width: 100px; border-radius: 6px; overflow: hidden;
  border: 3px solid #e5e7eb; cursor: pointer;
}
.history-item-img {
  width: 100%; height: 60px; background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: #94a3b8;
}
.history-item-date { font-size: 10px; text-align: center; padding: 4px; color: #374151; }
.history-severity-muy_alto, .history-severity-alto { border-color: #dc2626; }
.history-severity-medio { border-color: #f59e0b; }
.history-severity-bajo, .history-severity-muy_bajo { border-color: #22c55e; }

/* ===== GALLERY ===== */
#gallery {
  position: absolute; top: 90px; left: 0; right: 0; bottom: 32px;
  overflow-y: auto; padding: 24px; background: #f8fafc; z-index: 800;
}
#gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.gallery-card {
  background: white; border-radius: 8px; overflow: hidden;
  border: 2px solid #e5e7eb; cursor: pointer; transition: border-color 0.15s;
}
.gallery-card:hover { border-color: #94a3b8; }
.gallery-card-img {
  width: 100%; height: 180px; background: #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 13px; position: relative;
}
.gallery-card-badge {
  position: absolute; top: 8px; left: 8px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.92); padding: 4px 10px;
  border-radius: 12px; font-size: 12px; font-weight: 600;
}
.gallery-card-info {
  padding: 10px 12px; display: flex; justify-content: space-between;
  align-items: center; font-size: 12px; color: #6b7280;
}

/* ===== SEGMENTS ===== */
#segment-selector {
  position: absolute; top: 96px; right: 20px; z-index: 800;
  display: flex; gap: 4px;
}
.seg-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1);
  background: rgba(255,255,255,0.95); font-size: 13px; font-weight: 700;
  cursor: pointer; color: #374151; box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.seg-btn.active { background: #2563eb; color: white; border-color: #2563eb; }

/* ===== BOTTOM BAR ===== */
#bottom-bar {
  position: absolute; bottom: 52px; left: 50%; transform: translateX(-50%);
  background: white; padding: 8px 20px; border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15); z-index: 800;
  font-size: 13px; color: #374151; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
#bottom-bar:hover { background: #f8fafc; }

/* ===== FOOTER ===== */
#app-footer {
  position: absolute; bottom: 0; left: 0; right: 0; height: 32px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px; font-size: 11px; color: #6b7280;
  background: white; border-top: 1px solid #e5e7eb; z-index: 1000;
}
#app-footer strong { color: #374151; letter-spacing: 0.5px; }

/* ===== MAP POPUP ===== */
.alert-popup { min-width: 200px; }
.alert-popup-img {
  width: 100%; height: 100px; background: #e2e8f0; border-radius: 4px;
  margin-bottom: 8px; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 11px;
}
.alert-popup-info { display: flex; align-items: center; gap: 8px; }
.alert-popup-km { font-size: 13px; font-weight: 600; color: #1e293b; }
.alert-popup-detail {
  font-size: 12px; color: #2563eb; cursor: pointer; margin-left: auto;
  display: flex; align-items: center; gap: 4px;
}
