:root {
  --bg: #100e0a;
  --surface: #1a1611;
  --surface-hover: #221d16;
  --border: #2e2820;
  --gold: #c6a15b;
  --gold-light: #d9bc7f;
  --text: #f2ece0;
  --text-muted: #a89f8f;
  --danger: #d97060;
  --success: #7fae6c;
  --info: #6ea8c6;
  --warning: #cf9a4a;

  /* Distintivo por tipo_servicio (borde + punto), independiente de los
     colores de estado de arriba para que no se confundan cuando aparecen
     juntos en la misma tarjeta. Tonos moderados, pensados para leerse como
     acento sobre --bg, no como color sólido. Reutilizable en cualquier
     pantalla que liste servicios (Hoy, tablero de reparto, etc). */
  --tipo-entrada: #7fae6c;
  --tipo-salida: #6ea8c6;
  --tipo-traslado: #cf9a4a;
  --tipo-disposicion: #a48fc7;

  --font-heading: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  --radius: 14px;
  --tap-min: 48px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--font-heading);
  font-weight: 600;
  margin: 0 0 0.5em;
  letter-spacing: 0.01em;
}

a {
  color: var(--gold);
}

.mono {
  font-family: var(--font-mono);
}

/* --- Layout --- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Deja hueco para la barra inferior fija en móvil; en escritorio no hace
     falta porque .bottom-nav se oculta. */
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 720px) {
  .page {
    padding-bottom: 0;
  }
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Centered auth screen --- */

.auth-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  animation: fade-in 0.35s ease;
}

.auth-card .brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-card .brand .gold {
  color: var(--gold);
}

.auth-card h1 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.auth-card p.subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

/* --- Forms --- */

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23a89f8f'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%23a89f8f' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.field textarea {
  min-height: 90px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(198, 161, 91, 0.18);
}

.field .hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field {
  flex: 1;
  min-width: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--tap-min);
  padding: 0 20px;
  background: var(--gold);
  color: #1a1610;
  border: none;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--gold-light);
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn[hidden] {
  display: none;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.error-message {
  background: rgba(217, 112, 96, 0.12);
  border: 1px solid rgba(217, 112, 96, 0.4);
  color: var(--danger);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin-bottom: 18px;
  display: none;
}

.error-message.visible {
  display: block;
  animation: fade-in 0.2s ease;
}

.banner-success {
  background: rgba(127, 174, 108, 0.15);
  border: 1px solid rgba(127, 174, 108, 0.4);
  color: var(--success);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.9rem;
  margin-bottom: 18px;
  animation: fade-in 0.3s ease;
}

/* --- App header --- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(16, 14, 10, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  /* En iPhone con notch/Dynamic Island, deja hueco para el safe area
     superior cuando la PWA corre en modo standalone (sin barra de Safari).
     env() sin soporte (escritorio/Android) devuelve 0px, así que no afecta. */
  padding-top: max(14px, env(safe-area-inset-top, 0px));
}

.app-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .brand-mark {
  font-family: var(--font-heading);
  font-size: 1.15rem;
}

.app-header .brand-mark .gold {
  color: var(--gold);
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-header .user-name {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Nav principal (Diario/Histórico/Recursos/Cuenta): en escritorio vive como
   barra horizontal dentro del header; en móvil se oculta aquí porque pasa a
   ser la barra inferior fija (.bottom-nav), más cómoda para el pulgar. */
.top-nav {
  display: none;
}

@media (min-width: 720px) {
  .top-nav {
    display: flex;
    gap: 4px;
  }

  .top-nav-link {
    padding: 8px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
  }

  .top-nav-link:hover {
    background: var(--surface-hover);
    color: var(--text);
  }

  .top-nav-link.active {
    color: var(--gold);
  }
}

/* Barra inferior fija: navegación principal en móvil, pensada para el
   pulgar (siempre visible, sin abrir/cerrar nada). Se oculta en escritorio,
   donde su lugar lo ocupa .top-nav dentro del header. */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  background: rgba(16, 14, 10, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 60px;
  padding: 8px 4px 6px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.bottom-nav-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 0.7rem;
  font-weight: 500;
}

.bottom-nav-item.active {
  color: var(--gold);
}

@media (min-width: 720px) {
  .bottom-nav {
    display: none;
  }
}

/* Icono de navegación reutilizable en el header (calendario, y lo que venga
   después: kanban, ajustes...). */
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 1.2rem;
  transition: background 0.15s ease;
}

.icon-link:hover {
  background: var(--surface-hover);
}

.icon-link[hidden] {
  display: none;
}

.logout-btn {
  min-height: 40px;
  min-width: 40px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  background: var(--surface-hover);
  color: var(--danger);
}

/* --- Main content --- */

.main-content {
  flex: 1;
  padding: 24px 0 48px;
}

/* FAB reutilizable: cualquier pantalla con una acción principal de "crear"
   puede usar la misma clase. */
.fab {
  position: fixed;
  right: 20px;
  /* Por encima de la barra inferior fija en móvil. */
  bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 16px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gold);
  color: #1a1610;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  transition: background 0.15s ease, transform 0.1s ease;
  z-index: 20;
}

