*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* ── API health banner ───────────────────────────────────────────── */
#api-health-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 10px 20px;
  background: #b71c1c; color: #fff; font-size: .9rem; font-weight: 500;
}
#api-health-retry {
  padding: 4px 14px; border: 1px solid rgba(255,255,255,.6); border-radius: 4px;
  background: transparent; color: #fff; cursor: pointer; font-size: .85rem;
  white-space: nowrap;
}
#api-health-retry:hover { background: rgba(255,255,255,.15); }

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f4f6f9;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════════════════════ */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}

#login-box {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 32px rgba(0,0,0,.25);
  padding: 40px 48px;
  width: 380px;
  text-align: center;
}

.login-logo {
  margin-bottom: 20px;
}

.login-logo-img {
  height: 48px;
  width: auto;
  filter: contrast(3) brightness(0.5);
}

.login-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e2a3a;
  margin: 0 0 28px;
}

#login-version-info {
  margin-top: 20px;
  font-size: .72rem;
  color: #aaa;
  letter-spacing: .02em;
}

/* ═══════════════════════════════════════════════════════════
   APP SHELL — flex column, full viewport
═══════════════════════════════════════════════════════════ */
#app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════════════ */
#app-header {
  height: 52px;
  background: #1a2535;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 0;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
  z-index: 200;
  position: relative;
}

.hdr-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hdr-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hdr-logo-img {
  height: 28px;
  width: auto;
}

.hdr-titles {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.hdr-brand {
  font-size: 22px;
  font-weight: 700;
  color: #e8f0fe;
  letter-spacing: .3px;
  white-space: nowrap;
}

.hdr-titles-sep {
  color: #3d5470;
  font-weight: 300;
  font-size: 22px;
}

.hdr-client {
  font-size: 22px;
  color: #7eb8ff;
  font-weight: 600;
  white-space: nowrap;
}

.hdr-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Alarm badge ─────────────────────────────────────── */
#alarm-badge-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid #3d5470;
  border-radius: 16px;
  padding: 4px 10px;
  color: #cdd5e0;
  cursor: pointer;
  font-size: .85rem;
  transition: background .15s;
  white-space: nowrap;
}
#alarm-badge-btn:hover { background: rgba(255,255,255,.08); }
#alarm-badge-icon { font-size: .9rem; }
#alarm-badge-count {
  font-weight: 700;
  font-size: .8rem;
  min-width: 14px;
  text-align: center;
}
#alarm-badge-btn.sev-0  { color: #6b8299; background: none;       border-color: #3d5470; }
#alarm-badge-btn.sev-1  { color: #fff;    background: #2c5f8a;    border-color: #2c5f8a; }
#alarm-badge-btn.sev-2  { color: #fff;    background: #e67e22;    border-color: #e67e22; }
#alarm-badge-btn.sev-3  { color: #fff;    background: #c0392b;    border-color: #c0392b; animation: badge-pulse 2s infinite; }
@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.4); }
  50%       { box-shadow: 0 0 0 5px rgba(192,57,43,0); }
}

/* ── Alarm grid rows ─────────────────────────────────── */
.alarm-critical-row { animation: row-pulse 2s infinite; }
@keyframes row-pulse {
  0%, 100% { background-color: transparent; }
  50%       { background-color: rgba(192,57,43,.06); }
}

/* ═══════════════════════════════════════════════════════════
   USER MENU
═══════════════════════════════════════════════════════════ */
#user-menu-wrap {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid #3d5470;
  border-radius: 20px;
  padding: 4px 12px 4px 10px;
  color: #cdd5e0;
  cursor: pointer;
  font-size: .87rem;
  transition: background .15s;
}
.user-menu-btn:hover { background: rgba(255,255,255,.08); }
.user-icon { font-size: .9rem; }
.user-caret { font-size: .6rem; color: #7a9ab8; margin-top: 1px; }

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid #dde4ee;
  border-radius: 7px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15);
  min-width: 170px;
  z-index: 300;
  overflow: hidden;
}

