:root {
  --bg: #ffffff;
  --fg: #111111;
  --gray-100: #f5f5f5;
  --gray-200: #e6e6e6;
  --gray-400: #b0b0b0;
  --gray-600: #6b6b6b;
  --accent: #111111;
  --danger: #b3261e;
  --radius: 2px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

.watermark {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(30vw, 140px);
  aspect-ratio: 186 / 80;
  z-index: 5;
  background-image: url("/img/jck-logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.55;
  pointer-events: none;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-600); margin-top: 2.5rem; }

p { line-height: 1.5; }
.muted { color: var(--gray-600); font-size: 0.9rem; }

/* ---- Layout ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__left { display: flex; align-items: baseline; gap: 1rem; flex: 1; min-width: 0; }
.topbar__brand { font-weight: 600; letter-spacing: 0.02em; color: inherit; text-decoration: none; }
.topbar__nav { color: var(--gray-600); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__nav-link { color: inherit; text-decoration: none; }
.topbar__nav-link:hover { color: var(--fg); }
.topbar__burger {
  display: none;
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  background: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--fg);
  cursor: pointer;
}

/* ---- Campanita de notificaciones ---- */
.topbar__bell {
  position: relative;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.4rem 0.6rem;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}
.topbar__bell:hover { background: var(--gray-100); }
.topbar__bell:active { background: var(--gray-200); }
.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #b3261e;
  color: #fff;
  font-size: 0.65rem;
  line-height: 1.1rem;
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 1.5rem;
  min-width: 280px;
  max-width: 360px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.25rem 0;
  background: var(--bg);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  z-index: 20;
}
.notif-panel .muted { padding: 0.75rem 0.9rem; margin: 0; }
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.9rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--gray-200);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--gray-100); }
.notif-item strong { font-size: 0.85rem; }
.notif-item span { font-size: 0.8rem; color: var(--gray-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Barra de menús (estilo aplicación de escritorio) ---- */
.menubar { display: flex; align-items: stretch; gap: 0.25rem; }
.menu { position: relative; }
.menu__label {
  font: inherit;
  font-size: 0.85rem;
  color: var(--gray-600);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  white-space: nowrap;
}
.menu__label:hover { color: var(--fg); background: var(--gray-100); }
.menu__label:active { background: var(--gray-200); }
.menu.is-open > .menu__label { color: var(--fg); background: var(--gray-100); border-color: var(--gray-200); }
.menu__panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 240px;
  padding: 0.25rem 0;
  background: var(--bg);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
}
.menu.is-open > .menu__panel { display: block; }
.menu__item {
  display: block;
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.55rem 0.9rem;
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}
.menu__item:hover, .menu__item:focus-visible { background: var(--gray-100); }
.menu__item:active { background: var(--gray-200); }
.menu__item[aria-checked="true"]::before { content: "✓ "; }
.menu__item[aria-checked="false"]::before { content: ""; padding-left: 0.95em; display: inline-block; }
.menu__sep { height: 1px; margin: 0.25rem 0; background: var(--gray-200); }
.menu__group {
  padding: 0.5rem 0.9rem 0.25rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
}

/* Iframe oculto usado para imprimir el PDF (fuera de pantalla, nunca display:none:
   varios navegadores no imprimen un frame con display:none). */
.print-frame { position: fixed; left: -10000px; top: 0; width: 800px; height: 600px; border: 0; }

#app { max-width: 1100px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.view--center {
  max-width: 420px;
  margin: 4rem auto;
}

.view__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.view__header-actions { display: flex; gap: 0.5rem; }

/* ---- Buttons & forms ---- */

