:root {
  --bg: #FFF8F0;
  --surface: #FFFFFF;
  --surface-tint: #FFF1E4;
  --primary: #FF6B4A;
  --primary-dark: #E85A3B;
  --secondary: #2EC4B6;
  --secondary-dark: #23A99D;
  --accent-placa: #FFC857;
  --success: #3DD68C;
  --success-dark: #2BB876;
  --danger: #EF476F;
  --danger-dark: #D7335C;
  --text: #332F3B;
  --text-muted: #7A7486;
  --border: #F0E0CF;
  --sidebar-bg: #2B2438;
  --sidebar-texto: #EFE8F5;
  --sidebar-texto-muted: #A79DBC;

  --fuente-sistema: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --fuente-mono: ui-monospace, "Cascadia Mono", "Consolas", monospace;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(51, 47, 59, 0.06);
  --shadow-md: 0 8px 24px rgba(51, 47, 59, 0.10);
  --shadow-primary: 0 8px 20px rgba(255, 107, 74, 0.25);

  --sidebar-ancho: 240px;
  --bottom-nav-alto: 72px;
}

* {
  box-sizing: border-box;
}

html {
  /* Para que scrollIntoView() (usado por el navegador al enfocar/hacer
     clic en un campo) no deje elementos escondidos detrás de la barra
     de navegación inferior fija en móvil. */
  scroll-padding-bottom: calc(var(--bottom-nav-alto) + 1rem);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--fuente-sistema);
}

body {
  min-height: 100vh;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

h1, h2, h3 {
  margin: 0 0 0.5em;
}

svg {
  display: block;
}

/* -------------------- Shell de la app -------------------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* -------------------- Sidebar (PC) -------------------- */

.sidebar {
  display: none;
}

.sidebar-marca {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.3rem 1.2rem;
  color: var(--sidebar-texto);
}

.sidebar-marca .icono {
  width: 30px;
  height: 30px;
  color: var(--accent-placa);
  flex-shrink: 0;
}

.sidebar-marca span {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem;
}

.sidebar-nav .tab-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--sidebar-texto-muted);
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav .tab-btn .icono {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav .tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-texto);
}

.sidebar-nav .tab-btn.activo {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-primary);
}

/* -------------------- Barra superior -------------------- */

.barra-superior {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  gap: 0.75rem;
}

.barra-superior h1 {
  font-size: 1.05rem;
  font-weight: 800;
}

.barra-superior-estado {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip-pendientes {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chip-conexion {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--danger);
  color: white;
}

.chip-conexion.conectado {
  background: var(--success);
}

.chip-conexion .punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  filter: brightness(1.4);
}

.usuario-nombre {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* -------------------- Navegación por pestañas (barra inferior móvil) -------------------- */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-alto);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(51, 47, 59, 0.08);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav .tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  cursor: pointer;
}

.bottom-nav .tab-btn .icono {
  width: 22px;
  height: 22px;
}

.bottom-nav .tab-btn.activo {
  color: var(--primary);
}

/* -------------------- Layout principal -------------------- */

.contenido {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: calc(var(--bottom-nav-alto) + 1rem);
}

.vista {
  display: none;
}

.vista.activa {
  display: block;
}

/* -------------------- Botones -------------------- */

.boton-grande {
  display: block;
  width: 100%;
  padding: 1.1rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: white;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: var(--shadow-primary);
  transition: transform 0.1s ease, background 0.15s ease;
}

.boton-grande:hover {
  background: var(--primary-dark);
}

.boton-grande:active {
  transform: translateY(1px);
}