.fab:hover {
  background: var(--gold-light);
}

.fab:active {
  transform: scale(0.94);
}

@media (min-width: 720px) {
  .fab {
    bottom: 24px;
  }
}

.page-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title h1 {
  font-size: 1.5rem;
  margin: 0;
}

.page-title .today-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* --- Service cards --- */

.servicio-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.servicio-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: fade-in 0.3s ease;
  transition: border-color 0.15s ease;
  text-decoration: none;
  color: inherit;
}

/* Solo se anima el gold en los otros 3 lados: el borde izquierdo lo dejamos
   fijo al color de tipo_servicio para que el distintivo no desaparezca al
   pasar el ratón por encima. */
.servicio-card:hover {
  border-top-color: var(--gold);
  border-right-color: var(--gold);
  border-bottom-color: var(--gold);
}

.servicio-card .row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  gap: 10px;
}

.servicio-card .row-top-left {
  display: flex;
  align-items: center;
}

.servicio-card .hora {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--gold-light);
  font-weight: 600;
}

/* Distintivo de tipo_servicio: punto de color reutilizable en cualquier
   pantalla que muestre servicios (Hoy, tablero de reparto, etc). El mismo
   nombre de clase (.tipo-entrada, .tipo-salida, ...) también colorea el
   borde izquierdo de .servicio-card — una sola fuente de color por tipo. */
.tipo-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  min-width: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.tipo-entrada {
  --tipo-color: var(--tipo-entrada);
}
.tipo-salida {
  --tipo-color: var(--tipo-salida);
}
.tipo-traslado {
  --tipo-color: var(--tipo-traslado);
}
.tipo-disposicion {
  --tipo-color: var(--tipo-disposicion);
}

.tipo-dot.tipo-entrada,
.tipo-dot.tipo-salida,
.tipo-dot.tipo-traslado,
.tipo-dot.tipo-disposicion {
  background: var(--tipo-color);
}

.servicio-card.tipo-entrada,
.servicio-card.tipo-salida,
.servicio-card.tipo-traslado,
.servicio-card.tipo-disposicion {
  border-left-color: var(--tipo-color);
}

.servicio-card .ruta {
  font-size: 1rem;
  margin-bottom: 6px;
  line-height: 1.4;
}

.servicio-card .ruta .arrow {
  color: var(--text-muted);
  margin: 0 6px;
}

.servicio-card .meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.servicio-card .cliente {
  color: var(--text);
}

/* Fila de datos secundarios (pax, precio, vehículo, proveedor, cobro).
   Separada por un borde superior fino para diferenciarla de la info
   principal (hora/ruta/cliente) sin necesitar otra tarjeta ni acordeón. */
.servicio-card .detalles-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.servicio-card .detalles-row .dato {
  white-space: nowrap;
}

.servicio-card .detalles-row .separador {
  color: var(--border);
}

/* --- Estado badges --- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-pendiente {
  background: rgba(168, 159, 143, 0.15);
  color: var(--text-muted);
}

.badge-ofertado,
.badge-aceptado_por_colaborador,
.badge-confirmado_por_ofertante {
  background: rgba(110, 168, 198, 0.15);
  color: var(--info);
}

.badge-asignado {
  background: rgba(127, 174, 108, 0.15);
  color: var(--success);
}

.badge-completado {
  background: rgba(198, 161, 91, 0.18);
  color: var(--gold-light);
}

.badge-cancelado,
.badge-retirado {
  background: rgba(217, 112, 96, 0.15);
  color: var(--danger);
}

/* Estado de cobro: siempre visible en la fila de detalles, en danger si
   falta por cobrar (la señal que más debe destacar) o en success si ya
   está pagado. */