.btn {
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  min-height: 40px;
}
.btn:hover { background: var(--gray-100); }
.btn:active { background: var(--gray-200); transform: scale(0.97); }
.btn--primary { background: var(--fg); color: var(--bg); }
.btn--primary:hover { background: #333; }
.btn--primary:active { background: #111; transform: scale(0.97); }
.btn--secondary { border-color: var(--gray-400); }
.btn--ghost { border-color: transparent; }
.btn--ghost:hover { background: var(--gray-100); }
.btn--ghost:active { background: var(--gray-200); transform: scale(0.97); }

.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---- Login (marca j-c-k) ---- */

body.login-mode .topbar { display: none; }
body.login-mode #app { max-width: none; padding: 0; }

.login {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.login__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  border-right: 1px solid var(--gray-200);
  background-color: #fafafa;
  /* Retícula fina, guiño al papel milimetrado del plano. */
  background-image:
    linear-gradient(to right, rgba(0, 0, 0, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.045) 1px, transparent 1px);
  background-size: 28px 28px;
}
.login__brand-inner { max-width: 320px; }

.login__logo { display: block; width: 168px; height: auto; }
.login__studio {
  margin: 1.25rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-600);
}
.login__rule { border: none; border-top: 1px solid var(--gray-400); margin: 2rem 0 1.5rem; }
.login__app { margin: 0; font-size: 2rem; font-weight: 500; letter-spacing: -0.02em; }
.login__tagline { margin: 0.4rem 0 0; color: var(--gray-600); font-size: 0.95rem; }

.login__panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}
.login__lang { position: absolute; top: 1.25rem; right: 1.25rem; }

.login__form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  max-width: 340px;
}
.login__form-title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.login__submit { margin-top: 1.5rem; }

/* ---- Selector de idioma ---- */
.sel-lang {
  min-height: 34px;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}
.login__lang { min-width: 110px; }

/* ---- Campo de contraseña con ver/ocultar ---- */
.pass-field__row { display: flex; gap: 0.4rem; align-items: stretch; }
.pass-field__row input { flex: 1; }
.pass-field__toggle {
  border: 1px solid var(--gray-400);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  padding: 0 0.7rem;
  font-size: 1rem;
  line-height: 1;
}
.pass-field__toggle:hover { background: var(--gray-100); }

/* ---- Perfil ---- */
.perfil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* ---- Ayuda ---- */
.ayuda-temas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.ayuda-tema {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  background: #fafafa;
}
.ayuda-tema h3 { margin: 0 0 0.4rem; font-size: 1rem; font-weight: 600; }
.ayuda-tema p { margin: 0; color: var(--gray-600); font-size: 0.9rem; line-height: 1.45; }

.ayuda-changelog { list-style: none; margin: 1rem 0 0; padding: 0; }
.ayuda-changelog > li { padding: 0.6rem 0; border-top: 1px solid var(--gray-200); }
.ayuda-changelog > li:first-child { border-top: none; }
.ayuda-changelog p { margin: 0.3rem 0 0; color: var(--gray-600); font-size: 0.85rem; line-height: 1.4; }

label { font-size: 0.85rem; color: var(--gray-600); margin-top: 0.5rem; }
input, select, textarea {
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--gray-400);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  min-height: 42px;
}
input[type="color"] { padding: 0.2rem; width: 4rem; }
textarea { min-height: 80px; resize: vertical; }

.form-error { color: var(--danger); font-size: 0.85rem; }

/* ---- Cards grid ---- */

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.grid-cards--sm { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.obra-card, .sector-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  text-align: left;
  background: var(--bg);
  transition: border-color 0.15s;
}
.obra-card:hover, .sector-card:hover { border-color: var(--fg); }
/* El color de la izquierda es el mismo con el que el sector se ve en el plano. */
.sector-card--color { border-left-width: 4px; }
.sector-card__acciones { display: flex; gap: 0.4rem; margin-top: 0.5rem; }
.sector-card__acciones .btn { padding: 0.2rem 0.5rem; font-size: 0.8rem; }
.obra-card h3, .sector-card h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 500; }
.sector-card__m2 { margin: 0 0 0.35rem; font-size: 0.8rem; color: var(--gray-600); }
.obra-card__badge {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
}
.obra-card__badge--pendientes { background: #fdecea; color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  font-size: 0.85rem;
}
.chip__dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; }

/* ---- Plano viewer (estilo CAD) ---- */

.view--plano { max-width: none; padding: 0; }
.view--ancha { max-width: none; }
/* El tope de 1100px lo pone #app: sin esto, sacarle el max-width a la vista no ensancha nada. */
#app:has(.view--plano) { max-width: none; padding: 0; }
#app:has(.view--ancha) { max-width: none; padding: 1.5rem 1.5rem 4rem; }

.plano-toolbar[hidden] { display: none; }

/* La vista del plano ocupa el alto disponible: la toolbar puede envolverse en varias
   líneas en el celular y el visor se adapta solo, sin empujar nada fuera de pantalla. */
.view--plano {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 61px);
}

