/*
 * css/views/dynamic-query.css — Util > Dynamic Query (js/views/dynamic-query.js).
 * 6-nov, pedido del usuario: panel izquierdo de filtros + derecha con resumen, mapa y tabla. Prefijo dq- en todo; los
 * colores salen de los tokens de css/base.css (los del mapa los pone deck.gl: azul en movimiento, rojo detenido).
 */
#dq-root { min-width: 0; }
/* 20-nov, pedido del usuario: el panel izquierdo de Dynamic Query pegado al menú del sistema (abierto o contraído).
   .wrap centra el contenido en 1440 px con márgenes de hasta 32 px; en esta página (mapa) usa todo el ancho y 12 px. */
.wrap:has(> #tab-util-dynamic-query:not([hidden])) { max-width: none; margin: 0; padding-left: 12px; padding-right: 16px; }
.dq-layout { display: grid; grid-template-columns: minmax(260px, 320px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .dq-layout { grid-template-columns: minmax(0, 1fr); } }

.dq-left { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border);
           border-radius: var(--radius); padding: 12px 14px; position: sticky; top: 8px; }
.dq-field { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; color: var(--text-dim); }
.dq-field span { font-weight: 600; color: var(--text); }
.dq-left input, .dq-left select { font: inherit; font-size: .85rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; min-height: 32px; width: 100%; box-sizing: border-box; }
.dq-left input[type="checkbox"] { width: auto; min-height: 0; }
.dq-two { display: grid; grid-template-columns: 1fr; gap: 8px; }
.dq-check { display: flex; align-items: center; gap: 8px; font-size: .82rem; }
.fsel-bar.dq-fsel { flex-direction: column; align-items: stretch; gap: 4px; margin: 0; padding: 0; }
.dq-fsel .msel { flex: 0 0 auto; width: 100%; max-width: none; }   /* en columna, el flex 1 1 320px de .fsel-bar sería alto */
.dq-adv summary, .dq-sql summary { cursor: pointer; font-weight: 600; font-size: .85rem; padding: 4px 0; }
/* 6-nov: consulta expuesta (SQL para la consola de BigQuery) */
.dq-period { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }   /* 6-nov: botonera de período */
#dq-sql-body { display: flex; flex-direction: column; gap: 6px; padding-top: 6px; }
.dq-sql-pre { margin: 0; max-height: 320px; overflow: auto; white-space: pre; font-family: var(--font-mono, ui-monospace, monospace);
  font-size: .72rem; line-height: 1.35; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.dq-sql-tools { display: flex; align-items: center; gap: 10px; }
.dq-small-link { font-size: .78rem; }
#dq-adv-body { display: flex; flex-direction: column; gap: 8px; padding-top: 6px; }
.dq-run { width: 100%; }
.dq-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dq-small { align-self: flex-start; font-size: .78rem; padding: 3px 8px; }
.dq-hint { color: var(--text-dim); font-size: .78rem; }
.dq-err { color: var(--err); font-size: .85rem; }
.dq-warn { color: var(--warn); font-size: .82rem; margin-top: 4px; }

.dq-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* 24-nov: las tarjetas son .mc-tot del kit, fila compacta .mc-compact (css/components/mc.css, color por familia) */
.dq-qparams { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: .8rem; margin: 2px 0 4px; }
.dq-qparams .dq-qp-k { color: var(--text-dim); }
.dq-qparams b { font-variant-numeric: tabular-nums; font-weight: 600; }
.mv-wbtns { display: inline-flex; gap: 6px; }
.mv-wbtns .dq-ic { width: 14px; height: 14px; vertical-align: -2px; }
.dq-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.dq-card-v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dq-card-l { font-size: .78rem; color: var(--text-dim); }
.dq-card-s { font-size: .72rem; color: var(--text-dim); }
.dq-tabs { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dq-spacer { flex: 1; }
.dq-inline { font-size: .82rem; color: var(--text-dim); display: inline-flex; gap: 6px; align-items: center; }
.dq-inline select { font: inherit; font-size: .82rem; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; }
.dq-map { height: 62vh; min-height: 360px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
          background: var(--surface-2); position: relative; }
.dq-map-msg { padding: 24px; color: var(--text-dim); font-size: .85rem; }
.dq-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: .78rem; }
.dq-sw { display: inline-flex; align-items: center; gap: 5px; }
.dq-sw i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dq-picked { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
             padding: 10px 12px; margin-top: 8px; font-size: .8rem; }
.dq-picked dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 6px 0 0; }
.dq-picked dt { color: var(--text-dim); }
.dq-picked dd { margin: 0; overflow-wrap: anywhere; }
.dq-picked > button { float: right; }
.dq-table-wrap { overflow: auto; max-height: 65vh; border: 1px solid var(--border); border-radius: var(--radius); }
.dq-table { border-collapse: collapse; font-size: .78rem; white-space: nowrap; }
.dq-table th, .dq-table td { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.dq-table th { position: sticky; top: 0; background: var(--surface-2); }

/* 22-nov, pedido del usuario: pestañas del panel izquierdo (Datos / Líneas / Puntos / Geocercas) y paneles de capas
   (js/views/dq-layers.js). Colores solo por variables. */
/* 22-nov (2ª vuelta, captura de GeoAGP v2): pestañas de solo ícono; la activa con fondo suave y subrayado de acento */
.dq-ic { width: 18px; height: 18px; flex: none; }
.dq-ltabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -2px 0 4px; }
.dq-ltab { flex: 1 1 0; display: flex; align-items: center; justify-content: center; padding: 9px 4px; cursor: pointer;
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; color: var(--text-dim); }
.dq-ltab:hover { color: var(--text); background: var(--surface-2); }
.dq-ltab.on { color: var(--accent-text); border-bottom-color: var(--accent); background: var(--accent-dim); }
.dq-left-tab { display: flex; flex-direction: column; gap: 10px; }
.dq-left-tab[hidden] { display: none; }
.dq-sec-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
/* Capas: tarjeta "Sincronizar puntos y líneas" (borde de acento + interruptor) y una fila por capa */
.dq-sync { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--accent);
  border-radius: 6px; background: var(--accent-dim); color: var(--accent-text); }