.badge-pago-pendiente {
  background: rgba(217, 112, 96, 0.15);
  color: var(--danger);
}

.badge-pago-pagado {
  background: rgba(127, 174, 108, 0.15);
  color: var(--success);
}

/* --- Empty state --- */

.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  animation: fade-in 0.4s ease;
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state h2 {
  font-size: 1.2rem;
  color: var(--text);
}

.empty-state p {
  margin: 0;
  font-size: 0.9rem;
}

/* --- Loading state --- */

.loading-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 720px) {
  .container {
    max-width: 760px;
  }
}

/* --- Formulario de nuevo servicio --- */

.form-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.form-back[hidden] {
  display: none;
}

.form-back:hover {
  color: var(--gold);
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  animation: fade-in 0.3s ease;
}

.form-section h2 {
  font-size: 1.05rem;
  margin-bottom: 16px;
  color: var(--gold-light);
}

.form-section:last-of-type {
  margin-bottom: 24px;
}

/* Selector de proveedor: control segmentado (colaborador registrado vs
   texto libre). Solo el modo activo se envía; el otro se limpia. */
.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 12px;
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented button.active {
  background: var(--gold);
  color: #1a1610;
}

/* Checkbox tipo toggle, para "pagado" */
.toggle-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--tap-min);
}

.toggle-field label {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

.toggle {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle .track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  transition: background 0.15s ease;
  cursor: pointer;
}

.toggle .track::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}

.toggle input:checked + .track {
  background: rgba(127, 174, 108, 0.25);
}

.toggle input:checked + .track::before {
  transform: translateX(20px);
  background: var(--success);
}

/* Steppers +/- para equipaje */
.stepper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stepper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stepper .stepper-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stepper .stepper-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.stepper button {
  width: 40px;
  min-height: 40px;
  background: var(--bg);
  border: none;
  color: var(--gold-light);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease;
}

.stepper button:hover {
  background: var(--surface-hover);
}

.stepper .stepper-value {
  flex: 1;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1rem;
}

/* Bloques dinámicos de niños */
.ninos-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nino-block {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: fade-in 0.2s ease;
}

.nino-block .field {
  margin-bottom: 0;
}

.nino-block .nino-numero {
  min-height: var(--tap-min);
  display: flex;
  align-items: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding-right: 2px;
}

.nino-block .nino-edad {
  width: 90px;
  flex-shrink: 0;
}

.nino-block .nino-asiento {
  flex: 1;
  min-width: 0;
}

.form-submit-bar {
  position: sticky;
  /* Por encima de la barra inferior fija en móvil (si no, el botón de
     guardar quedaría tapado detrás de .bottom-nav). */
  bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 16px 0 20px;
}

@media (min-width: 720px) {
  .form-submit-bar {
    bottom: 0;
  }
}

/* --- Calendario --- */

.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.cal-nav-label {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  text-transform: capitalize;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--gold);
  background: var(--surface-hover);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.cal-day:hover {
  border-color: var(--gold);
}

.cal-day.outside {
  color: var(--text-muted);
  background: transparent;
}

.cal-day.today {
  border-color: var(--gold);
}

.cal-day-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.cal-day-dots {
  display: flex;
  gap: 3px;
  min-height: 6px;
}

.cal-day-dots .tipo-dot {
  margin-right: 0;
}

/* --- Detalle de servicio --- */

.btn-row {
  display: flex;
  gap: 12px;
}

.btn-row[hidden] {
  display: none;
}

.btn-row .btn {
  width: auto;
  flex: 1;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(217, 112, 96, 0.4);
}

.btn-danger:hover {
  background: rgba(217, 112, 96, 0.12);
}

.detalle-actions {
  margin-bottom: 16px;
}

.page-title .badge {
  margin-left: 10px;
}

.historial-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.historial-item {
  position: relative;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}

.historial-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.historial-item .historial-transicion {
  font-size: 0.9rem;
  color: var(--text);
}

.historial-item .historial-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.historial-item .historial-nota {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* Modal de confirmación (eliminar) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade-in 0.15s ease;
}

/* display:flex de arriba anula el display:none que el navegador aplica por
   defecto al atributo [hidden] (una regla de autor gana sobre la del
   user-agent aunque tengan la misma especificidad); sin esto el modal se
   ve siempre, ignorando `hidden`. */
.modal-overlay[hidden] {
  display: none;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
}