.plano-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* en pantallas chicas los botones bajan de línea en vez de salirse a la derecha */
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--bg);
  z-index: 5;
  flex-shrink: 0;
}
.select-categoria {
  min-height: 44px;
  font-weight: 500;
  max-width: 100%;
}
.plano-toolbar__hint { color: var(--gray-600); font-size: 0.8rem; flex: 1 1 auto; min-width: 0; }
.plano-toolbar__zoom { display: flex; gap: 0.25rem; flex-shrink: 0; }
.plano-toolbar__zoom .btn { min-width: 44px; padding: 0.4rem; }

.plano-scroll {
  overflow: auto;
  background: var(--gray-100);
  flex: 1;
  min-height: 0;
  touch-action: pan-x pan-y;
  /* Si el plano no llena el visor, queda centrado en vez de dejar una franja gris
     abajo. `safe` evita que se corte el borde superior cuando sí desborda. */
  display: grid;
  place-content: safe center;
}
.plano-stage { position: relative; display: inline-block; }
#plano-canvas { display: block; background: #fff; box-shadow: 0 0 0 1px var(--gray-200); }
.plano-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

.pin {
  cursor: pointer;
}
.pin circle { stroke: #fff; stroke-width: 2; }
.pin text {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  fill: #fff;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
}
.pin--resuelto circle { opacity: 0.45; }
.pin__flecha { stroke: #fff; stroke-width: 1; }
.pin--resuelto .pin__flecha { opacity: 0.45; }

#pin-tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  max-width: 260px;
  background: var(--bg);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.35;
}
#pin-tooltip[hidden] { display: none; }
#pin-tooltip strong { display: block; margin-bottom: 0.15rem; }
#pin-tooltip .pin-tooltip__meta { color: var(--gray-600); }
#pin-tooltip .pin-tooltip__obs { margin-top: 0.25rem; }

#medicion-popover {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  padding: 0.6rem;
  max-width: 220px;
}
#medicion-popover[hidden] { display: none; }
#medicion-popover input[type="text"] { width: 100%; }
.medicion-popover__acciones { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* ---- Plano general (embebido en la vista de obra) ---- */

.plano-scroll--embed {
  /* El plano es el protagonista: ocupa casi toda la pantalla, sin quedar bajo el pliegue. */
  height: calc(100vh - 140px);
  min-height: 620px;
  margin-top: 0;
  border: 1px solid var(--gray-200);
  cursor: grab;
}
.plano-scroll--agarrando { cursor: grabbing; }
#plano-general-canvas { display: block; background: #fff; }

/* Mientras se dibuja un sector el gesto no debe hacer scroll del plano. */
.plano-stage--dibujo { cursor: crosshair; touch-action: none; }
/* En edición el dedo debe arrastrar el rectángulo, no hacer scroll de la página. */
.plano-stage--editar { touch-action: none; }
/* Modo "mover punto": el próximo click sobre el plano reubica el punto en vez de crear uno nuevo. */
.plano-stage--moviendo { cursor: crosshair; }
.btn--activo { background: var(--fg); color: #fff; border-color: var(--fg); }

.plano-toolbar--form { gap: 0.5rem; }
.plano-toolbar--form input[type="text"] { flex: 1; max-width: 320px; min-height: 44px; }
.plano-toolbar--form input[type="number"] { flex: 1; max-width: 320px; min-height: 44px; }

/* Marcadores de la calibración de escala y de la regla de medir sobre el plano general */
.medicion-punto { fill: #dc2626; stroke: #fff; stroke-width: 1.5; }
.medicion-linea { stroke: #dc2626; stroke-width: 2; stroke-dasharray: 4 3; }
.medicion-texto { fill: #dc2626; font-size: 12px; font-weight: 600; text-anchor: middle; }

/* Mediciones guardadas (0.7.28): cada una con su color propio (inline, no fijo por CSS) */
.medicion-persistente__linea { stroke-width: 2.5; }
.medicion-persistente__punto { stroke: #fff; stroke-width: 1.5; }
.medicion-persistente__texto { font-size: 12px; font-weight: 600; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.medicion-persistente { cursor: pointer; }

/* Flecha de norte fija en la esquina del plano general (según calibración de la obra) */
.brujula-norte line, .brujula-norte polygon { stroke: var(--gray-600); fill: var(--gray-600); stroke-width: 1.5; }
.brujula-norte text { fill: var(--gray-600); font-size: 11px; font-weight: 700; }

/* Áreas de los sectores sobre el plano general */
.sector-area { cursor: pointer; }
.sector-area rect {
  fill-opacity: 0.08;
  stroke-width: 1.75;
}
.sector-area:hover rect { fill-opacity: 0.2; }
.sector-area__nombre {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3;
  stroke-linejoin: round;
}
.sector-area__nueva {
  fill: rgba(17, 17, 17, 0.06);
  stroke: var(--fg);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
  cursor: move;
}
.sector-area__handle {
  fill: #fff;
  stroke: var(--fg);
  stroke-width: 2;
  cursor: nwse-resize;
  touch-action: none;
}
.pin--mini circle { stroke-width: 1.5; }

.plano-cargando {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  color: var(--gray-600);
  font-size: 0.85rem;
}
.plano-cargando[hidden] { display: none; }
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

label.btn { display: inline-flex; align-items: center; justify-content: center; }

/* ---- Panel lateral de punto ---- */

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--gray-200);
  box-shadow: -4px 0 16px rgba(0,0,0,0.08);
  overflow-y: auto;
  padding: 1.5rem;
  z-index: 20;
}
.side-panel__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray-600);
  min-width: 44px;
  min-height: 44px;
}
.side-panel__title {
  margin: 0 2.5rem 1rem 0;
  font-size: 1.2rem;
}

.punto-form__categoria {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--gray-600);
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  margin-bottom: 1.25rem;
}
.punto-form__categoria-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.punto-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.punto-form__campo {
  display: flex;
  flex-direction: column;
}
.punto-form__campo label {
  margin-top: 0;
  margin-bottom: 0.4rem;
  font-weight: 500;
}
.punto-form__acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 0.5rem;
  border-top: 1px solid var(--gray-200);
}
.punto-form__acciones .btn {
  min-width: 120px;
  flex: 1 1 auto;
}

.estado-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-600);
}
.side-panel .estado-badge { margin-bottom: 1rem; }
.estado-badge--pendiente_aprobacion { background: #fff4de; color: #8a5a00; }
.estado-badge--resuelto { background: #e6f4ea; color: #1e7431; }

.fotos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.foto-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}
.foto-item__desc { font-size: 0.75rem; color: var(--gray-600); margin: 0.25rem 0 0; }
.foto-item__gps { font-size: 0.75rem; display: inline-block; margin-top: 0.15rem; }
.foto-item__img { cursor: zoom-in; }

/* Foto en grande (click en la miniatura) */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  cursor: zoom-out;
}
.lightbox__img {
  max-width: 100%;
  max-height: 85vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: #fff;
}
.lightbox__desc {
  margin: 0;
  color: #fff;
  font-size: 0.85rem;
  text-align: center;
  max-width: 60ch;
}
.lightbox__cerrar {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.5rem;
  line-height: 1;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
}