.dq-sync-l { flex: 1 1 auto; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.dq-switch { position: relative; width: 40px; height: 22px; flex: none; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); cursor: pointer; padding: 0; }
.dq-switch span { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-dim);
  transition: left .15s ease; }
.dq-switch.on { background: var(--accent); border-color: var(--accent); }
.dq-switch.on span { left: 20px; background: var(--surface); }
.dq-lrow { display: flex; align-items: center; gap: 8px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.dq-lrow.off .dq-lname, .dq-lrow.off .dq-ldot { opacity: .45; }
.dq-ldot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dq-lname { flex: 1 1 auto; font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.dq-ibtn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0;
  border: 1px solid transparent; border-radius: 6px; background: none; color: var(--accent-text); cursor: pointer; }
.dq-ibtn:hover { background: var(--surface-2); }
.dq-ibtn.on { border-color: var(--accent); background: var(--accent-dim); }
.dq-lrow.off .dq-ibtn:last-child { color: var(--text-dim); }
.dq-lpanel { padding: 10px 4px 12px 22px; border-bottom: 1px solid var(--border); }
.dq-layer { display: flex; flex-direction: column; gap: 10px; font-size: .85rem; }
.dq-slider span { display: flex; justify-content: space-between; }
.dq-left .dq-slider input[type="range"] { padding: 0; min-height: 0; border: none; background: none; accent-color: var(--accent); }
.dq-left input[type="color"] { padding: 2px; min-height: 30px; width: 100%; cursor: pointer; }
/* el selector de color se ve como una muestra con borde y esquinas, no como una barra plana */
.dq-left input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.dq-left input[type="color"]::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 4px; }
.dq-left input[type="color"]::-moz-color-swatch { border: 1px solid var(--border); border-radius: 4px; }
.dq-color { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.dq-color legend { font-weight: 600; font-size: .82rem; padding: 0 4px; }
.dq-vals { display: flex; flex-direction: column; gap: 4px; max-height: 280px; overflow: auto; }
.dq-val { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 6px; font-size: .8rem; }
.dq-left .dq-val input[type="color"] { width: 34px; min-height: 24px; height: 24px; }
.dq-val span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dq-x { font: inherit; font-size: .8rem; cursor: pointer; background: none; border: 1px solid var(--border); border-radius: 4px;
  color: var(--text-dim); padding: 0 6px; min-height: 24px; }
.dq-x:hover { color: var(--text); }
.dq-ranges { display: flex; flex-direction: column; gap: 4px; }
.dq-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 34px auto; gap: 4px; align-items: center; }
.dq-range-h { font-size: .75rem; color: var(--text-dim); }
.dq-left .dq-range input[type="color"] { width: 34px; min-height: 28px; }
.dq-range-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.dq-leg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; width: 100%; }
.dq-leg-name { font-size: .78rem; }
/* 22-nov: pestaña Configuración — muestrario de la paleta predefinida de GeoAGP (100 colores) */
.dq-palette { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.dq-palette i { display: block; aspect-ratio: 1; border-radius: 3px; border: 1px solid var(--border); }
.dq-left .dq-field small { font-weight: 400; }
/* 22-nov: el máximo de valores distintos es un parámetro global (solo lectura aquí) */
.dq-param-val { display: flex; align-items: baseline; gap: 8px; font-size: 1.05rem; }
.dq-param-link { align-self: flex-start; text-decoration: none; display: inline-block; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--text); }
/* 22-nov: configuración preferida del usuario (botón con estrella; rellena = hay una guardada) */
.dq-prefs { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.dq-prefs-save { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; }
.dq-prefs-save .dq-ic { width: 16px; height: 16px; color: var(--warn, #d97706); }
.dq-prefs-row { display: flex; gap: 6px; flex-wrap: wrap; }
/* 22-nov (dq-widgets.js): íconos atenuados (función apagada), listas de campos con ↑↓, y cuadros sobre el mapa
   (vista jerárquica a la izquierda, resumen a la derecha) */
.dq-ibtn-wrap { display: inline-flex; }
.dq-ibtn-wrap.dim .dq-ibtn { opacity: .4; }
.dq-ibtn { width: 26px; height: 26px; }
.dq-ibtn .dq-ic { width: 15px; height: 15px; }
.dq-lrow { gap: 2px; }
.dq-lrow .dq-ldot { margin-right: 6px; }
.dq-sec-title .dq-ic { width: 14px; height: 14px; vertical-align: -2px; }
.dq-flist { display: flex; flex-direction: column; gap: 3px; max-height: 300px; overflow: auto; }
.dq-fitem { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 3px 6px;
  border: 1px solid var(--border); border-radius: 5px; font-size: .8rem; }
.dq-fitem.off { opacity: .55; }
.dq-fitem label { display: flex; align-items: center; gap: 6px; min-width: 0; cursor: pointer; }
.dq-fitem input { width: auto; min-height: 0; }
.dq-fname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dq-fmove { display: flex; gap: 2px; flex: none; }
.dq-fmove .dq-x { min-height: 22px; padding: 0 5px; }
.dq-fmove .dq-x:disabled { opacity: .3; cursor: default; }
.dq-warn-ic { color: var(--warn); }
.dq-map-wrap { position: relative; }
/* 24-nov: los cuadros flotan dentro de esta área (arrastrar por el título, agrandar por la esquina) */
.dq-widgets { position: absolute; inset: 8px 56px 8px 8px; pointer-events: none; }
.dq-wfloat { position: absolute; pointer-events: auto; width: 320px; max-width: 100%; max-height: 100%; z-index: 5; }
.dq-wfloat .dq-whead { cursor: move; touch-action: none; user-select: none; }
.dq-wfloat .dq-whead .dq-x { cursor: pointer; }
.dq-wfloat.dragging { opacity: .92; box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }
.dq-wbox { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); font-size: .78rem; display: flex; flex-direction: column; gap: 4px; }
.dq-whead { display: flex; align-items: center; gap: 6px; }
.dq-whead b { flex: 1 1 auto; text-transform: uppercase; letter-spacing: .03em; font-size: .75rem; }
.dq-whead .dq-ic { width: 14px; height: 14px; color: var(--accent-text); }
.dq-wtotal { font-size: .78rem; }
.dq-tree, .dq-tree ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.dq-tree { padding-left: 0; }
.dq-tree summary { display: flex; align-items: center; gap: 5px; cursor: pointer; padding: 1px 0; }
.dq-tree details.leaf > summary { list-style: none; padding-left: 14px; }
.dq-tree details.leaf > summary::-webkit-details-marker { display: none; }
.dq-tree input { width: auto; min-height: 0; margin: 0; }
.dq-tlabel { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dq-tval { color: var(--text-dim); white-space: nowrap; font-size: .75rem; }
.dq-tsw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; margin-right: 4px; vertical-align: -1px; }
.dq-wsum { width: 100%; border-collapse: collapse; font-size: .75rem; }
.dq-wsum th, .dq-wsum td { padding: 2px 4px; border-bottom: 1px solid var(--border); text-align: left; }
.dq-wsum .num { text-align: right; white-space: nowrap; }
@media (max-width: 720px) { .dq-wfloat { width: min(320px, 100%); } }
.dq-outline { display: grid; grid-template-columns: 1fr 64px; align-items: center; gap: 8px; }   /* 22-nov: color de borde de los puntos */
.dq-left .dq-outline input[type="color"]:disabled { opacity: .35; cursor: default; }

/* 23-nov: filtro "corrida de identidad Wialon" (abierto desde la auditoría de la Tarea automática) */
.dq-identity { border: 1px solid var(--border); border-left: 3px solid #0e7490; border-radius: 6px; padding: 6px 8px;
  margin: 0 0 10px; font-size: 0.8rem; display: flex; flex-direction: column; gap: 2px; }
.dq-identity code { font-size: 0.75rem; }
.dq-identity .link-btn { align-self: flex-start; }

/* 23-nov: Visor de mapa (js/views/map-viewer.js): el mapa de Dynamic Query sin el panel izquierdo */
.mv-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 0 0 10px; font-size: 0.85rem; }
.mv-head code { font-size: 0.8rem; }
.mv-main { min-width: 0; }

/* 24-nov: Desde / Hasta = fecha + hora en 24 h (HH:MM:SS) */
.dq-dt { display: flex; gap: 6px; }
.dq-dt input[type="date"] { flex: 1 1 auto; min-width: 0; }
.dq-dt .dq-time { flex: 0 0 6.2em; font-variant-numeric: tabular-nums; text-align: center; }
.dq-dt .dq-bad { outline: 2px solid var(--danger, #dc2626); }

/* 24-nov: vista jerárquica en tabla (como el Resumen), total en la última fila, cuadros redimensionables con scroll */
.dq-wresize { resize: both; overflow: hidden; display: flex; flex-direction: column; min-width: 220px; min-height: 90px; }
.dq-wscroll { overflow: auto; flex: 1 1 auto; min-height: 0; }
.dq-wsum thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dq-wsum tfoot th { position: sticky; bottom: 0; background: var(--surface); border-top: 2px solid var(--border); border-bottom: 0; }
.dq-wsum tfoot th.num, .dq-wsum thead th.num { text-align: right; }
.dq-ttable td:first-child { white-space: nowrap; }
.dq-ttable tr.off td { color: var(--text-dim); }
.dq-tcell { display: inline-flex; align-items: center; gap: 4px; }
.dq-ttable input { width: auto; min-height: 0; margin: 0; }
.dq-ttog { display: inline-block; width: 14px; flex: none; padding: 0; border: 0; background: none; color: var(--text-dim); cursor: pointer; font-size: .75rem; line-height: 1; }

/* 24-nov: panel izquierdo plegable hacia la izquierda (queda una franja con » para abrirlo) */
.dq-layout { transition: grid-template-columns .2s ease; }
.dq-layout.dq-collapsed { grid-template-columns: 44px minmax(0, 1fr); }
.dq-lcollapse { flex: 0 0 auto; padding: 4px 8px; background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--text-dim); cursor: pointer; font-size: 1rem; line-height: 1; min-height: 0; }
.dq-lcollapse:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.dq-collapsed .dq-left { padding: 6px 4px; align-items: center; }
.dq-collapsed .dq-left > :not(.dq-ltabs), .dq-collapsed .dq-ltab { display: none; }
.dq-collapsed .dq-ltabs { border-bottom: 0; margin: 0; }
@media (max-width: 900px) { .dq-layout.dq-collapsed { grid-template-columns: minmax(0, 1fr); } .dq-collapsed .dq-left { align-items: flex-start; } }
/* sin alto elegido por el usuario: a lo sumo 60 % del mapa (con alto elegido, hasta el 100 %) */
.dq-wfloat:not([style*="height"]) { max-height: 60%; }
/* 24-nov: Resumen ordenable (▲ ▼ ↺ como Bitácora / Unidades) */
.dq-ssort .dq-sth { display: flex; align-items: center; gap: 4px; justify-content: space-between; }
.dq-ssort th.num .dq-sth { justify-content: flex-end; }
.dq-ssort .bita-sort { padding: 0 2px; font-size: .62rem; min-height: 0; line-height: 1.2; }