.modal-card h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

/* --- Popup de día del calendario --- */

.cal-day {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.cal-day-nota-flag {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
  line-height: 1;
}

.modal-card-dia {
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.dia-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dia-modal-header h2 {
  font-size: 1.1rem;
  text-transform: capitalize;
  margin: 0;
}

.dia-modal-body {
  overflow-y: auto;
  margin: 0 -20px;
  padding: 0 20px;
}

.dia-modal-body p {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 24px 0;
}

.dia-modal-nota {
  border-top: 1px solid var(--border);
  margin: 12px -20px 0;
  padding: 16px 20px 0;
}

.dia-modal-nota label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.dia-modal-nota textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  resize: vertical;
}

.dia-modal-nota .btn-row {
  margin-top: 10px;
  align-items: center;
}

.dia-modal-nota .nota-guardado {
  font-size: 0.8rem;
  color: var(--success);
  flex: none;
}

.dia-modal-servicio {
  display: block;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
}

.dia-modal-servicio:last-child {
  border-bottom: none;
}

.dia-modal-servicio .row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.dia-modal-servicio .row-top-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dia-modal-servicio .hora {
  font-size: 0.85rem;
}

.dia-modal-servicio .ruta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.dia-modal-servicio .ruta .arrow {
  margin: 0 6px;
  color: var(--text-muted);
}

.dia-modal-servicio .cliente {
  font-size: 0.9rem;
}

/* --- Índice de Recursos --- */

.recursos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 720px) {
  .recursos-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.recurso-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: border-color 0.15s ease;
}

.recurso-card:hover {
  border-color: var(--gold);
}

.recurso-icon {
  font-size: 2rem;
}

.recurso-label {
  font-size: 0.9rem;
  font-weight: 500;
}

/* --- Catálogos simples de Recursos (listas + alta/edición admin) --- */

.catalogo-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.catalogo-item.inactivo {
  opacity: 0.55;
}

.catalogo-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.catalogo-item-nombre {
  font-weight: 600;
}

.catalogo-item-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.catalogo-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.catalogo-item-actions .icon-btn {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}

.catalogo-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aviso-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.aviso-badge.caducado {
  background: rgba(217, 112, 96, 0.15);
  color: var(--danger);
}

.aviso-badge.proximo {
  background: rgba(207, 154, 74, 0.18);
  color: var(--warning);
}

/* --- Histórico --- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
}

.stat-card .stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--gold-light);
}

.stat-card.alerta .stat-value {
  color: var(--danger);
}

.desglose-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.desglose-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.desglose-row:last-child {
  border-bottom: none;
}

.desglose-row .valor {
  font-family: var(--font-mono);
  color: var(--gold-light);
}

.chart-wrap {
  position: relative;
  height: 220px;
}

.tabs-nav {
  margin-bottom: 16px;
}

.tabla-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tabla-historico {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  white-space: nowrap;
}

.tabla-historico th,
.tabla-historico td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.tabla-historico th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tabla-historico tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.tabla-historico tbody tr:hover {
  background: var(--surface-hover);
}

.tabla-historico tbody tr:last-child td {
  border-bottom: none;
}

.tabla-historico .mono {
  color: var(--gold-light);
}

.paginacion {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Página pública de verificación (/verificar/:id) --- */

.verificacion-container {
  padding-top: 24px;
  padding-bottom: 48px;
  max-width: 560px;
}

.verificacion-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(127, 174, 108, 0.15);
  color: var(--success);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.verificacion-container h1 {
  font-size: 1.6rem;
  margin-bottom: 2px;
}

.verificacion-container .form-section p {
  margin: 6px 0;
  font-size: 0.95rem;
}

.verificacion-lista {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 0.95rem;
}

.verificacion-lista li {
  margin: 4px 0;
  color: var(--text);
}

.verificacion-lista li::marker {
  color: var(--gold);
}

.verificacion-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 16px;
}

/* Legible en papel/impresión: fondo blanco, texto negro, sin chrome de app. */
@media print {
  body {
    background: #ffffff;
    color: #000000;
  }
  .app-header,
  .verificacion-badge,
  a.btn {
    display: none;
  }
  .form-section {
    background: #ffffff;
    border: 1px solid #999999;
  }
  .form-section h2,
  .verificacion-container h1 {
    color: #000000;
  }
  .hint,
  .verificacion-footer {
    color: #333333;
  }
}