.boton-secundario {
  display: inline-block;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-tint);
  border: 2px solid var(--border);
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.boton-secundario:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.boton-verde {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.boton-verde:hover {
  background: var(--success-dark);
  color: white;
}

.boton-rojo {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

.boton-rojo:hover {
  background: var(--danger-dark);
  color: white;
}

.boton-bloque {
  display: block;
  width: 100%;
  text-align: center;
}

/* -------------------- Tarjetas / secciones -------------------- */

.tarjeta {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

/* -------------------- Formulario -------------------- */

.campo {
  margin-bottom: 1rem;
}

.campo label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.campo input,
.campo textarea,
.campo select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.campo input:focus,
.campo textarea:focus,
.campo select:focus {
  outline: none;
  border-color: var(--secondary);
}

.campo .ayuda {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.contador-caracteres {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* -------------------- Campo de placa estilo placa colombiana -------------------- */

.placa-input-wrap {
  display: flex;
  justify-content: center;
}

input.placa {
  font-family: var(--fuente-mono);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
  background: var(--accent-placa);
  color: #1B1D21;
  border: 4px solid #1B1D21;
  border-radius: var(--radius-lg);
  padding: 0.6rem 0.5rem;
  max-width: 320px;
}

input.placa::placeholder {
  color: rgba(27, 29, 33, 0.45);
}

/* -------------------- Selector de modo de placa -------------------- */

.selector-segmentos {
  display: flex;
  background: var(--surface-tint);
  border-radius: var(--radius-pill);
  padding: 0.25rem;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.selector-segmentos button {
  flex: 1;
  padding: 0.55rem 0.4rem;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.82rem;
}

.selector-segmentos button.activo {
  background: var(--secondary);
  color: white;
}

.modo-placa-panel {
  display: none;
}

.modo-placa-panel.activo {
  display: block;
}

.aviso {
  background: #FFF4D9;
  border: 1px solid var(--accent-placa);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  color: #7A5A00;
}

.aviso.error {
  background: #FDE3EA;
  border-color: var(--danger);
  color: #A32447;
}

.aviso.exito {
  background: #DDF7EA;
  border-color: var(--success);
  color: #1E8A5A;
}

/* -------------------- Cámara / OCR -------------------- */

.camara-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 0.75rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border);
  background: black;
}

.camara-wrap video {
  width: 100%;
  display: block;
}

.camara-acciones {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 0.75rem;
}

/* -------------------- Tarjetas de estadísticas -------------------- */

.stats-fila {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.stat-tarjeta {
  flex: 1 1 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-numero {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-etiqueta {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* -------------------- Listas de resultados (buscador / historial / en vivo) -------------------- */

.item-lista {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
}

.item-lista:hover {
  border-color: var(--secondary);
}

.item-lista-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.item-lista .placa-mini {
  font-family: var(--fuente-mono);
  font-weight: 800;
  letter-spacing: 0.1em;
  background: var(--accent-placa);
  border: 2px solid #1B1D21;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  color: #1B1D21;
}

.item-lista .detalle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  color: white;
}

.badge.en-parqueadero {
  background: var(--success);
}

.badge.retirada {
  background: var(--text-muted);
}

.ficha-linea {
  margin-bottom: 0.45rem;
}

.ficha-linea strong {
  display: inline-block;
  min-width: 130px;
  color: var(--text);
}

/* -------------------- Modal de ficha de moto -------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(43, 36, 56, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-caja {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
}

.modal-cerrar {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 50%;
  background: var(--surface-tint);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal-cerrar:hover {
  background: var(--danger);
  color: white;
}

/* -------------------- Pantalla de login -------------------- */

.pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
  padding: 1rem;
}

.pantalla-login-tarjeta {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius-lg);
}

.pantalla-login-icono {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
  color: var(--primary);
}

/* -------------------- Utilidades -------------------- */

.oculto {
  display: none !important;
}

.texto-centrado {
  text-align: center;
}

.mt-1 { margin-top: 1rem; }

/* -------------------- Responsivo: móvil / PC -------------------- */

/* Móvil por defecto: barra inferior + una sola columna (definido arriba). */

@media (min-width: 900px) {
  html {
    scroll-padding-bottom: 0;
  }

  .app-shell {
    flex-direction: row;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-ancho);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
  }

  .titulo-movil {
    display: none;
  }

  .bottom-nav {
    display: none;
  }

  .contenido {
    padding-bottom: 1.5rem;
  }
}
