/* CRC Órdenes — hoja de estilo corporativa.
   El azul procede del logotipo de CRC Obras y Servicios (#153873). */

:root {
  --crc-azul:        #153873;
  --crc-azul-claro:  #1f4e9e;
  --crc-azul-suave:  #e8eef8;
  --crc-gris:        #9a9a9a;

  --pendiente:  #64748b;
  --asignada:   #15803d;
  --exportada:  #1d4ed8;
  --vencida:    #c2410c;
  --prioritaria:#b91c1c;
  --aprox:      #a16207;

  --fondo:      #f1f4f9;
  --panel:      #ffffff;
  --borde:      #d8dfea;
  --texto:      #16213a;
  --texto-tenue:#5b6880;

  --sombra:     0 1px 2px rgba(21, 56, 115, .08), 0 4px 16px rgba(21, 56, 115, .06);
  --radio:      10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--texto);
  background: var(--fondo);
}

a { color: var(--crc-azul-claro); }

/* ─────────────── Acceso ─────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 600px at 15% -10%, #26508f 0%, transparent 60%),
    linear-gradient(160deg, #0f2a57 0%, var(--crc-azul) 45%, #0c204a 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 24px 60px rgba(4, 16, 40, .45);
}

.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo img { width: 190px; max-width: 70%; height: auto; }
.login-logo h1 {
  font-size: 19px;
  margin: 16px 0 4px;
  color: var(--crc-azul);
  letter-spacing: .2px;
}
.login-logo p { margin: 0; color: var(--texto-tenue); font-size: 13px; }

/* El logotipo trae el texto en blanco sobre fondo transparente: sobre la
   tarjeta clara necesita su propio fondo oscuro para leerse. */
.login-logo .marca {
  background: var(--crc-azul);
  border-radius: 10px;
  padding: 14px 18px;
  display: inline-block;
}

/* ─────────────── Formularios ─────────────── */

label.campo {
  display: block;
  font-weight: 600;
  font-size: 12.5px;
  margin-bottom: 6px;
  color: var(--texto-tenue);
}

input[type="text"], input[type="password"], input[type="search"],
input[type="date"], input[type="email"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  font: inherit;
  color: var(--texto);
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(31, 78, 158, .35);
  outline-offset: 1px;
  border-color: var(--crc-azul-claro);
}

.campo-grupo { margin-bottom: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--crc-azul);
  color: #fff;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--crc-azul-claro); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-sec   { background: #fff; color: var(--crc-azul); border-color: var(--borde); }