/* Ambiente de staging (no es producción) */
.banner-staging {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.55rem 1rem;
  background: #d00000;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.03em;
}

/* Obra de práctica (demo) */
.banner-demo {
  padding: 0.55rem 1rem;
  background: #fff4de;
  color: #8a5a00;
  border-bottom: 1px solid #f0d9a8;
  font-size: 0.8rem;
  text-align: center;
}
.chip-demo {
  margin-left: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #fff4de;
  color: #8a5a00;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  vertical-align: middle;
}

/* Filtro de puntos por categoría sobre el plano */
.plano-filtro {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-200);
  background: #fff;
}
.chip-filtro {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  cursor: pointer;
}
.chip-filtro:active { background: var(--gray-100); transform: scale(0.96); }
.chip-filtro--activo {
  border-color: var(--gray-600);
  color: var(--gray-900, #111);
  font-weight: 500;
}
.chip-filtro__dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
}

.fotos-field { display: flex; flex-direction: column; }
.fotos-field label { margin-top: 0; margin-bottom: 0.4rem; font-weight: 500; }
.fotos-field input[type="file"] {
  padding: 0.9rem 0.7rem;
  border-style: dashed;
  background: var(--gray-100);
  cursor: pointer;
}
.fotos-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.foto-preview-item { width: 96px; }
.foto-preview-item img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  display: block;
}
.foto-preview-item input {
  width: 96px;
  min-height: auto;
  font-size: 0.7rem;
  padding: 0.3rem;
  margin-top: 0.3rem;
}