.user-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  color: #1e2a3a;
  font-size: .88rem;
  cursor: pointer;
  transition: background .15s;
}
.user-dropdown-item:hover { background: #f0f4fa; color: #c0392b; }

/* ═══════════════════════════════════════════════════════════
   ICON BUTTONS
═══════════════════════════════════════════════════════════ */
.btn-icon {
  width: 38px;
  height: 38px;
  background: none;
  border: none;
  color: #cdd5e0;
  font-size: 1.15rem;
  cursor: pointer;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: rgba(255,255,255,.1); color: #fff; }

.btn-icon--sm {
  width: 32px;
  height: 32px;
  font-size: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   APP BODY — fills remaining height
═══════════════════════════════════════════════════════════ */
#app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  position: relative;   /* ancla para el nav-drawer en modo overlay */
}

/* ═══════════════════════════════════════════════════════════
   NAV DRAWER — rail / overlay / pinned (estilo VS Code)
   · rail:    columna estrecha solo iconos (default)
   · overlay: expandido flotando sobre el contenido (temporal)
   · pinned:  expandido en el flujo (empuja el contenido, persiste)
   El ☰ del header alterna rail ↔ overlay. El pin (pie) ancla.
═══════════════════════════════════════════════════════════ */
:root { --nav-rail-w: 56px; --nav-panel-w: 260px; }

.nav-drawer {
  flex: 0 0 var(--nav-rail-w);
  background: #1e2a3a;
  border-right: 1px solid #2d3d52;
  transition: flex-basis 0.2s ease;
  min-width: 0;
  display: flex; flex-direction: column;
}
.nav-drawer.pinned { flex-basis: var(--nav-panel-w); }
.nav-drawer.overlay {
  position: absolute; top: 0; bottom: 0; left: 0;
  flex-basis: var(--nav-panel-w); width: var(--nav-panel-w);
  z-index: 40; box-shadow: 4px 0 16px rgba(0,0,0,.35);
}

.nav-list { list-style: none; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 0; margin: 0; }

/* Fila de grupo */
.nav-group > .group-row {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; margin: 1px 8px; border-radius: 6px;
  cursor: pointer; white-space: nowrap; overflow: hidden;
}
.nav-group > .group-row .gicon { width: calc(var(--nav-rail-w) - 16px); text-align: center; font-size: 18px; flex-shrink: 0; }
.nav-group > .group-row .glabel { font-size: 14px; font-weight: 600; color: #fff; flex: 1; }
.nav-group > .group-row .chev { font-size: 10px; color: rgba(205,213,224,.55); padding-right: 12px; transition: transform .15s ease; }
.nav-group.open > .group-row .chev { transform: rotate(90deg); }
.nav-group > .group-row:hover { background: #2d3d52; }
.nav-group.active > .group-row { background: #1a73e8; }

/* Hijos: colapsados por defecto; se despliegan al abrir el grupo */
.nav-children { list-style: none; display: none; margin: 0; padding: 0; }
.nav-drawer.overlay .nav-group.open > .nav-children,
.nav-drawer.pinned  .nav-group.open > .nav-children { display: block; }
.nav-children li {
  padding: 4px 12px 4px 64px; margin: 1px 8px; border-radius: 5px;
  font-size: 13.5px; cursor: pointer; white-space: nowrap; overflow: hidden; color: #cdd5e0;
}
.nav-children li:hover { background: #2d3d52; color: #fff; }
.nav-children li.sel { background: #1a73e8; color: #fff; }

/* En rail: solo iconos (oculta labels, chevron, hijos) */
.nav-drawer.rail .glabel,
.nav-drawer.rail .chev,
.nav-drawer.rail .nav-children { display: none; }
.nav-drawer.rail .nav-group > .group-row { justify-content: center; padding: 10px 0; }

/* Pie del nav: expandir-todo + pin. Solo visible expandido. */
.nav-foot { display: flex; align-items: center; justify-content: flex-end; gap: 2px; border-top: 1px solid #2d3d52; padding: 4px 6px; flex-shrink: 0; }
.nav-drawer.rail .nav-foot { display: none; }
.nav-foot-btn { width: 36px; height: 32px; border: none; background: none; color: #cdd5e0; cursor: pointer; font-size: 20px; font-weight: 700; border-radius: 5px; display: flex; align-items: center; justify-content: center; }
.nav-foot-btn:hover { background: #2d3d52; color: #fff; }
.nav-foot-btn .vchev { display: inline-block; transform: rotate(90deg); }
.nav-foot-btn.pin { font-size: 16px; }
.nav-foot-btn.pin .pin-glyph { display: inline-block; transition: transform .15s ease; }
.nav-foot-btn.pin.on .pin-glyph { transform: rotate(-45deg); }

/* Flyout (rail: click en icono → context menu con hijos) */
#nav-flyout {
  position: fixed; z-index: 60; min-width: 200px; background: #24344a;
  border: 1px solid #2d3d52; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.4);
  padding: 6px 0; display: none;
}
#nav-flyout .fly-title {
  padding: 6px 14px; font-size: 14px; font-weight: 700; color: #8aa0bd;
  text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid #2d3d52; margin-bottom: 4px;
}
#nav-flyout ul { list-style: none; margin: 0; padding: 0; }
#nav-flyout li { padding: 7px 16px; font-size: 13.5px; color: #cdd5e0; cursor: pointer; white-space: nowrap; }
#nav-flyout li:hover { background: #1a73e8; color: #fff; }

/* Resizer nav↔geo-tree: solo en modo anclado (en rail/overlay no aplica) */
#nav-resizer { display: none; }
.nav-drawer.pinned + #nav-resizer { display: block; }

/* ═══════════════════════════════════════════════════════════
   GEO TREE DRAWER (right of nav, expanded by default)
═══════════════════════════════════════════════════════════ */
.geo-drawer {
  width: 280px;
  background: #f8f9fb;
  border-right: 1px solid #dde4ee;
  transition: width 0.25s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.geo-drawer.collapsed {
  width: 40px;
}

.geo-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Geo toolbar (botones + buscador en dos filas) */
.geo-toolbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border-bottom: 1px solid #dde4ee;
  flex-shrink: 0;
}

.geo-toolbar-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.geo-toolbar-search input {
  flex: 1;
  padding: 5px 9px;
  border: 1px solid #bcc8d8;
  border-radius: 4px;
  font-size: .82rem;
  outline: none;
  min-width: 0;
}

.btn-tree {
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid #bcc8d8;
  border-radius: 4px;
  cursor: pointer;
  font-size: .85rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a5a72;
  transition: background .15s;
}
.btn-tree:hover { background: #f0f4fa; }
.btn-search { font-size: 1rem; }

/* Búsqueda manual de grids (GRIDUTIL.installManualSearch) — mismo look que
   la barra del árbol; usamos 32px de alto para casar con el botón nativo
   "Columnas" del toolbar de DevExtreme. */
.grid-search { display: inline-flex; gap: 6px; align-items: center; }
.grid-search-input {
  width: 220px; height: 32px; padding: 4px 8px; font-size: .9rem;
  border: 1px solid #bcc8d8; border-radius: 4px; background: #fff;
  color: #333; outline: none; box-sizing: border-box;
}
.grid-search-input:focus { border-color: #1a73e8; }
.grid-search .btn-tree { width: 32px; height: 32px; }

/* El grid contenedor debe usar todo el ancho horizontal disponible para que
   las columnas y el toolbar lleguen al borde derecho del panel. */
#content-area > .dx-datagrid { width: 100%; }

/* Iconos del nodo del árbol — emoji o imagen subida desde BD */
.geo-icon-emoji {
  display: inline-block;
  margin-right: 4px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  font-style: normal;
}
.geo-icon-img {
  width: 22px; height: 22px;
  vertical-align: -6px;
  object-fit: contain;
  margin-right: 2px;
}
.geo-node-label { vertical-align: middle; }

/* Highlight de búsqueda por path: replica el azul del click manual.
   Se limpia al pulsar en cualquier otro nodo del árbol. */
.geo-tree-wrap .dx-treeview-item.geo-search-hit {
  background-color: #1a73e8 !important;
  color: #fff !important;
}
.geo-tree-wrap .dx-treeview-item.geo-search-hit .geo-node,
.geo-tree-wrap .dx-treeview-item.geo-search-hit .geo-node * {
  color: #fff !important;
}

.geo-tree-wrap {
  flex: 1;
  overflow: auto;
  padding: 4px;
}

/* Geo tree node styles */
.geo-node { display: inline-block; font-size: .88rem; cursor: default; padding: 1px 4px; border-radius: 3px; }
.geo-node--site         { color: #1e2a3a; font-weight: 600; }
.geo-node--location { color: #2c5f8a; }
.geo-node--installation { color: #1a6b3c; }
.geo-node--device       { color: #6b3a1a; }
.geo-node--remote       { color: #6b1a6b; }

/* ── Selected/focused: override node color to stay readable on dark bg ── */
/* cubre ambas posiciones posibles del state class (node li / item div) y usa > */
/* para NO propagar a hijos dentro de dx-treeview-node-container */
.dx-treeview-item.dx-state-selected .geo-node,
.dx-treeview-item.dx-state-focused  .geo-node,
.dx-treeview-node.dx-state-selected > .dx-treeview-item .geo-node,
.dx-treeview-node.dx-state-focused  > .dx-treeview-item .geo-node,
.dx-treeview-item-content.dx-state-selected .geo-node,
.dx-treeview-item-content.dx-state-focused  .geo-node {
  color: #fff !important;
}
.dx-treeview-item.dx-state-selected .geo-node,
.dx-treeview-node.dx-state-selected > .dx-treeview-item .geo-node {
  font-weight: 600;
}

/* ── Ctrl-held: show grab cursor on all tree nodes ── */
.geo-tree-wrap.ctrl-held .geo-node          { cursor: grab; }
.geo-tree-wrap.ctrl-held .geo-node:active   { cursor: grabbing; }

/* ── Ghost personalizado para el drag (texto negro sobre blanco) ── */
.geo-drag-ghost {
  position: absolute;
  top: -9999px; left: -9999px;
  background: #fff;
  color: #1e2a3a;
  padding: 4px 10px;
  border: 1px solid #bcc8d8;
  border-radius: 4px;
  font: 13px -apple-system, sans-serif;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  white-space: nowrap;
}

/* ── Drag & drop feedback ── */
.geo-node.drag-source { opacity: 0.45; }
.geo-node.drag-over {
  outline: 2px dashed #1a73e8;
  background: #e8f0fe;
}

/* ── Hint Ctrl+drag ── */
.geo-hint {
  padding: 4px 10px;
  font-size: 11px;
  color: #6a737d;
  background: #f6f8fa;
  border-bottom: 1px solid #e1e4e8;
}
.move-confirm {
  border-collapse: collapse;
  margin: 4px 0;
}
.move-confirm td {
  padding: 4px 10px;
  vertical-align: top;
}
.move-confirm td.lbl {
  color: #6a737d;
  text-align: right;
  white-space: nowrap;
  font-weight: 600;
}
.move-confirm td.val {
  text-align: left;
  color: #1e2a3a;
}

.geo-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid #bcc8d8;
  border-radius: 3px;
  font-family: Consolas, monospace;
  font-size: 10px;
  color: #444;
  box-shadow: 0 1px 0 #cbd2d9;
}

/* ── Geo tree context menu ── */
.geo-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #d0d7e2;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  min-width: 190px;
  padding: 4px 0;
  font-size: 13px;
  user-select: none;
}
.geo-ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px;
  cursor: pointer;
  color: #1e2a3a;
  transition: background .1s;
}
.geo-ctx-item:hover:not(.geo-ctx-item--disabled) {
  background: #eef3fc;
  color: #1a3a6b;
}
.geo-ctx-item--disabled {
  color: #b0b8c8;
  cursor: default;
}
.geo-ctx-icon { width: 18px; text-align: center; flex-shrink: 0; }

/* ── Ancestor alarm dot (bubble-up) ── */
.alarm-ancestor-dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-left: 6px;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: .85;
}
.geo-ctx-sep  { height: 1px; background: #e8ecf2; margin: 4px 0; }

/* ═══════════════════════════════════════════════════════════
   PANEL RESIZER (splitter)
═══════════════════════════════════════════════════════════ */
.panel-resizer {
  width: 5px;
  flex-shrink: 0;
  background: #dde4ee;
  cursor: col-resize;
  position: relative;
  transition: background .15s;
  z-index: 10;
}
.panel-resizer:hover,
.panel-resizer.dragging {
  background: #1a73e8;
}
.panel-resizer::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 1px;
  transform: translateY(-50%);
  width: 3px;
  height: 32px;
  background: repeating-linear-gradient(
    to bottom,
    #bcc8d8 0, #bcc8d8 2px,
    transparent 2px, transparent 5px
  );
  border-radius: 2px;
}
.panel-resizer.dragging::after { background: repeating-linear-gradient(
    to bottom, #fff 0, #fff 2px, transparent 2px, transparent 5px); }

/* ═══════════════════════════════════════════════════════════
   CONTENT PANEL
═══════════════════════════════════════════════════════════ */
#content-panel {
  flex: 1;
  overflow: auto;
  min-width: 0;
}

#content-area {
  padding: 20px;
  min-height: 100%;
}

/* ═══════════════════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════════════════ */
#app-footer {
  height: 26px;
  background: #1a2535;
  color: #6a8aa8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: .72rem;
  flex-shrink: 0;
  letter-spacing: .2px;
}

.ver-badge { font-weight: 600; color: #9ab8d4; }
.footer-sep { color: #304560; }

/* ═══════════════════════════════════════════════════════════
   ENTITY PAGE
═══════════════════════════════════════════════════════════ */
.entity-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.entity-title {
  font-size: 1.35rem;
  font-weight: 600;
  color: #1e2a3a;
  margin: 0;
}

.dx-datagrid {
  border-radius: 6px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}

/* ═══════════════════════════════════════════════════════════
   MASTER-DETAIL
═══════════════════════════════════════════════════════════ */
.detail-back-btn {
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid #bcc8d8;
  background: #fff;
  color: #1e2a3a;
  cursor: pointer;
  font-size: .88rem;
  white-space: nowrap;
  transition: background .15s;
}
.detail-back-btn:hover { background: #f0f4fa; }

.form-fields-group.dx-field-item,
.form-fields-group .dx-form-group-content {
  padding: 0 !important;
  border: none !important;
  margin: 0 !important;
}

.audit-group .dx-form-group-caption {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: #7a8a9a;
}
.audit-group .dx-texteditor-input { color: #7a8a9a; font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════
   FULL PAGE (Template / Driver / Device / Installation)
═══════════════════════════════════════════════════════════ */
.full-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e6ef;
}

.full-footer {
  display: flex;
  gap: 10px;
  padding: 16px 0 4px;
  border-top: 1px solid #e0e6ef;
  margin-top: 8px;
}

.full-btn-save {
  padding: 8px 22px; border-radius: 4px; border: none;
  background: #1a73e8; color: #fff; font-size: .92rem; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.full-btn-save:hover    { background: #1558c0; }
.full-btn-save:disabled { background: #a0b8d8; cursor: not-allowed; }

.full-btn-cancel {
  padding: 8px 18px; border-radius: 4px; border: 1px solid #bcc8d8;
  background: #fff; color: #4a5a72; font-size: .92rem;
  cursor: pointer; transition: background .15s;
}
.full-btn-cancel:hover { background: #f0f4fa; }

/* ═══════════════════════════════════════════════════════════
   INHERITANCE GRID BADGES
═══════════════════════════════════════════════════════════ */
.badge-inherited { display: inline-block; font-size: .85rem; color: #999; }
.badge-modified  { display: inline-block; font-size: .85rem; color: #1a73e8; font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   MONACO EDITOR
═══════════════════════════════════════════════════════════ */
.monaco-wrap {
  width: 100%;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.monaco-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f6f8fa;
  border-bottom: 1px solid #d0d7de;
  padding: 3px 8px;
  font-size: 0.85em;
  flex: 0 0 auto;
}
.monaco-lang {
  color: #6a737d;
  font-family: Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.monaco-btn-max {
  background: none;
  border: 1px solid transparent;
  color: #4a5a72;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 3px;
  line-height: 1;
}
.monaco-btn-max:hover {
  background: #e6ebf0;
  border-color: #bcc8d8;
}
.monaco-host {
  width: 100%;
  background: #fff;
}

/* ═══════════════════════════════════════════════════════════
   IMPORTADOR
═══════════════════════════════════════════════════════════ */
.importer-root { display: flex; flex-direction: column; height: 100%; }

.imp-header {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px 8px; border-bottom: 1px solid #e0e4ea;
  flex-wrap: wrap;
}
.imp-title { margin: 0; font-size: 1.15rem; font-weight: 600; color: #1e3a5f; }
.imp-def-bar { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.imp-def-lbl { color: #7a8a9a; }
.imp-def-file { padding: 4px 10px; border-radius: 4px; border: 1px solid #bcd; cursor: pointer; font-size: .85rem; font-weight: 600; color: #1a73e8; background: #f0f4fa; }
.imp-def-file:hover { background: #e0ecff; }

.imp-body { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 20px; }

.imp-section { background: #fff; border: 1px solid #e0e4ea; border-radius: 6px; padding: 16px 20px; }
.imp-sec-h { margin: 0 0 12px; font-size: .95rem; font-weight: 600; color: #1e3a5f; }

.imp-row-inline { display: flex; align-items: center; gap: 10px; }
.imp-xl-name-btn { padding: 5px 12px; border-radius: 4px; border: 1px solid #dde; cursor: pointer; font-size: .85rem; color: #444; background: #fafafa; text-align: left; }
.imp-xl-name-btn:hover { background: #f0f4fa; color: #1a73e8; }

/* Work tabs (Datos / Resultados) */
.imp-work-tabs { display: flex; gap: 2px; border-bottom: 2px solid #1a73e8; margin-bottom: 16px; }
.imp-work-tab  { padding: 8px 22px; border: none; cursor: pointer; font-size: .875rem; border-radius: 4px 4px 0 0; background: #f0f4fa; color: #555; }
.imp-work-tab.active { background: #1a73e8; color: #fff; font-weight: 600; }
.imp-work-tab:hover:not(.active) { background: #dce8fd; color: #1a73e8; }
.imp-work-panel { }

/* Entity sub-tabs */
.imp-entity-tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.imp-entity-tab  { padding: 4px 14px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer; font-size: .8rem; background: #f9f9f9; color: #555; }
.imp-entity-tab.active { background: #e8f0fe; border-color: #1a73e8; color: #1a73e8; font-weight: 600; }
.imp-entity-tab:hover:not(.active) { background: #f0f4ff; }

.imp-grid-wrap { height: 300px; }

.imp-val-msg { margin-top: 10px; font-size: .875rem; padding: 6px 10px; border-radius: 4px; }
.imp-val-ok  { background: #e8f5e9; color: #2e7d32; }
.imp-val-err { background: #fff3e0; color: #e65100; }

.imp-actions { margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; }

.imp-result-summary { font-size: .9rem; margin-bottom: 12px; display: flex; gap: 16px; }
.imp-sum-ok  { color: #2e7d32; font-weight: 600; }
.imp-sum-err { color: #c62828; font-weight: 600; }

/* Botones */
.imp-btn-primary   { padding: 7px 18px; border-radius: 4px; border: none; cursor: pointer; font-size: .875rem; font-weight: 600; background: #1a73e8; color: #fff; }
.imp-btn-primary:hover:not(:disabled) { background: #1558c0; }
.imp-btn-primary:disabled { opacity: .45; cursor: default; }
.imp-btn-secondary { padding: 7px 14px; border-radius: 4px; border: 1px solid #bbc; cursor: pointer; font-size: .875rem; background: #fff; color: #333; }
.imp-btn-secondary:hover { background: #f0f4fa; }
.imp-btn-danger    { padding: 7px 14px; border-radius: 4px; border: none; cursor: pointer; font-size: .875rem; font-weight: 600; background: #d32f2f; color: #fff; }
.imp-btn-danger:hover { background: #b71c1c; }

/* Tabla de resultados (HTML simple, sin DevExtreme) */
.imp-result-scroll { height: 300px; overflow-y: auto; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 4px; }
.imp-result-table  { width: 100%; border-collapse: collapse; font-size: .82rem; }
.imp-result-table th { background: #1a73e8; color: #fff; padding: 6px 8px; text-align: left; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.imp-result-table td { padding: 5px 8px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }

/* Badges de estado en grid de resultados */
.imp-st-badge    { font-size: .8rem; white-space: nowrap; }
.imp-st-ok       { color: #2e7d32; }
.imp-st-error    { color: #c62828; }
.imp-st-importing{ color: #e65100; }
.imp-st-reverted { color: #7a8a9a; }

/* Botones inline en grid de resultados */
.imp-row-btn     { font-size: .78rem; padding: 2px 8px; border-radius: 3px; cursor: pointer; border: none; }
.imp-row-rollback{ background: #fff3e0; color: #bf360c; border: 1px solid #ffccbc; }
.imp-row-rollback:hover { background: #ffe0b2; }
.imp-row-retry   { background: #e3f2fd; color: #0d47a1; border: 1px solid #bbdefb; }
.imp-row-retry:hover { background: #bbdefb; }


/* ══════════════════════════════════════════════════════════════════
   MÓDULO ADMINISTRACIÓN (auth-providers-page, users-admin-page)
   ══════════════════════════════════════════════════════════════════ */

/* ── Layout general ─────────────────────────────────────────────── */
.ap-page         { padding: 20px 24px; max-width: 1100px; }
.ap-header       { margin-bottom: 20px; }
.ap-title        { font-size: 1.25rem; font-weight: 600; color: #1a73e8; margin: 0; }
.ap-section      { background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.ap-section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ap-section-title{ font-size: 1rem; font-weight: 600; color: #333; }
.ap-empty        { color: #888; font-style: italic; margin: 0; }

/* ── Tabla ──────────────────────────────────────────────────────── */
.ap-table        { width: 100%; border-collapse: collapse; font-size: .875rem; }
.ap-table th     { background: #f5f5f5; color: #555; padding: 8px 10px; text-align: left; border-bottom: 2px solid #e0e0e0; font-weight: 600; white-space: nowrap; }
.ap-table td     { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.ap-table tr:hover td { background: #fafafa; }
.ap-actions      { white-space: nowrap; display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Status dot ─────────────────────────────────────────────────── */
.ap-dot          { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.ap-dot-on       { background: #43a047; }
.ap-dot-off      { background: #bdbdbd; }

/* ── Type badge ─────────────────────────────────────────────────── */
.ap-type-badge   { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; letter-spacing: .5px; }
.ap-type-local   { background: #e3f2fd; color: #1565c0; }
.ap-type-ldaps   { background: #e8f5e9; color: #2e7d32; }
.ap-type-oidc    { background: #f3e5f5; color: #6a1b9a; }

/* ── Role badge ─────────────────────────────────────────────────── */
.ap-role-badge      { font-size: .72rem; font-weight: 700; padding: 2px 7px; border-radius: 4px; background: #fff3e0; color: #e65100; }
.ap-role-sysadmin   { background: #ede7f6; color: #4527a0; }
.ap-role-admin      { background: #fce4ec; color: #b71c1c; }
.ap-role-operator   { background: #e8eaf6; color: #283593; }
.ap-role-guest      { background: #fff3e0; color: #e65100; }
.ap-role-readonly   { background: #f5f5f5; color: #616161; }
.ap-role-siteworker { background: #e0f2f1; color: #00695c; }

/* ── MFA status ─────────────────────────────────────────────────── */
.ap-mfa-on       { color: #2e7d32; font-size: .8rem; }
.ap-mfa-off      { color: #bdbdbd; }
.ap-mfa-pending  { color: #e65100; font-size: .8rem; }

/* ── "predeterminado" badge ─────────────────────────────────────── */
.ap-badge        { font-size: .68rem; background: #fff9c4; color: #f57f17; border: 1px solid #ffe082; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }

/* ── Form ───────────────────────────────────────────────────────── */
.ap-label        { display: block; font-size: .82rem; font-weight: 600; color: #444; margin-bottom: 4px; margin-top: 12px; }
.ap-label:first-child { margin-top: 0; }
.ap-input        { width: 100%; padding: 7px 10px; border: 1px solid #ccc; border-radius: 5px; font-size: .875rem; box-sizing: border-box; }
.ap-input:focus  { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,.15); }
.ap-input:disabled { background: #f5f5f5; color: #888; }
.ap-select-sm    { width: auto; min-width: 180px; }
.ap-field-group  { margin-bottom: 4px; }
.ap-field-row    { display: flex; gap: 12px; }
.ap-field-row .ap-field-group { flex: 1; }
.ap-field-short  { flex: 0 0 90px !important; }
.ap-config-title { font-size: .95rem; font-weight: 600; color: #333; margin: 16px 0 8px; border-bottom: 1px solid #e0e0e0; padding-bottom: 6px; }

/* ── Form row (fields + help panel) ────────────────────────────── */
.ap-form-row     { display: flex; gap: 20px; }
.ap-form-fields  { flex: 1; min-width: 0; }
.ap-help-panel   { width: 280px; flex-shrink: 0; background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 6px; padding: 14px; font-size: .8rem; color: #555; line-height: 1.55; }
.ap-help-panel strong { color: #333; }
.ap-help-panel code   { background: #e8eaf6; color: #283593; padding: 1px 4px; border-radius: 3px; font-size: .78rem; }

/* ── Inline help (per field, collapsible) ───────────────────────── */
.ap-field-help-btn  { border: none; background: none; color: #1a73e8; font-size: .75rem; cursor: pointer; border: 1px solid #c5d8f5; border-radius: 50%; width: 18px; height: 18px; line-height: 16px; text-align: center; margin-left: 4px; font-weight: 700; vertical-align: middle; }
.ap-field-help-btn:hover { background: #e3f2fd; }
.ap-inline-help  { background: #fffde7; border: 1px solid #fff176; border-radius: 5px; padding: 8px 12px; font-size: .79rem; color: #555; line-height: 1.5; margin-top: 4px; margin-bottom: 8px; }
.ap-inline-help strong { color: #333; }
.ap-inline-help code   { background: #e3f2fd; color: #1565c0; padding: 1px 4px; border-radius: 3px; font-size: .77rem; }
.ap-help-table   { border-collapse: collapse; font-size: .78rem; margin-top: 4px; }
.ap-help-table th, .ap-help-table td { border: 1px solid #ddd; padding: 3px 6px; }
.ap-help-table th { background: #f5f5f5; }

/* ── Radio / checkbox groups ────────────────────────────────────── */
.ap-radio-group  { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.ap-radio        { font-size: .875rem; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.ap-checkbox-group { display: flex; gap: 20px; margin-top: 4px; font-size: .875rem; }
.ap-checkbox-group label { cursor: pointer; }

/* ── Filters bar ─────────────────────────────────────────────────── */
.ap-filters      { display: flex; gap: 8px; align-items: center; }

/* ── Dialog overlay ─────────────────────────────────────────────── */
/* z-index 1400: por encima del header (200) y demás chrome SPA, pero por
   debajo del z-index inicial de DevExpress (~1500) — así los confirm()
   y notify() de DevExpress aparecen siempre por encima del overlay. */
.ap-overlay      { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1400; display: flex; align-items: center; justify-content: center; }
.ap-dialog       { background: #fff; border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,.25); width: 780px; max-width: 95vw; max-height: 92vh; display: flex; flex-direction: column; }
.ap-dialog-sm    { width: 420px; }
.ap-dialog-head  { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e0e0e0; font-weight: 600; font-size: .95rem; }
.ap-dialog-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: #888; line-height: 1; }
.ap-dialog-close:hover { color: #333; }
.ap-dialog-body  { padding: 20px; overflow-y: auto; flex: 1; }
.ap-dialog-foot  { padding: 14px 20px; border-top: 1px solid #e0e0e0; display: flex; justify-content: flex-end; gap: 10px; }

/* ── Test result ─────────────────────────────────────────────────── */
.ap-test-result  { padding: 8px 12px; border-radius: 5px; font-size: .83rem; margin-top: 12px; }
.ap-test-loading { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.ap-test-ok      { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ap-test-error   { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }

/* ── Login MFA hint ─────────────────────────────────────────────── */
.login-mfa-hint  { font-size: .85rem; color: #555; text-align: center; margin: 0 0 16px; }

/* ── req asterisk ───────────────────────────────────────────────── */
.req             { color: #c62828; }

/* ── Roles page ─────────────────────────────────────────────────── */
.ap-dialog-lg    { width: 900px; }
.ap-badge-builtin{ font-size: .68rem; background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; border-radius: 3px; padding: 1px 5px; margin-left: 6px; vertical-align: middle; }
.ap-perm-count   { font-size: .8rem; color: #555; }
.ap-type-local   { background: #e3f2fd; color: #1565c0; }
.roles-dlg-top   { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; margin-bottom: 8px; }
.roles-dlg-meta  { grid-column: 1 / -1; display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; }
.roles-perms-grid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 8px; }
.roles-perm-group{ border: 1px solid #e0e0e0; border-radius: 6px; padding: 10px 12px; }
.roles-perm-group-title { font-size: .82rem; font-weight: 700; color: #333; margin-bottom: 6px; border-bottom: 1px solid #f0f0f0; padding-bottom: 5px; }
.roles-perm-item { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: #444; cursor: pointer; padding: 2px 0; }
.roles-perm-item input { flex-shrink: 0; }

/* ── LDAP provider tabs ──────────────────────────────────────────── */
.ap-tabs { margin-top: 8px; }
.ap-tab-bar { display: flex; border-bottom: 2px solid #e0e0e0; margin-bottom: 16px; gap: 4px; }
.ap-tab-btn { background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; padding: 8px 18px; cursor: pointer; color: #666; font-size: .88rem; font-family: inherit; transition: color .15s; }
.ap-tab-btn:hover { color: #1a73e8; }
.ap-tab-btn.ap-tab-active { color: #1a73e8; border-bottom-color: #1a73e8; font-weight: 600; }
.ap-tab-content-area { height: 430px; overflow-y: auto; padding-right: 4px; }
.ap-tab-panel { display: none; }
.ap-tab-panel.ap-tab-panel-active { display: block; }

/* ── Inline 2-col form (label + input on same row) ──────────────── */
.ap-inline-form { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 6px 10px; }
.ap-il-label { font-size: .82rem; color: #444; white-space: nowrap; text-align: right; }
.ap-il-label-mid { font-size: .82rem; color: #444; white-space: nowrap; flex-shrink: 0; }
.ap-il-input { min-width: 0; }
.ap-il-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ap-il-check { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: #444; white-space: nowrap; cursor: pointer; }
.ap-il-help { grid-column: 1 / -1; }
.ap-il-btn { justify-self: start; }

/* ── Group mappings tab ──────────────────────────────────────────── */
.ap-groups-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ap-add-mapping-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; padding: 10px 12px; background: #f8f9fa; border-radius: 6px; border: 1px solid #e0e0e0; }
.ap-dn { color: #888; font-size: .73rem; }

/* ── Misc helpers ────────────────────────────────────────────────── */
.ap-hint { display: block; margin-top: 4px; font-size: .75rem; color: #888; }
.ap-hint code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; font-size: .72rem; }