.btn-sec:hover:not(:disabled) { background: var(--crc-azul-suave); }
.btn-peli  { background: #b91c1c; }
.btn-peli:hover:not(:disabled) { background: #991b1b; }
.btn-ok    { background: var(--asignada); }
.btn-ok:hover:not(:disabled) { background: #166534; }
.btn-sm    { padding: 5px 10px; font-size: 12.5px; }
.btn-ancho { width: 100%; padding: 11px; font-size: 15px; }

.alerta {
  padding: 10px 13px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  border: 1px solid;
}
.alerta-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alerta-ok    { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alerta-info  { background: var(--crc-azul-suave); border-color: #c7d7f0; color: #1e3a73; }
.alerta-aviso { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.oculto { display: none !important; }

/* ─────────────── Estructura general ─────────────── */

.app { display: flex; flex-direction: column; height: 100vh; }

.barra {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  height: 54px;
  background: var(--crc-azul);
  color: #fff;
  flex-shrink: 0;
}
.barra img { height: 30px; width: auto; }
.barra .titulo { font-weight: 600; font-size: 15px; letter-spacing: .2px; }
.barra nav { display: flex; gap: 2px; margin-left: 10px; }
.barra nav a {
  color: #d8e2f4;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 7px;
  font-weight: 500;
  font-size: 13.5px;
}
.barra nav a:hover  { background: rgba(255,255,255,.12); color: #fff; }
.barra nav a.activo { background: rgba(255,255,255,.2); color: #fff; }
.barra .usuario {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #cfdcf2;
}
.barra .usuario a { color: #fff; text-decoration: none; opacity: .85; }
.barra .usuario a:hover { opacity: 1; text-decoration: underline; }

.contenido { flex: 1; overflow: auto; padding: 20px; }
.contenido-ancho { max-width: 1180px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  margin-bottom: 18px;
}
.panel-cab {
  padding: 13px 18px;
  border-bottom: 1px solid var(--borde);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-cab h2 { margin: 0; font-size: 15px; }
.panel-cuerpo { padding: 18px; }

/* ─────────────── Tablas ─────────────── */

table.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tabla th {
  text-align: left;
  padding: 9px 10px;
  background: #f7f9fc;
  border-bottom: 2px solid var(--borde);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
  color: var(--texto-tenue);
  white-space: nowrap;
}
table.tabla td { padding: 9px 10px; border-bottom: 1px solid #eef2f8; }
table.tabla tbody tr:hover { background: #f8fafd; }
table.tabla td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─────────────── Distintivos ─────────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.7;
  white-space: nowrap;
}
.chip-pendiente  { background: #eef1f6; color: var(--pendiente); }
.chip-asignada   { background: #dcfce7; color: #14532d; }
.chip-exportada  { background: #dbeafe; color: #1e3a8a; }
.chip-vencida    { background: #ffedd5; color: #9a3412; }
.chip-prioritaria{ background: #fee2e2; color: #991b1b; }
.chip-aprox      { background: #fef9c3; color: #854d0e; }
.chip-origen     { background: var(--crc-azul-suave); color: var(--crc-azul); }

.punto { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ─────────────── Indicadores ─────────────── */

.indicadores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.indicador {
  background: var(--panel);
  border: 1px solid var(--borde);
  border-left: 4px solid var(--crc-azul);
  border-radius: var(--radio);
  padding: 12px 14px;
  box-shadow: var(--sombra);
}
.indicador .valor { font-size: 24px; font-weight: 700; line-height: 1.15; }
.indicador .etiqueta {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--texto-tenue);
  margin-top: 2px;
}
.indicador.es-pendiente   { border-left-color: var(--pendiente); }
.indicador.es-asignada    { border-left-color: var(--asignada); }
.indicador.es-exportada   { border-left-color: var(--exportada); }
.indicador.es-vencida     { border-left-color: var(--vencida); }
.indicador.es-prioritaria { border-left-color: var(--prioritaria); }
.indicador.es-aprox       { border-left-color: var(--aprox); }

/* ─────────────── Ventanas modales ─────────────── */

.modal-fondo {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 50, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 2000;
}
.modal {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(4, 16, 40, .4);
}
.modal-cab {
  padding: 16px 20px;
  border-bottom: 1px solid var(--borde);
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-cab h3 { margin: 0; font-size: 16px; }
.modal-cab .cerrar {
  margin-left: auto;
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--texto-tenue);
  padding: 0 4px;
}
.modal-cuerpo { padding: 20px; overflow: auto; }
.modal-pie {
  padding: 14px 20px;
  border-top: 1px solid var(--borde);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.texto-tenue { color: var(--texto-tenue); }
.texto-sm    { font-size: 12.5px; }
.mt-2 { margin-top: 10px; }  .mt-3 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }  .mb-2 { margin-bottom: 10px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 10px; }
.entre { justify-content: space-between; }
.centro-v { align-items: center; }
.crece { flex: 1; }
.envuelve { flex-wrap: wrap; }

/* ─────────────── Mapa del dispatcher ─────────────── */

.mapa-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.lateral {
  width: 310px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lateral-dcha { border-right: 0; border-left: 1px solid var(--borde); width: 350px; }

.lateral-cab {
  padding: 11px 14px;
  border-bottom: 1px solid var(--borde);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f7f9fc;
  flex-shrink: 0;
}
.lateral-cuerpo { overflow-y: auto; padding: 14px; flex: 1; min-height: 0; }
.lateral-pie {
  border-top: 1px solid var(--borde);
  padding: 12px 14px;
  background: #f7f9fc;
  flex-shrink: 0;
}

.mapa-zona { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }

/* La caja del mapa es a su vez contenedor flex: si no lo fuera, #map no
   heredaría altura y Leaflet se quedaría con 0 px. */
.mapa-caja { position: relative; flex: 1; min-height: 0; display: flex; }
#map { flex: 1; min-width: 0; min-height: 0; background: #dfe6ef; }

.mapa-herramientas {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--borde);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.recuento {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12.5px;
  color: var(--texto-tenue);
  padding-right: 12px;
  border-right: 1px solid var(--borde);
}
.recuento strong { font-size: 16px; color: var(--texto); font-variant-numeric: tabular-nums; }

/* ─────────────── Filtros ─────────────── */

.filtro-bloque { margin-bottom: 16px; }
.filtro-bloque > h4 {
  margin: 0 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--texto-tenue);
  font-weight: 700;
}

.opcion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.opcion:hover { background: var(--crc-azul-suave); }
.opcion input { margin: 0; flex-shrink: 0; width: auto; }
.opcion .n {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--texto-tenue);
  font-variant-numeric: tabular-nums;
}
.opcion .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lista-scroll {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 4px;
}

/* ─────────────── Órdenes en la lista ─────────────── */

.orden-item {
  border: 1px solid var(--borde);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 8px;
  cursor: pointer;
  background: #fff;
  transition: box-shadow .12s, border-color .12s;
}
.orden-item:hover { box-shadow: var(--sombra); }
.orden-item.elegida {
  border-color: var(--crc-azul-claro);
  border-left-color: var(--crc-azul-claro);
  background: var(--crc-azul-suave);
}
.orden-item .cab {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 3px;
}
.orden-item .num { font-weight: 700; font-size: 13px; }
.orden-item .meta { font-size: 11.5px; color: var(--texto-tenue); line-height: 1.5; }
.orden-item .distintivos { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }

/* ─────────────── Marcadores ─────────────── */

.marcador {
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  position: relative;
}
.marcador.es-vencida   { border-color: var(--vencida); border-width: 3px; }
.marcador.es-elegida {
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--crc-azul-claro);
  z-index: 1000 !important;
}
.marcador .aviso {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--prioritaria);
  border: 1.5px solid #fff;
  font-size: 9px;
  line-height: 10px;
  text-align: center;
}

.leyenda {
  background: rgba(255,255,255,.96);
  padding: 9px 11px;
  border-radius: 8px;
  box-shadow: var(--sombra);
  font-size: 11.5px;
  line-height: 1.9;
  border: 1px solid var(--borde);
}
.leyenda b { display: block; margin-bottom: 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--texto-tenue); }
.leyenda .fila { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
.leyenda .punto-g { width: 12px; height: 12px; }

.popup-orden { font-size: 13px; min-width: 240px; }
.popup-orden h4 { margin: 0 0 7px; font-size: 14px; color: var(--crc-azul); }
.popup-orden dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; }
.popup-orden dt { color: var(--texto-tenue); font-size: 11.5px; }
.popup-orden dd { margin: 0; font-size: 12.5px; }
.popup-orden .acciones { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }

.cargando {
  position: absolute;
  inset: 0;
  background: rgba(241,244,249,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  font-weight: 600;
  color: var(--crc-azul);
}

/* Durante la selección por recuadro el cursor avisa del modo activo. */
.modo-recuadro .leaflet-container { cursor: crosshair; }

@media (max-width: 1100px) {
  .lateral      { width: 270px; }
  .lateral-dcha { width: 290px; }
}