.usuarios-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }
.usuario-row {
  display: grid;
  grid-template-columns: 1fr 140px auto;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}
.auditoria-row { grid-template-columns: 1fr 140px 130px auto; }
.usuario-row__info { display: flex; flex-direction: column; min-width: 0; }
.usuario-row__acciones { display: flex; gap: 0.5rem; justify-content: flex-end; }
.form-success { color: #1e7431; }

.paginado { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }

hr.sep { border: none; border-top: 1px solid var(--gray-200); margin: 1.25rem 0; }

.revision-historial { margin-top: 0.75rem; font-size: 0.9rem; }
.revision-historial summary { cursor: pointer; color: var(--gray-600); }
.revision-historial__item { padding: 0.5rem 0 0.5rem 0.75rem; border-left: 2px solid var(--gray-200); margin-top: 0.5rem; }

#export-filtro { margin: 0.75rem 0 1.25rem; font-size: 0.9rem; }
#export-filtro summary { cursor: pointer; color: var(--gray-600); }
.export-filtro__form { display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem 1rem; margin-top: 0.75rem; }
.export-filtro__campo { display: flex; flex-direction: column; gap: 0.25rem; }
.export-filtro__form label { display: block; font-size: 0.8rem; color: var(--gray-600); margin-bottom: 0.25rem; }
.export-filtro__campo label { margin-bottom: 0; }
.export-filtro__acciones { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ---- Responsive: celular en obra ---- */

@media (max-width: 800px) {
  .login { grid-template-columns: 1fr; min-height: 0; }
  .login__brand {
    justify-content: flex-start;
    padding: 2.5rem 1.5rem 2rem;
    border-right: none;
    border-bottom: 1px solid var(--gray-200);
  }
  .login__brand-inner { max-width: none; }
  .login__logo { width: 120px; }
  .login__rule { margin: 1.5rem 0 1rem; }
  .login__app { font-size: 1.6rem; }
  .login__panel { padding: 2rem 1.5rem 3rem; align-items: flex-start; }
  .login__form { max-width: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0.75rem 1rem; gap: 0.75rem; justify-content: space-between; }
  .topbar__nav { font-size: 0.8rem; }
  .topbar__burger { display: inline-flex; }
  .notif-panel { right: 0.75rem; min-width: 240px; max-width: calc(100vw - 1.5rem); }
  /* En mobile la barra se despliega bajo la hamburguesa: los mismos menús, pero
     apilados como secciones (el título del menú pasa a ser encabezado de sección). */
  .menubar {
    display: none;
    position: absolute;
    top: 100%;
    right: 0.75rem;
    left: 0.75rem;
    flex-direction: column;
    gap: 0;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    padding: 0.25rem 0 0.5rem;
    background: var(--bg);
    border: 1px solid var(--gray-200);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  }
  .menubar.is-open { display: flex; }
  .menu__label {
    display: block;
    width: 100%;
    text-align: left;
    pointer-events: none;
    padding: 0.75rem 0.9rem 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--gray-400);
  }
  .menu.is-open > .menu__label { background: none; border-color: transparent; color: var(--gray-400); }
  .menu__panel, .menu.is-open > .menu__panel {
    display: block;
    position: static;
    min-width: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
  }
  .menu__item { min-height: 46px; white-space: normal; }
  #app { padding: 1.25rem 1rem 3rem; }
  .card { padding: 1.25rem; }
  .btn { min-height: 46px; }
  .side-panel { width: 100vw; }
  .usuario-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .usuario-row__acciones { justify-content: flex-start; }
}

dialog { border: none; border-radius: var(--radius); padding: 1.5rem; width: min(480px, 90vw); box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
dialog form { display: flex; flex-direction: column; }
.modal__acciones { display: flex; gap: 0.75rem; margin-top: 1rem; }

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 0.85rem;
  color: var(--fg);
  text-align: center;
}
.offline-banner[hidden] { display: none; }
.offline-banner__btn {
  border: 1px solid var(--gray-400);
  background: var(--bg);
  border-radius: var(--radius);
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.pin--pendiente circle { stroke: var(--gray-600); stroke-width: 2; stroke-dasharray: 4 3; }
.pin--pendiente text { opacity: 0.6; }

@media (prefers-color-scheme: dark) {
  /* Regla del ecosistema: nunca tema oscuro — se fuerza claro siempre. */
  :root {
    --bg: #ffffff;
    --fg: #111111;
  }
}
