:root {
  --navy: #1b2b44;
  --navy-2: #243652;
  --navy-3: #324765;
  --orange: #b5541f;          /* botones sobre fondo claro: 4,9:1 con blanco */
  --orange-h: #9a4519;
  --orange-vivo: #f0a06a;      /* acento sobre fondo oscuro */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #d9dfe8;
  --line-2: #e8ecf2;
  --ink: #16233a;
  --muted: #4a5a70;
  --ok: #1d6b45;
  --ok-bg: #e2f2e9;
  --warn: #8a5300;
  --warn-bg: #fdf0d9;
  --err: #a8321a;
  --err-bg: #fbe6e1;
  --info-bg: #e6edf6;
  --radius: 10px;
  --sombra: 0 1px 2px rgba(22, 35, 58, .06), 0 4px 14px rgba(22, 35, 58, .05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #0f1a2c; --surface: #172540; --line: #2b3d5c; --line-2: #22324d; --ink: #e8edf5; --muted: #a9b6c9;
    --orange: #e07b3f; --orange-h: #ee8d54; --ok: #6fd3a0; --ok-bg: #12382a; --warn: #f2c26b; --warn-bg: #3a2c10;
    --err: #ff9d87; --err-bg: #43201a; --info-bg: #1d2f4b; --navy: #0b1424; --navy-2: #172540;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Outfit", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px; line-height: 1.5; font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .6rem; }
a { color: var(--orange); }
.saltar { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.saltar:focus { left: 8px; }
:focus-visible { outline: 3px solid #2a6fb0; outline-offset: 2px; border-radius: 4px; }

/* cabecera */
.cab { background: var(--navy); color: #fff; }
.cab-int { max-width: 1240px; margin: 0 auto; padding: 0 16px; min-height: 60px; display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; font-size: 1.05rem; }
.marca svg { width: 30px; height: 30px; }
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: #cdd7e6; text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a[aria-current="page"] { background: var(--navy-2); color: #fff; }
.usuario { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: #cdd7e6; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--orange-vivo); color: var(--navy); display: grid; place-items: center; font-weight: 700; }
.btn-salir { background: none; border: 1px solid var(--navy-3); color: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-size: .9rem; }
.btn-salir:hover { background: var(--navy-2); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }
.titulo-pagina { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.sub { color: var(--muted); margin: 4px 0 0; }

/* pasos */
.pasos { display: flex; gap: 0; margin: 0 0 22px; padding: 0; list-style: none; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pasos li { flex: 1 1 150px; border-right: 1px solid var(--line-2); }
.pasos li:last-child { border-right: 0; }
.pasos a, .pasos span.paso { display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-decoration: none; color: var(--muted); font-size: .92rem; min-height: 52px; }
.pasos .n { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 600; flex: none; }
.pasos li.hecho .n { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.pasos li.actual { background: var(--info-bg); }
.pasos li.actual a, .pasos li.actual span.paso { color: var(--ink); font-weight: 600; }
.pasos li.actual .n { background: var(--navy); border-color: var(--navy); color: #fff; }
.pasos li.off span.paso { opacity: .65; }
.pasos small { display: block; font-weight: 400; font-size: .72rem; color: var(--muted); }

/* tarjetas y formularios */
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--sombra); margin-bottom: 18px; }
.tarjeta > h2 { margin-bottom: 4px; }
.tarjeta > .sub { margin-bottom: 14px; }
.fila { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 190px; flex: 1 1 190px; }
.campo label, .etq { font-size: .85rem; font-weight: 500; color: var(--muted); }
.campo small { color: var(--muted); font-size: .78rem; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input:not([type]), select {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid #8794a8; border-radius: 8px; padding: 9px 11px; min-height: 44px; width: 100%; }
input:focus-visible, select:focus-visible { outline: 3px solid #2a6fb0; outline-offset: 1px; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--navy); }
.btn { font: inherit; font-weight: 600; border-radius: 8px; border: 1px solid var(--navy); background: var(--surface); color: var(--navy); padding: 10px 18px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; justify-content: center; }
.btn:hover { background: var(--info-bg); }
.btn.primario { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primario:hover { background: var(--orange-h); }
.btn.chico { padding: 5px 12px; min-height: 34px; font-size: .88rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.acciones { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.acciones .espacio { flex: 1; }
.aviso { border-radius: 8px; padding: 12px 14px; margin: 0 0 14px; font-size: .94rem; border: 1px solid transparent; }
.aviso.info { background: var(--info-bg); border-color: #b9c9de; }
.aviso.ok { background: var(--ok-bg); border-color: #a8d5bc; color: var(--ok); }
.aviso.warn { background: var(--warn-bg); border-color: #ecca8f; color: var(--warn); }
.aviso.err { background: var(--err-bg); border-color: #e8b3a6; color: var(--err); }
.leyenda { background: var(--navy); color: #fff; border-radius: 8px; padding: 9px 14px; font-weight: 600; font-size: .85rem; letter-spacing: .02em; margin-bottom: 18px; }

/* tablas */
.tabla-caja { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { background: var(--bg); font-weight: 600; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td input, td select { min-height: 36px; padding: 5px 8px; font-size: .9rem; }
td input[type=number] { width: 90px; text-align: right; }
td select { min-width: 128px; }
#color { max-width: 360px; }
.fila > .campo { align-self: flex-start; }
.scroll-v { max-height: 420px; overflow: auto; }
.etiqueta { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--info-bg); color: var(--navy); }
.etiqueta.ok { background: var(--ok-bg); color: var(--ok); }
.etiqueta.warn { background: var(--warn-bg); color: var(--warn); }

/* panel de proyectos */
.vacio { text-align: center; padding: 46px 16px; color: var(--muted); }
.vacio h2 { color: var(--ink); margin-bottom: 6px; }
.fila-click { cursor: pointer; }
.fila-click:hover td { background: var(--info-bg); }

/* pestañas de nivel */
.tabs { display: inline-flex; gap: 4px; background: var(--line-2); padding: 4px; border-radius: 10px; margin-bottom: 14px; }
.tabs button { font: inherit; border: 0; background: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; min-height: 40px; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--sombra); }

/* visor de láminas */
.visor { position: relative; border: 1px solid var(--line); border-radius: 8px; background: #fff; overflow: hidden; height: 62vh; min-height: 360px; touch-action: none; cursor: grab; }
.visor.arrastrando { cursor: grabbing; }
.visor img { position: absolute; top: 0; left: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; }
.visor .ctl { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.visor .ctl button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 1.2rem; cursor: pointer; }
.visor .nota { position: absolute; left: 10px; bottom: 10px; background: rgba(27, 43, 68, .85); color: #fff; padding: 4px 10px; border-radius: 6px; font-size: .78rem; }
.leyenda-colores { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); margin: 10px 0 0; }
.leyenda-colores i { display: inline-block; width: 22px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* resultado */
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 18px; }
.metrica { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--sombra); }
.metrica .etq { text-transform: uppercase; letter-spacing: .05em; font-size: .75rem; }
.metrica .valor { font-size: 1.75rem; font-weight: 600; margin-top: 4px; }
.metrica.destacada { background: var(--navy); border-color: var(--navy); color: #fff; }
.metrica.destacada .etq { color: #b8c5da; }
.metrica small { color: var(--muted); }
.metrica.destacada small { color: #b8c5da; }
.barra { height: 8px; background: var(--line-2); border-radius: 4px; min-width: 90px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--orange); border-radius: 4px; }
details.sup { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 12px 16px; margin-bottom: 18px; }
details.sup summary { cursor: pointer; font-weight: 600; min-height: 32px; display: flex; align-items: center; }
details.sup ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); font-size: .92rem; }

/* acceso */
.acceso { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.acceso .lado { background: var(--navy); color: #fff; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 22px;
  background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 36px 36px; }
.acceso .lado h1 { font-size: 2.4rem; font-weight: 600; max-width: 14ch; }
.acceso .lado h1 em { color: var(--orange-vivo); font-style: normal; }
.acceso .lado p { color: #cdd7e6; max-width: 46ch; }
.acceso .lado ul { color: #cdd7e6; padding-left: 20px; max-width: 46ch; margin: 0; }
.acceso .lado li { margin-bottom: 6px; }
.acceso .form { display: grid; place-items: center; padding: 32px 20px; }
.acceso form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.acceso form .campo { flex: none; }
.cargando { display: inline-block; width: 18px; height: 18px; border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: gira .8s linear infinite; vertical-align: -3px; }
@keyframes gira { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .cargando { animation-duration: 3s; } }
.progreso { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--info-bg); border-radius: 8px; }
.drop { border: 2px dashed #8794a8; border-radius: 10px; padding: 34px 16px; text-align: center; background: var(--bg); }
.drop.sobre { background: var(--info-bg); border-color: var(--navy); }
.reglas { font-size: .92rem; color: var(--muted); }
.reglas ul { margin: 6px 0 0; padding-left: 20px; }
.dudas li { margin-bottom: 14px; }
.dudas .op { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dudas label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
@media (max-width: 860px) {
  .acceso { grid-template-columns: 1fr; }
  .acceso .lado { padding: 32px 22px; }
  .acceso .lado h1 { font-size: 1.8rem; }
  .nav { order: 3; flex-basis: 100%; }
  .visor { height: 52vh; }
}

/* lo oculto con el atributo hidden debe quedar oculto aunque la clase le dé display */
[hidden] { display: none !important; }

/* edición sobre el plano */
.visor .capa { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; overflow: visible; }
.visor.tocable { cursor: crosshair; }
.muros-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.ficha { position: sticky; top: 14px; max-height: calc(100vh - 28px); overflow: auto; }
.ficha h2 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ficha form { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.ficha .campo { flex: none; min-width: 0; }
.ficha .fila .campo { flex: 1 1 120px; }
.casilla { display: flex; gap: 8px; align-items: center; font-size: .92rem; }
.casilla input { width: 20px; height: 20px; }
.zona-peligro { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.btn.peligro { background: #b42318; border-color: #b42318; color: #fff; }
tr.elegida td { background: #fff4cc !important; }
.tabla-caja tbody tr[data-id] { cursor: pointer; }
@media (max-width: 900px) { .muros-grid { grid-template-columns: 1fr; } .ficha { position: static; max-height: none; } }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* herramientas del plano */
.barra-herr { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.barra-herr .buscar { display: flex; gap: 6px; }
.barra-herr .buscar input { width: 170px; min-height: 34px; padding: 4px 10px; }
.barra-herr .sep { width: 1px; height: 26px; background: var(--line); margin: 0 4px; }
.btn.activo, .btn[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* capas dibujadas */
.tabs .cuenta { color: var(--muted); font-weight: 500; }
select.chico { min-height: 34px; padding: 4px 8px; width: auto; }
.lista-tot { list-style: none; padding: 0; margin: 8px 0 12px; }
.lista-tot li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .92rem; }
#t-capa td select, #t-capa td input[type=text] { min-width: 0; }
#t-capa [data-k="zona"] { min-width: 110px; }
#t-capa [data-k="material"] { min-width: 190px; }
#t-capa [data-k="caida"], #t-capa [data-k="tipo"] { min-width: 150px; }

/* guardar */
.guardar-caja { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.guardar-caja .sub { font-size: .85rem; margin: 0; }

/* panel de administración */
.metricas-5 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
code.clave { font-size: 1.05rem; background: var(--surface); border: 1px solid var(--line); padding: 6px 10px; border-radius: 6px; letter-spacing: .04em; user-select: all; }
.partidas { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 12px 18px; }
.partidas select { width: 100%; }
fieldset.lista-chk { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; margin: 0 0 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 6px 18px; }
fieldset.lista-chk legend { font-weight: 600; padding: 0 6px; }
#t-rub input, #t-rub select { min-height: 34px; padding: 4px 8px; font-size: .88rem; }

/* registro y acceso con Google / correo */
.caja-reg { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; }
.caja-reg form { width: 100%; }
.caja-reg h2 { margin: 0; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #c7ccd4; }
.btn-google:hover { background: #f3f5f8; }
.btn-link { background: none; border: none; padding: 4px 0; color: var(--orange); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: underline; align-self: flex-start; }
.separador { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.separador::before, .separador::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.wa { display: flex; gap: 8px; }
.wa select { flex: 0 0 auto; max-width: 48%; }
.wa input { flex: 1 1 auto; min-width: 0; }
.casilla a { color: var(--orange); }
.fin-prueba { border-color: var(--orange); }
.fin-prueba p { margin: 8px 0; max-width: 62ch; }
.btn-wa { margin-top: 8px; }
.metricas-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.link-camp { font-size: .82rem; word-break: break-all; }
.ext-fila td { background: var(--info-bg); }
.nombre-usr { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .nombre-usr { display: none; } }
