/* Estilos principales: ¿Dónde están los coches? (Layout 50/50 sin scroll base) */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden], .hidden {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #0f172a;
  color: #0f172a;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

/* Cabecera superior mínima */
.app-header {
  height: 2.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.85rem;
  background-color: #0f172a;
  color: #f8fafc;
  border-bottom: 1px solid #334155;
}
.app-title { margin: 0; font-size: 0.88rem; font-weight: 700; letter-spacing: 0.01em; }
.user-indicator { font-size: 0.8rem; color: #cbd5e1; }
.user-indicator strong { color: #ffffff; font-weight: 700; }

/* Contenedor principal 50/50 sin scroll */
.vehicles-split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  background-color: #ffffff;
  overflow: hidden;
}
.vehicle-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0.65rem 0.45rem;
  background-color: #ffffff;
  overflow: hidden;
}
.vehicle-card + .vehicle-card { border-top: 3px solid #0f172a; }

/* Zona fotográfica dominante y controles superpuestos */
.vehicle-photo-area {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: 0.75rem;
  overflow: hidden;
  background-color: #e2e8f0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.vehicle-photo { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Esquina superior izquierda: Matrícula */
.plate-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  padding: 0;
  border: 1.5px solid #ffffff;
  border-radius: 0.25rem;
  background-color: #ffffff;
  box-shadow: 0 2px 6px rgba(2, 6, 23, 0.45);
  cursor: pointer;
  overflow: hidden;
}
.plate-img { display: block; height: 1.5rem; width: 7.2rem; object-fit: cover; }
/* Esquina superior derecha: Deshacer e Historial con separación holgada */
.card-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.control-btn {
  min-height: 2.15rem;
  padding: 0 0.75rem;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: 0.5rem;
  background-color: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(2, 6, 23, 0.4);
}
.undo-btn { min-width: 2.3rem; padding: 0 0.55rem; font-size: 1.05rem; }
.control-btn:disabled, .undo-btn:disabled {
  opacity: 0.38;
  background-color: rgba(51, 65, 85, 0.75);
  border-color: rgba(203, 213, 225, 0.4);
  cursor: not-allowed;
}

/* Bloque inferior de 3 líneas: Máximo contraste a pleno sol */
.vehicle-info { flex-shrink: 0; padding: 0.4rem 0.2rem 0.1rem; display: flex; flex-direction: column; gap: 0.12rem; }
.vehicle-title { margin: 0; font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #1e293b; }
.vehicle-location { margin: 0; font-size: 1.28rem; font-weight: 800; line-height: 1.15; color: #020617; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vehicle-meta { margin: 0; font-size: 0.86rem; font-weight: 600; color: #0f172a; }

/* Modales superpuestos (85%-90% de pantalla) con scroll interno fluido */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: rgba(2, 6, 23, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-panel {
  width: 90%;
  max-width: 26rem;
  height: 86dvh;
  max-height: 88dvh;
  background-color: #ffffff;
  color: #0f172a;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}
.modal-panel-compact { height: auto; max-height: 85dvh; padding-bottom: 1rem; }
.modal-header { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; background-color: #0f172a; color: #ffffff; }
.modal-title { margin: 0; font-size: 1rem; font-weight: 700; }
.modal-close-btn { width: 2rem; height: 2rem; border: none; border-radius: 0.45rem; background-color: rgba(255, 255, 255, 0.16); color: #ffffff; font-size: 0.95rem; font-weight: 700; cursor: pointer; }
.modal-scroll-area { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.75rem; }
.locations-list, .history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.location-btn, .locations-list button { width: 100%; padding: 0.8rem 0.9rem; text-align: left; font-size: 0.98rem; font-weight: 700; color: #020617; background-color: #f8fafc; border: 1.5px solid #cbd5e1; border-radius: 0.6rem; cursor: pointer; }
.history-item, .history-list li { padding: 0.7rem 0.85rem; background-color: #f8fafc; border: 1px solid #cbd5e1; border-radius: 0.6rem; color: #0f172a; font-size: 0.9rem; }
.new-location-form { border-top: 2px solid #e2e8f0; padding-top: 0.75rem; display: flex; flex-direction: column; gap: 0.45rem; }
.new-location-label { font-size: 0.85rem; font-weight: 700; color: #0f172a; }
.new-location-row { display: flex; gap: 0.5rem; }
.new-location-input { flex: 1; min-width: 0; padding: 0.65rem 0.75rem; font-size: 0.95rem; border: 1.5px solid #64748b; border-radius: 0.55rem; }
.new-location-btn, .action-btn { padding: 0.65rem 1rem; font-size: 0.92rem; font-weight: 700; border: none; border-radius: 0.55rem; background-color: #0f172a; color: #ffffff; cursor: pointer; }
.modal-confirm-text { margin: 1.1rem 1rem; font-size: 0.98rem; text-align: center; color: #020617; }
.modal-actions { display: flex; gap: 0.65rem; padding: 0 1rem; }
.action-btn { flex: 1; padding: 0.75rem; }
.confirm-undo-btn { background-color: #b91c1c; }
.cancel-undo-btn { background-color: #e2e8f0; color: #0f172a; }

/* Pantalla de bloqueo */
.lock-screen { position: fixed; inset: 0; z-index: 100; background-color: #0f172a; color: #ffffff; display: flex; align-items: center; justify-content: center; padding: 1.5rem; text-align: center; }
.lock-card { background-color: #1e293b; border: 1px solid #334155; border-radius: 1rem; padding: 1.5rem; max-width: 22rem; }
.lock-title { margin: 0 0 0.6rem; font-size: 1.2rem; font-weight: 800; }
.lock-text { margin: 0; font-size: 0.92rem; line-height: 1.45; color: #e2e8f0; }
