/* ============================================================================
   dashboard - estructura de la replica original (replicador-web-integral/dashboard/replica-test)
   re-pintada con la paleta de Vector GPS
   ============================================================================ */
:root{
  --wire-paper:#ffffff;
  --wire-ink:#26313d;
  --wire-dark:#26313d;
  --wire-mid:#bfcbd6;
  --wire-line:#bfcbd6;
  --wire-soft-line:#cfd9e2;
  --wire-muted:#f4f7f9;
  --wire-soft:#f4f7f9;
  --wire-selected:#cfd9e2;
}
*{box-sizing:border-box;border-radius:0}
[hidden]{display:none!important}
html,body{width:100%;height:100%;min-width:320px;margin:0;color:var(--wire-ink);background:var(--wire-soft);font:14px/1.35 Roboto,Arial,sans-serif}
body{overflow:hidden}
button,input,select{color:inherit;background:var(--wire-paper);border:1px solid #bfcbd6;font:inherit}
button{min-height:32px;padding:5px 10px;cursor:pointer}
button:hover:not(:disabled){background:var(--wire-muted)}
button:disabled{color:var(--wire-line);cursor:not-allowed}
button:focus-visible,input:focus-visible,select:focus-visible,canvas:focus-visible{outline:2px solid #bfcbd6;outline-offset:2px}
#dashboardApp{position:relative;width:100%;height:100%}
#dashboardLayout{display:grid;grid-template-columns:220px minmax(0,1fr);width:100%;height:100%}
#filterPanel{min-width:0;padding-top:54px;border-right:1px solid var(--wire-line);background:var(--wire-paper);overflow:auto}
#categoryNav{margin:0 14px 24px;border:1px solid #bfcbd6}
.category-button{display:grid;grid-template-columns:46px minmax(0,1fr) auto;align-items:center;width:100%;min-height:52px;padding:0;text-align:left;border:0;border-bottom:1px solid #bfcbd6}
.category-button:last-child{border-bottom:0}
.category-button.active{background:var(--wire-selected);font-weight:700}
.category-icon{display:grid;place-items:center;align-self:stretch;border-right:1px solid #bfcbd6;font-size:18px}
.badge{min-width:25px;margin-right:6px;padding:3px 6px;border:1px solid #bfcbd6;text-align:center;font-size:12px}
.group-filter{margin:0 14px}
.group-filter label{display:block;margin-bottom:5px;font-weight:700}
.group-multiselect{position:relative;margin-bottom:8px}
#groupToggle{width:100%;min-height:34px;padding-right:28px;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}
#groupToggle::after{position:absolute;right:10px;content:'▾'}
.group-popup{position:relative;z-index:12;top:-1px;width:100%;padding:6px;border:1px solid #bfcbd6;background:var(--wire-paper)}
#groupSearch{width:100%;min-height:30px;margin-bottom:5px;padding:4px 6px}
#groupChoices{max-height:132px;overflow:auto;border-top:1px solid var(--wire-soft-line)}
#groupChoices label{display:flex;align-items:center;gap:6px;min-height:30px;margin:0;padding:4px 2px;font-weight:400;cursor:pointer}
#groupChoices label:hover,#groupChoices label:focus-within{background:var(--wire-muted)}
#groupChoices input{margin:0}
#groupHelp{margin:5px 0 8px;color:var(--wire-dark);font-size:12px}
#filterGroups{width:100%;border-width:2px;font-weight:700}
#contentPanel{min-width:0;height:100%;padding:16px;overflow:auto}
.box{width:100%;margin:0 0 18px;border:1px solid var(--wire-line);background:var(--wire-paper)}
.box-header{min-height:44px;padding:9px 12px;border-bottom:1px solid var(--wire-line);background:var(--wire-muted)}
.box-header h1,.box-header h2{margin:0;font-size:18px;font-weight:600}
.box-content{padding:12px}
#chartCarousel{display:grid;grid-template-columns:42px minmax(0,1fr) 42px;align-items:stretch;min-height:480px}
.carousel-control{align-self:center;width:36px;min-width:36px;height:64px;padding:0;border:1px solid #bfcbd6;font-size:32px}
#chartStage{position:relative;min-width:0;min-height:460px}
#dashboardChart{display:block;width:100%;height:460px}
.chart-tooltip{position:absolute;z-index:3;max-width:260px;padding:6px 8px;border:1px solid #bfcbd6;background:var(--wire-paper);pointer-events:none;white-space:nowrap}
.no-information{display:grid;place-items:center;min-height:440px;margin:0;padding:20px;text-align:center;border:1px dashed var(--wire-line);font-weight:700}
.chart-legend{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;min-height:26px;margin-top:4px}
.legend-item{display:inline-flex;align-items:center;gap:5px}
.legend-swatch{display:inline-block;width:20px;height:12px;border:2px solid #bfcbd6;background:var(--wire-paper)}
.legend-swatch.pattern-1{background:var(--wire-mid)}
#carouselIndicators{display:flex;justify-content:center;gap:6px;margin:8px 0 0;padding:0;list-style:none}
#carouselIndicators button{width:14px;min-width:14px;height:14px;min-height:14px;padding:0;border:1px solid #bfcbd6}
#carouselIndicators button[aria-current="true"]{background:var(--wire-dark)}
.detail-header{display:flex;align-items:center;justify-content:space-between;gap:10px}
.header-actions{display:flex;flex-wrap:wrap;gap:5px}
#closeDetail{width:32px;min-width:32px;padding:0;font-size:20px}
.table-toolbar{display:flex;align-items:center;gap:7px;margin-bottom:8px}
#detailSearch{width:min(260px,45%);min-height:30px;padding:4px 6px}
#detailInfo{margin-left:auto}
.table-scroll{width:100%;overflow:auto}
table{width:100%;min-width:680px;border-collapse:collapse}
th,td{padding:7px 8px;border:1px solid var(--wire-line);text-align:left;white-space:nowrap}
th{background:var(--wire-muted)}
tbody tr:nth-child(even){background:var(--wire-soft)}
tbody tr[data-unit-id]{cursor:pointer}
tbody tr[data-unit-id]:hover{background:var(--wire-selected)}
.pager{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:5px;margin-top:9px}
#pageStatus{min-width:90px;text-align:center}
dialog{width:min(760px,calc(100% - 24px));max-height:calc(100% - 24px);padding:0;border:2px solid #bfcbd6;background:var(--wire-paper)}
dialog::backdrop{background:rgba(0,0,0,.28)}
dialog header{display:flex;align-items:center;justify-content:space-between;padding:9px 12px;border-bottom:1px solid var(--wire-line);background:var(--wire-muted)}
dialog h2{margin:0;font-size:18px}
dialog header button{width:32px;min-width:32px;padding:0;font-size:20px}
dialog>.table-scroll,dialog>dl{margin:12px;width:calc(100% - 24px)}
dialog footer{display:flex;justify-content:flex-end;gap:5px;padding:9px 12px;border-top:1px solid var(--wire-line)}
#averagesContent{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 14px}
#averagesContent dt{font-weight:700}
#averagesContent dd{margin:0}
.full-state{position:absolute;z-index:20;inset:0;display:grid;place-content:center;justify-items:center;background:var(--wire-paper)}
.full-state h1,.full-state p{margin:8px;text-align:center}
.spinner{width:70px;height:70px;border:7px solid var(--wire-soft-line);border-top-color:#bfcbd6;animation:spin 1s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@media(prefers-reduced-motion:reduce){.spinner{animation:none}}
@media(max-width:850px){
  body{height:auto;min-height:100%;overflow-x:hidden;overflow-y:auto}
  #dashboardApp{min-height:100vh}
  #dashboardLayout{grid-template-columns:minmax(0,1fr);height:auto}
  #filterPanel{padding:12px;border-right:0;border-bottom:1px solid var(--wire-line);overflow:visible}
  #categoryNav{display:grid;grid-template-columns:1fr 1fr;margin:0 0 12px}
  .category-button{border:1px solid #bfcbd6}
  .group-filter{margin:0}
  #groupChoices{max-height:105px}
  #contentPanel{height:auto;padding:12px;overflow:visible}
}
@media(max-width:560px){
  #categoryNav{grid-template-columns:1fr}
  #chartCarousel{grid-template-columns:34px minmax(0,1fr) 34px;min-height:380px}
  .carousel-control{width:30px;min-width:30px}
  #chartStage{min-height:360px}
  #dashboardChart{height:360px}
  .detail-header,.table-toolbar{align-items:stretch;flex-direction:column}
  #detailSearch{width:100%}
  #detailInfo{margin-left:0}
  .header-actions{width:100%}
  .header-actions button:not(#closeDetail){flex:1}
}

/* ============================================================================
   Capa Vector GPS (colores, bordes y estados) - no altera el layout original
   Referencia: GUIA_ESTILOS_UI.md
   ============================================================================ */
:root {
  --v-primary: #0f8995; --v-primary-border: #0d7d88; --v-primary-dark: #0a6670;
  --v-primary-tint: #e6f4f5; --v-primary-ring: rgba(15, 137, 149, .18);
  --v-danger: #dc3545; --v-danger-dark: #bd2130; --v-success: #28a745; --v-success-dark: #1e8a37;
  --v-text: #26313d; --v-title: #1f2a35; --v-muted: #607080; --v-label: #485664;
  --v-border: #cfd9e2; --v-input-border: #bfcbd6; --v-th-bg: #f4f7f9; --v-input-bg: #f9fbfc;
  --v-shadow-pop: 0 12px 24px rgba(26, 36, 44, .22);
}

html, body { font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif; color: var(--v-text); }
a { color: var(--v-primary); }
h1, h2, h3 { color: var(--v-title); }

button {
  border-color: var(--v-input-border);
  border-radius: 6px;
  background-color: #fff;
  color: var(--v-label);
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
button:hover:not(:disabled) { color: var(--v-primary); border-color: var(--v-primary); background-color: var(--v-primary-tint); }
button:disabled { opacity: .5; color: #9aa6b2; background-color: #f4f7f9; border-color: #d8e0e6; cursor: not-allowed; }

button:is([id*="save" i],[id*="create" i],[id*="crear" i],[id*="guardar" i],[id*="accept" i],[id*="aceptar" i],[id*="apply" i],[id*="send" i],[id*="enviar" i],[id*="agregar" i],[id*="add" i],[id*="submit" i],[id*="filter" i]):not(:disabled) { color: #fff; background-color: var(--v-primary); border-color: var(--v-primary-border); }
button:is([id*="save" i],[id*="create" i],[id*="crear" i],[id*="guardar" i],[id*="accept" i],[id*="aceptar" i],[id*="apply" i],[id*="send" i],[id*="enviar" i],[id*="agregar" i],[id*="add" i],[id*="submit" i],[id*="filter" i]):hover:not(:disabled) { color: #fff; background-color: var(--v-primary-dark); border-color: var(--v-primary-dark); }

button:is([id*="edit" i],[id*="editar" i]):not(:disabled) { color: var(--v-primary); border-color: var(--v-primary); }

button:is([id*="delete" i],[id*="remove" i],[id*="borrar" i],[id*="eliminar" i]):not(:disabled) { color: var(--v-danger); border-color: #e3a0a8; background-color: #fff5f6; }
button:is([id*="delete" i],[id*="remove" i],[id*="borrar" i],[id*="eliminar" i]):hover:not(:disabled) { color: #fff; border-color: var(--v-danger); background-color: var(--v-danger); }

button:is([id*="excel" i],[id*="download" i],[id*="export" i],[id*="csv" i],[id*="descargar" i]):not(:disabled) { color: #fff; background-color: var(--v-success); border-color: var(--v-success); }
button:is([id*="excel" i],[id*="download" i],[id*="export" i],[id*="csv" i],[id*="descargar" i]):hover:not(:disabled) { color: #fff; background-color: var(--v-success-dark); border-color: var(--v-success-dark); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible, [role="row"]:focus-visible {
  outline: 2px solid var(--v-primary);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), select, textarea {
  border-color: var(--v-input-border);
  border-radius: 6px;
  background-color: var(--v-input-bg);
  color: var(--v-text);
}
input:not([type="checkbox"]):not([type="radio"]):focus, select:focus, textarea:focus { border-color: var(--v-primary); box-shadow: 0 0 0 3px var(--v-primary-ring); }
input:disabled, select:disabled, textarea:disabled { color: #8a97a4; background-color: #f1f4f6; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--v-primary); }

fieldset { border-color: var(--v-border); border-radius: 8px; }
legend { color: var(--v-primary); font-weight: 700; }

th, [role="columnheader"] { background-color: var(--v-th-bg); color: #536171; font-weight: 700; }

tr[aria-selected="true"], [role="row"][aria-selected="true"], [role="option"][aria-selected="true"], tr.selected, [role="row"].selected,
[class*="row"].selected, [class*="item"].selected, [class*="row"][aria-selected="true"], [class*="item"][aria-selected="true"] {
  background-color: var(--v-primary-tint);
  box-shadow: inset 4px 0 0 var(--v-primary);
  outline: none;
}
tbody tr:hover, [role="grid"] [role="row"]:hover { background-color: rgba(15, 137, 149, .07); }
tr[aria-selected="true"]:hover, tr.selected:hover, [role="row"][aria-selected="true"]:hover { background-color: var(--v-primary-tint); }

dialog {
  border: 1px solid var(--v-border);
  border-top: 4px solid var(--v-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--v-text);
  box-shadow: var(--v-shadow-pop);
}
dialog:not([open]) { display: none !important; }
dialog::backdrop { background: rgba(26, 36, 44, .5); }

/* Botones dentro de encabezados de tabla: sin caja */
th button, [role="columnheader"] button { background-color: transparent; border-color: transparent; box-shadow: none; color: inherit; }
th button:hover:not(:disabled), [role="columnheader"] button:hover:not(:disabled) { background-color: rgba(15, 137, 149, .10); border-color: transparent; color: var(--v-primary); }
/* Leyenda de gráficas: mismos colores que el canvas */
.legend-swatch { background: #0f8995; border-color: #0d7d88; }
.legend-swatch.pattern-1 { background: #90caf9; border-color: #2196f3; }

/* Estado activo / seleccionado en botones (pestañas, filtros, categorías) */
button[aria-pressed="true"]:not(:disabled), button[aria-selected="true"]:not(:disabled), button.active:not(:disabled), button.selected:not(:disabled) {
  color: var(--v-primary-dark); background-color: var(--v-primary-tint); border-color: var(--v-primary); box-shadow: none;
}

/* v2: dialogos al nivel de Alertas */
html, body { background: #eef2f5; }
/* Diálogos con encabezado */
dialog { padding: 0 0 14px !important; overflow: auto; }
dialog > :not(header):not(h1:first-child):not(h2:first-child) { margin-left: 16px; margin-right: 16px; }
dialog > header, dialog > h1:first-child, dialog > h2:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 12px !important;
  padding: 9px 14px !important;
  font: 700 13px/1.45 Roboto, Arial, sans-serif !important;
  color: #fff !important;
  background: #343a40 !important;
  border: 0 !important;
  border-bottom: 3px solid var(--v-primary) !important;
}
dialog > header h2, dialog > header h1 { margin: 0 !important; padding: 0 !important; font: 700 13px/1.45 Roboto, Arial, sans-serif !important; color: #fff !important; background: transparent !important; border: 0 !important; }
dialog > header button { min-height: 26px; padding: 0 9px; color: #fff; background: transparent; border-color: rgba(255, 255, 255, .4); }
dialog > header button:hover:not(:disabled) { color: #fff; background: rgba(255, 255, 255, .16); border-color: #fff; }
dialog[id*="confirm" i] { border-top-color: var(--v-danger); }
dialog[id*="confirm" i] > h1:first-child, dialog[id*="confirm" i] > h2:first-child, dialog[id*="confirm" i] > header { border-bottom-color: var(--v-danger); }

/* v2: bandas de panel */
.box-header, .box-header h1, .box-header h2, .box-header span {
  color: #fff !important;
}
.box-header {
  background: #343a40 !important;
  border-bottom: 3px solid var(--v-primary) !important;
  border-top: 0 !important;
}

/* v3: tablas a ancho completo del contenedor */
table { width: 100%; }