/* ============================================================
   Radicampo — sistema de diseño "El Registro"
   Instrumento de campo oficial: lomo de expediente (riel oscuro
   con curvas de nivel grabadas + latón), lienzo marfil con textura
   topográfica, tipografía editorial IBM Plex, sello oficial e
   iconografía de trazo propia. 100% offline.
   ============================================================ */

@font-face { font-family:'Plex Serif'; src:url('/app/static/fonts/ibmplexserif-600.woff2') format('woff2'); font-weight:600; font-display:swap; }
@font-face { font-family:'Plex Serif'; src:url('/app/static/fonts/ibmplexserif-500.woff2') format('woff2'); font-weight:500; font-display:swap; }
@font-face { font-family:'Plex Sans'; src:url('/app/static/fonts/ibmplexsans-400.woff2') format('woff2'); font-weight:400; font-display:swap; }
@font-face { font-family:'Plex Sans'; src:url('/app/static/fonts/ibmplexsans-500.woff2') format('woff2'); font-weight:500; font-display:swap; }
@font-face { font-family:'Plex Sans'; src:url('/app/static/fonts/ibmplexsans-600.woff2') format('woff2'); font-weight:600; font-display:swap; }
@font-face { font-family:'Plex Sans'; src:url('/app/static/fonts/ibmplexsans-700.woff2') format('woff2'); font-weight:700; font-display:swap; }
@font-face { font-family:'Plex Mono'; src:url('/app/static/fonts/ibmplexmono-500.woff2') format('woff2'); font-weight:500; font-display:swap; }

:root {
  /* tinta / verdes */
  --pino:      #0c261a;   /* riel: casi negro-verde */
  --pino-2:    #12341f;   /* riel: base del degradado */
  --verde:     #1c6b43;
  --verde-osc: #114029;
  --verde-cl:  #e7f0e9;
  --verde-bd:  #c6dccd;
  --musgo:     #4d7a5b;

  /* papel / neutros */
  --marfil:    #f6f2e9;   /* lienzo de contenido */
  --marfil-2:  #efe9db;
  --papel:     #fffdf8;   /* superficie de hoja */
  --tinta:     #182319;
  --gris:      #5c6a5f;
  --gris-2:    #8a958c;
  --linea:     #e0dccf;   /* hairline cálida */
  --linea-2:   #cfc9b8;

  /* latón / sello oficial */
  --laton:     #b0842f;
  --laton-cl:  #d8b96a;
  --laton-tinte:#f3e9cf;
  --laton-bd:  #e3d09a;
  --laton-texto:#7a5a1a;  /* latón para texto pequeño: 6,1:1 sobre papel, 5,1:1 sobre el tinte */

  /* catastro (datos, coordenadas) */
  --catastro:  #2f4a62;
  --catastro-cl:#e7edf2;

  /* semáforo */
  --rojo:      #a3352c; --rojo-cl:#f6e6e2;
  --ambar:     #9a6b16; --ambar-cl:#f6ecd4;

  /* superficies de formulario / filas */
  --campo:     #fffefb;   /* fondo de inputs/selects */
  --fila-par:  #faf8f1;   /* fila par de tablas */

  /* geometría */
  --r:   16px;
  --r-sm:10px;
  --r-xs:7px;
  --sh-1: 0 1px 2px rgba(16,40,26,.05);
  --sh-2: 0 2px 8px rgba(16,40,26,.06), 0 14px 34px -18px rgba(16,40,26,.16);
  --sh-3: 0 10px 30px -6px rgba(16,40,26,.20), 0 30px 70px -20px rgba(16,40,26,.28);
  --ease: cubic-bezier(.22,.61,.36,1);
  --ring: 0 0 0 4px rgba(28,107,67,.16);
  color-scheme: light;
}

/* ============================================================
   Tema OSCURO — misma identidad "El Registro" (pino + latón),
   lienzo nocturno. Se activa con html[data-tema="oscuro"]
   (el JS resuelve "auto" según prefers-color-scheme).
   ============================================================ */
html[data-tema="oscuro"] {
  --verde:     #3f9e69;
  --verde-osc: #8fd0ab;   /* en oscuro, el "verde oscuro" es texto claro */
  --verde-cl:  #16291d;
  --verde-bd:  #2b4a36;
  --musgo:     #7aa588;

  --marfil:    #0f1712;   /* lienzo nocturno con tinte pino */
  --marfil-2:  #0b110d;
  --papel:     #17231a;   /* superficie de tarjeta */
  --tinta:     #e8e6d9;
  --gris:      #a4b0a6;
  --gris-2:    #77857a;
  --linea:     #263528;
  --linea-2:   #35473a;

  --laton:     #c9a24e;
  --laton-cl:  #e2c67f;
  --laton-tinte:#2c2413;
  --laton-bd:  #55461f;
  --laton-texto:#e2c67f;

  --catastro:  #8fb3d1;
  --catastro-cl:#15212b;

  --rojo:      #e08b7f; --rojo-cl:#33201b;
  --ambar:     #d9b165; --ambar-cl:#302713;

  --campo:     #101a13;
  --fila-par:  #131f16;

  --sh-1: 0 1px 2px rgba(0,0,0,.35);
  --sh-2: 0 2px 8px rgba(0,0,0,.35), 0 14px 34px -18px rgba(0,0,0,.55);
  --sh-3: 0 10px 30px -6px rgba(0,0,0,.5), 0 30px 70px -20px rgba(0,0,0,.65);
  --ring: 0 0 0 4px rgba(63,158,105,.28);
  color-scheme: dark;
}
html[data-tema="oscuro"] body::before {
  background:
    radial-gradient(900px 480px at 100% -8%, rgba(63,158,105,.08), transparent 60%),
    radial-gradient(700px 520px at -6% 108%, rgba(201,162,78,.07), transparent 60%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--tinta);
  font-size: 14.5px;
  line-height: 1.6;
  background: var(--marfil);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* textura topográfica muy sutil del lienzo (curvas de nivel + grano) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 480px at 100% -8%, rgba(28,107,67,.06), transparent 60%),
    radial-gradient(700px 520px at -6% 108%, rgba(176,132,47,.06), transparent 60%);
}

h1, h2, h3, h4 { font-family: 'Plex Serif', Georgia, serif; color: var(--tinta); letter-spacing: -.012em; line-height: 1.16; }

.mono { font-family: 'Plex Mono', ui-monospace, monospace; }
.eyebrow {
  font-family: 'Plex Mono', monospace; font-size: 10.5px; font-weight: 500;
  letter-spacing: .18em; text-transform: uppercase; color: var(--laton-texto);
}

/* iconos de trazo */
.ic { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; stroke-width: 1.7;
      fill: none; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.22em; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }

/* ============ App shell ============ */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; position: relative; z-index: 1; }

/* ---- Riel lateral: lomo del expediente ---- */
.rail {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, var(--pino) 0%, var(--pino-2) 100%);
  color: #d6e2d8; overflow: hidden;
  border-right: 1px solid #0a1f14;
}
.rail::before {   /* curvas de nivel grabadas en el lomo */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  color: rgba(216,185,106,.10);
  background: currentColor;
  -webkit-mask: url('/app/static/contours.svg') no-repeat -40px 40px / 460px auto;
          mask: url('/app/static/contours.svg') no-repeat -40px 40px / 460px auto;
  opacity: .9;
}
.rail::after {   /* filo de latón del lomo */
  content: ""; position: absolute; top: 0; right: 0; bottom: 0; width: 2px;
  background: linear-gradient(180deg, transparent, var(--laton) 20%, var(--laton-cl) 50%, var(--laton) 80%, transparent);
  opacity: .5;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 20px; position: relative; z-index: 1; }
.brand .seal { width: 42px; height: 42px; flex-shrink: 0; filter: drop-shadow(0 2px 5px rgba(0,0,0,.35)); }
.brand .wordmark { font-family: 'Plex Serif', serif; font-weight: 600; font-size: 22px; letter-spacing: -.02em; color: #f3efe4; line-height: 1; }
.brand .wordmark b { color: var(--laton-cl); font-weight: 600; }
.brand .sub { font-size: 10.5px; color: #93a89a; letter-spacing: .04em; margin-top: 3px; }

.rail-sep { height: 1px; margin: 6px 22px 12px; background: linear-gradient(90deg, transparent, rgba(216,185,106,.28), transparent); position: relative; z-index: 1; }

.nav { padding: 4px 14px; position: relative; z-index: 1; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 13px;
  width: 100%; padding: 11px 14px; border: none; background: none;
  border-radius: 11px; color: #b7c6ba; text-align: left; cursor: pointer;
  font-family: inherit; font-size: 14.5px; font-weight: 500;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.nav-item .ic { color: #8fa896; transition: color .18s var(--ease), transform .2s var(--ease); }
.nav-item:hover { background: rgba(255,255,255,.05); color: #eaf2ec; }
.nav-item:hover .ic { color: var(--laton-cl); transform: translateY(-1px); }
.nav-item.active { background: linear-gradient(90deg, rgba(216,185,106,.16), rgba(216,185,106,.03)); color: #fff; font-weight: 600; }
.nav-item.active .ic { color: var(--laton-cl); }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--laton-cl); box-shadow: 0 0 12px rgba(216,185,106,.6);
}

.rail-foot { margin-top: auto; padding: 16px 22px 20px; position: relative; z-index: 1; }
.rail-foot .lic {
  display: block; width: 100%; text-align: left; cursor: pointer;
  font-family: 'Plex Mono', monospace; font-size: 11px; color: #cdd8cf;
  background: rgba(255,255,255,.06); border: 1px solid rgba(216,185,106,.22);
  border-radius: 10px; padding: 9px 12px; transition: background .2s var(--ease), border-color .2s var(--ease);
}
.rail-foot .lic:hover { background: rgba(255,255,255,.11); border-color: rgba(216,185,106,.5); }
.rail-foot .lic .k { color: #8fa896; display: block; font-size: 9px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 2px; }
.rail-toggles { display: flex; flex-direction: column; gap: 2px; margin-top: 6px;
  border-top: 1px solid rgba(216,185,106,.14); padding-top: 8px; }
.rail-foot .ayuda {
  margin-top: 8px; display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: #93a89a; cursor: pointer; font-family: inherit;
  font-size: 12px; padding: 4px 2px; transition: color .18s var(--ease);
}
.rail-foot .ayuda:hover { color: var(--laton-cl); }

/* ---- Contenido ---- */
.main { padding: 34px 44px 60px; max-width: 1120px; width: 100%; }
section[id^="vista-"] { animation: viewIn .42s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* encabezado de vista */
.vhead { margin-bottom: 24px; }
.vhead h1 { font-size: 30px; font-weight: 600; }
.vhead .lead { color: var(--gris); font-size: 14.5px; margin-top: 6px; max-width: 66ch; }

/* ============ Sheets / dossiers ============ */
.card {
  position: relative; background: var(--papel);
  border: 1px solid var(--linea); border-radius: var(--r);
  box-shadow: var(--sh-1); padding: 26px 28px; margin-bottom: 22px;
  transition: box-shadow .28s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.card:hover { box-shadow: var(--sh-2); }
.card > h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.card > .sub { color: var(--gris); font-size: 13px; margin-bottom: 18px; max-width: 70ch; }
/* hoja destacada: filo de latón arriba */
.card.sello::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  border-radius: var(--r) var(--r) 0 0;
  background: linear-gradient(90deg, var(--laton), var(--laton-cl) 60%, var(--laton));
}

.cita-norma {
  display: inline-block; font-family: 'Plex Mono', monospace; font-size: 10.5px; letter-spacing: .02em;
  color: var(--laton-texto); background: var(--laton-tinte);
  border: 1px solid var(--laton-bd); border-radius: 5px; padding: 1px 7px; margin-left: 6px; vertical-align: middle;
}

/* ============ Formularios ============ */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px 22px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--tinta); letter-spacing: .005em; }
.field .ayuda { font-size: 11.5px; color: var(--gris); line-height: 1.45; }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 14px; color: var(--tinta);
  padding: 10px 13px; border: 1.5px solid var(--linea-2); border-radius: var(--r-sm);
  background: var(--campo); outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease), background .18s;
}
.field input::placeholder, .field textarea::placeholder { color: var(--gris-2); }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--linea-2); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--verde); background: #fff; box-shadow: var(--ring);
}
.field textarea { resize: vertical; min-height: 78px; }

/* ============ Botones ============ */
.btn {
  position: relative; overflow: hidden; font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--r-sm); border: 1.5px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease),
              transform .09s var(--ease), color .18s;
}
.btn .ic { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px) scale(.995); }
.btn:focus-visible { outline: 3px solid rgba(28,107,67,.4); outline-offset: 2px; }
.btn-primary { background: var(--verde); color: #fff; box-shadow: 0 2px 10px -2px rgba(28,107,67,.5); }
.btn-primary:hover { background: var(--verde-osc); box-shadow: 0 6px 18px -4px rgba(28,107,67,.55); transform: translateY(-1px); }
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.32), transparent);
  transform: skewX(-18deg); transition: left .55s var(--ease); pointer-events: none;
}
.btn-primary:hover::after { left: 120%; }
.btn-secundario { background: var(--papel); color: var(--verde-osc); border-color: var(--verde-bd); }
.btn-secundario:hover { background: var(--verde-cl); border-color: var(--verde); transform: translateY(-1px); }
.btn-laton { background: var(--laton-tinte); color: #7c5a15; border-color: var(--laton-bd); }
.btn-laton:hover { background: #efe0be; border-color: var(--laton); }
.btn-ghost { background: none; color: var(--gris); }
.btn-ghost:hover { color: var(--tinta); background: var(--marfil-2); }
.btn-peligro { background: var(--rojo-cl); color: var(--rojo); }
.btn-peligro:hover { background: #f2d8d1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-grande { font-size: 15px; padding: 13px 26px; }
.fila-acciones { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }

/* ============ Métricas del panel ============ */
.metricas { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 20px; }
.metrica {
  position: relative; background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--r); padding: 17px 18px 16px; overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
  animation: fadeUp .5s var(--ease) both;
}
.metrica:hover { transform: translateY(-3px); box-shadow: var(--sh-2); border-color: var(--verde-bd); }
.metrica .k { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--gris); }
.metrica .k .ic { width: 15px; height: 15px; color: var(--musgo); }
.metrica .v { font-family: 'Plex Serif', serif; font-size: 30px; font-weight: 600; color: var(--verde-osc); margin-top: 6px; line-height: 1; }
.metrica .u { font-size: 11px; color: var(--gris); margin-top: 5px; }

/* ============ Lista de predios ============ */
.predio-card {
  display: flex; align-items: center; gap: 18px; padding: 17px 22px; margin-bottom: 12px;
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r); box-shadow: var(--sh-1);
  cursor: pointer; animation: fadeUp .45s var(--ease) both;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .16s var(--ease);
}
.predio-card:hover { border-color: var(--verde-bd); box-shadow: var(--sh-2); transform: translateY(-2px); }
.predio-card .nombre { font-family: 'Plex Serif', serif; font-weight: 600; font-size: 16.5px;
  background: none; border: 0; padding: 0; color: inherit; text-align: left; cursor: pointer; max-width: 100%;
  white-space: normal; line-height: 1.3; border-radius: 4px; }
.predio-card .nombre:hover { text-decoration: underline; text-decoration-color: var(--laton); text-underline-offset: 3px; }
.predio-card .nombre:focus-visible { outline: 2px solid var(--verde); outline-offset: 3px; }
.predio-card .meta { color: var(--gris); font-size: 12.5px; margin-top: 2px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.predio-card .meta .mono { color: var(--catastro); }
.predio-card .spacer { flex: 1; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.anillo {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; display: grid; place-items: center;
  background: conic-gradient(var(--anillo-color, var(--verde)) calc(var(--pct, 0) * 1%), var(--marfil-2) 0);
  animation: popIn .5s var(--ease) both;
}
@keyframes popIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
.anillo > div {
  background: var(--papel); width: 37px; height: 37px; border-radius: 50%; display: grid; place-items: center;
  font-family: 'Plex Mono', monospace; font-size: 11px; font-weight: 700; color: var(--tinta);
}

/* chips */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: .01em; border-radius: 999px; padding: 3px 11px; }
.chip .ic { width: 12px; height: 12px; }
.chip-verde { background: var(--verde-cl); color: var(--verde-osc); }
.chip-ambar { background: var(--ambar-cl); color: var(--ambar); }
.chip-rojo  { background: var(--rojo-cl); color: var(--rojo); }
.chip-gris  { background: var(--marfil-2); color: var(--gris); }
.chip-laton { background: var(--laton-tinte); color: #7c5a15; border: 1px solid var(--laton-bd); }

/* barra de herramientas de la lista */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.buscador { position: relative; flex: 1; min-width: 200px; }
.buscador .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gris-2); width: 17px; height: 17px; }
.buscador input { width: 100%; padding-left: 38px; font-family: inherit; font-size: 14px; padding-top: 10px; padding-bottom: 10px;
  border: 1.5px solid var(--linea-2); border-radius: var(--r-sm); background: #fffefb; outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease); }
.buscador input:focus { border-color: var(--verde); box-shadow: var(--ring); }

/* ============ Wizard ============ */
.wizard-steps { display: flex; gap: 2px; margin: 20px 0 24px; border-bottom: 1.5px solid var(--linea); overflow-x: auto; }
.wstep {
  padding: 11px 15px; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--gris);
  background: none; border: none; border-bottom: 3px solid transparent; margin-bottom: -1.5px;
  white-space: nowrap; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.wstep .ic { width: 15px; height: 15px; }
.wstep:hover { color: var(--verde-osc); }
.wstep.active { color: var(--verde-osc); border-bottom-color: var(--laton); }
.wstep.done { color: var(--verde); }
/* Punto de aviso cuando al paso le faltan campos mínimos para un expediente serio. */
.wstep.wstep-falta::after {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--ambar); display: inline-block; margin-left: 1px;
}
.paso { animation: viewIn .32s var(--ease) both; }
.wizard-nav { display: flex; align-items: center; gap: 10px; margin-top: 20px;
  padding-top: 16px; border-top: 1px solid var(--linea); }
.mas-opciones { margin-top: 10px; }
.mas-opciones > summary { cursor: pointer; font-size: 13px; color: var(--gris);
  list-style: none; user-select: none; display: inline-flex; align-items: center; gap: 6px; }
.mas-opciones > summary::before { content: "▸"; font-size: 11px; transition: transform .15s var(--ease); }
.mas-opciones[open] > summary::before { transform: rotate(90deg); }
.mas-opciones > summary:hover { color: var(--verde-osc); }
.mas-opciones > summary::-webkit-details-marker { display: none; }

/* anexo fotográfico */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.foto-card { position: relative; background: var(--papel); border: 1px solid var(--linea);
  border-radius: var(--r-sm); padding: 8px; box-shadow: var(--sh-1); }
.foto-card img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--r-xs); display: block; }
.foto-card input { width: 100%; margin-top: 6px; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--linea-2); border-radius: 6px; background: var(--campo); color: var(--tinta); font-family: inherit; }
.foto-card > button { position: absolute; top: 4px; right: 4px; background: var(--papel); border-radius: 50%; padding: 4px; }

/* ============ Tablas ============ */
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; overflow: hidden; border-radius: var(--r-sm); }
.tabla th { background: var(--verde-osc); color: #eaf3ec; text-align: left; padding: 10px 12px; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; }
.tabla td { padding: 10px 12px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tr:nth-child(even) td { background: var(--fila-par); }
.tabla tr:hover td { background: var(--verde-cl); }
.tabla .cientifico { font-style: italic; color: var(--gris); font-size: 12px; }

/* ============ Checklist ============ */
.check-item {
  display: flex; align-items: flex-start; gap: 13px; padding: 13px 15px; margin-bottom: 9px;
  border: 1px solid var(--linea); border-radius: var(--r-sm); background: var(--papel);
  transition: border-color .18s var(--ease), background .18s var(--ease), transform .14s var(--ease);
}
.check-item:hover { transform: translateX(2px); border-color: var(--verde-bd); }
.check-item .estado { flex-shrink: 0; display: grid; place-items: center; width: 22px; height: 22px; }
.check-item .estado .ic { width: 20px; height: 20px; }
.check-item .titulo { font-weight: 600; font-size: 13.5px; }
.check-item .desc { color: var(--gris); font-size: 12px; }
.check-item.ok { border-color: var(--verde-bd); background: #f4faf6; }
.st-ok  { color: var(--verde); }
.st-warn{ color: var(--ambar); }
.st-bad { color: var(--rojo); }

/* ============ Coordenadas ============ */
.coord-row { display: flex; gap: 8px; align-items: center; margin-bottom: 7px; }
.coord-row input { width: 165px; }
.coord-row .idx { width: 34px; font-family: 'Plex Mono', monospace; font-weight: 700; color: var(--laton); font-size: 12.5px; }
.croquis-preview { max-width: 100%; border: 1px solid var(--linea); border-radius: var(--r-sm); margin-top: 12px; box-shadow: var(--sh-1); animation: fadeUp .4s var(--ease) both; }

/* ============ Documentos ============ */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 15px; }
.doc-card {
  position: relative; border: 1px solid var(--linea); border-radius: var(--r); padding: 20px;
  background: var(--papel); display: flex; flex-direction: column; gap: 10px; overflow: hidden;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .16s var(--ease);
}
.doc-card:hover { border-color: var(--verde-bd); box-shadow: var(--sh-2); transform: translateY(-3px); }
.doc-card .ico { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px;
  background: var(--verde-cl); color: var(--verde); }
.doc-card .ico .ic { width: 22px; height: 22px; }
.doc-card .titulo { font-family: 'Plex Serif', serif; font-weight: 600; font-size: 15px; }
.doc-card .desc { color: var(--gris); font-size: 12px; flex: 1; line-height: 1.5; }

/* ============ Avisos ============ */
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 15px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 14px; border: 1px solid transparent; animation: fadeUp .35s var(--ease) both; }
.aviso .ic { width: 18px; height: 18px; margin-top: 1px; flex-shrink: 0; }
.aviso-ambar { background: var(--ambar-cl); color: var(--ambar); border-color: #e6d19f; }
.aviso-verde { background: var(--verde-cl); color: var(--verde-osc); border-color: var(--verde-bd); }
.aviso-rojo  { background: var(--rojo-cl); color: var(--rojo); border-color: #e6c2ba; }

/* ============ Toast ============ */
#toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 100; display: flex; align-items: center; gap: 10px;
  background: var(--tinta); color: #fff; padding: 13px 20px; border-radius: 12px; font-size: 13.5px;
  box-shadow: var(--sh-3); border-left: 3px solid var(--laton-cl);
  opacity: 0; transform: translateY(10px) scale(.98); pointer-events: none;
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
#toast.show { opacity: 1; transform: none; }

/* ============ Modal ============ */
.modal-fondo { position: fixed; inset: 0; z-index: 90; background: rgba(12,38,26,.55); backdrop-filter: blur(3px); display: grid; place-items: center; animation: fadeIn .2s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal { position: relative; background: var(--papel); border-radius: 18px; padding: 30px 32px; width: min(560px, 92vw); max-height: 86vh; overflow-y: auto; box-shadow: var(--sh-3); animation: modalIn .32s var(--ease) both; }
.modal::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; border-radius: 18px 18px 0 0; background: linear-gradient(90deg, var(--laton), var(--laton-cl) 60%, var(--laton)); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 20px; font-weight: 600; margin-bottom: 12px; }

/* vista previa del informe */
.preview-doc { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--r-sm); padding: 28px 32px; font-size: 13.5px; box-shadow: var(--sh-1); }
.preview-doc h4 { color: var(--verde-osc); margin: 15px 0 5px; font-size: 15px; }
.preview-doc p { margin-bottom: 8px; text-align: justify; }

.oculto { display: none !important; }
footer { animation: fadeIn .6s var(--ease) both; }

/* ============ Panel 3D "Tu territorio" ============ */
.territorio {
  position: relative; border-radius: var(--r); overflow: hidden; margin-bottom: 22px;
  background: radial-gradient(120% 140% at 20% 0%, #14432b 0%, #0c2a1b 55%, #081f14 100%);
  border: 1px solid #0a2016; box-shadow: var(--sh-2);
  min-height: 220px; display: flex; align-items: stretch;
}
.territorio canvas { display: block; width: 100%; height: 260px; }
.territorio .glass {
  position: absolute; left: 26px; top: 24px; z-index: 2; color: #eaf3ec; pointer-events: none;
  text-shadow: 0 1px 10px rgba(0,0,0,.5);
}
.territorio .glass .eyebrow { color: var(--laton-cl); }
.territorio .glass .big { font-family: 'Plex Serif', serif; font-size: 34px; font-weight: 600; line-height: 1.05; margin-top: 8px; }
.territorio .glass .small { font-size: 12.5px; color: #a9c2af; margin-top: 4px; }

/* ============ Movimiento reducido ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .rail::before { display: none; }
  .brand { padding: 14px 18px; }
  .rail-sep { display: none; }
  .nav { flex-direction: row; flex: 1; overflow-x: auto; padding: 10px; }
  .nav-item.active::before { display: none; }
  .rail-foot { margin: 0; padding: 10px 18px; }
  .main { padding: 22px 18px 48px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

/* ============================================================
   v1.11 — «Instrumento»: cabecera fija del expediente, stepper
   numerado con progreso, autoguardado visible, transiciones de
   vista, paleta de comandos, vista previa, planes de licencia,
   estados de carga y vacíos. Mismo sistema «El Registro».
   ============================================================ */

/* ---- pasos del expediente: entrada según la dirección ---- */
.paso { animation: pasoDer .3s var(--ease) both; }
.paso.entra-izq { animation-name: pasoIzq; }
@keyframes pasoDer { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes pasoIzq { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }

/* ---- cabecera fija del expediente ---- */
.wizard-card { padding-top: 0; overflow: visible; }
.wizard-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  margin: 0 -28px 0; padding: 18px 28px 14px; background: var(--papel);
  border-bottom: 1px solid var(--linea); border-radius: var(--r) var(--r) 0 0;
  backdrop-filter: blur(6px);
}
.wizard-head .wizard-titulo { flex: 1; min-width: 0; }
.wizard-head h2 { font-size: 20px; font-weight: 600; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wizard-sub { font-family: 'Plex Mono', monospace; font-size: 11px; color: var(--gris); letter-spacing: .02em; margin-top: 2px; min-height: 14px; }
.wizard-sub:empty { display: none; }

.estado-guardado {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--gris);
  padding: 6px 11px; border-radius: 999px; border: 1px solid var(--linea); background: var(--marfil);
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease); white-space: nowrap;
}
.estado-guardado .punto { width: 7px; height: 7px; border-radius: 50%; background: var(--gris-2); transition: background .2s; }
.estado-guardado.sucio { color: var(--ambar); border-color: #e6d19f; background: var(--ambar-cl); }
.estado-guardado.sucio .punto { background: var(--ambar); }
.estado-guardado.guardando .punto { background: var(--verde); animation: pulso 1s ease-in-out infinite; }
.estado-guardado.guardado { color: var(--verde-osc); border-color: var(--verde-bd); background: var(--verde-cl); }
.estado-guardado.guardado .punto { background: var(--verde); }
.estado-guardado.error { color: var(--rojo); border-color: #e6c2ba; background: var(--rojo-cl); }
.estado-guardado.error .punto { background: var(--rojo); }
@keyframes pulso { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .5; } }

.progreso {
  --pct: 0; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0;
  background: conic-gradient(var(--verde) calc(var(--pct) * 1%), var(--marfil-2) 0);
  transition: background .5s var(--ease);
}
.progreso > span {
  width: 34px; height: 34px; border-radius: 50%; background: var(--papel); display: grid; place-items: center;
  font-family: 'Plex Mono', monospace; font-size: 10.5px; font-weight: 700; color: var(--verde-osc);
}
.progreso.completo { background: conic-gradient(var(--laton) 100%, var(--laton) 0); }
.progreso.completo > span { color: #7c5a15; }

/* ---- stepper numerado ---- */
.wizard-steps { position: relative; display: flex; gap: 0; margin: 18px 0 22px; border-bottom: none; overflow-x: auto; padding: 4px 0 6px; }
.wizard-steps::before {
  content: ""; position: absolute; left: 30px; right: 30px; top: 21px; height: 2px;
  background: var(--linea); z-index: 0;
}
.wizard-steps::after {
  content: ""; position: absolute; left: 30px; top: 21px; height: 2px; z-index: 0;
  width: calc((100% - 60px) * var(--avance, 0)); background: linear-gradient(90deg, var(--verde), var(--laton));
  transition: width .45s var(--ease);
}
.wstep {
  position: relative; z-index: 1; flex: 1; min-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 4px 6px 2px; border: none; border-bottom: none; margin: 0; background: none; color: var(--gris);
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: color .18s var(--ease);
}
.wstep .num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--papel); border: 2px solid var(--linea-2); color: var(--gris);
  font-family: 'Plex Mono', monospace; font-size: 12px; font-weight: 700;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.wstep .lbl { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.wstep .lbl small { font-weight: 500; font-size: 10.5px; color: var(--gris-2); margin-top: 2px; }
.wstep:hover .num { border-color: var(--verde); color: var(--verde-osc); transform: translateY(-1px); }
.wstep.active { color: var(--verde-osc); }
.wstep.active .num { background: var(--verde); border-color: var(--verde); color: #fff; box-shadow: 0 0 0 5px rgba(28,107,67,.14); }
.wstep.done .num { background: var(--verde-cl); border-color: var(--verde); color: var(--verde); }
.wstep.done .num::before { content: "✓"; }
.wstep.done .num span { display: none; }
.wstep.wstep-falta::after { position: absolute; top: 2px; right: calc(50% - 22px); margin: 0; width: 8px; height: 8px; border: 2px solid var(--papel); }
.wstep:focus-visible { outline: none; }
.wstep:focus-visible .num { box-shadow: 0 0 0 4px rgba(28,107,67,.35); }

/* ---- botones ocupados (generando…) ---- */
.btn.cargando { pointer-events: none; color: transparent !important; }
.btn.cargando > * { visibility: hidden; }
.btn.cargando::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: calc(50% - 8px); top: calc(50% - 8px);
  border-radius: 50%; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; animation: gira .7s linear infinite;
}
.btn-secundario.cargando::before, .btn-ghost.cargando::before, .btn-laton.cargando::before { border-color: rgba(28,107,67,.25); border-top-color: var(--verde); }
@keyframes gira { to { transform: rotate(360deg); } }

/* ---- toasts con tipo ---- */
#toast .ic { width: 18px; height: 18px; flex-shrink: 0; }
#toast.ok { border-left-color: #6fcf97; }
#toast.err { border-left-color: #e08b7f; }
#toast.info { border-left-color: var(--laton-cl); }

/* ---- paleta de comandos ---- */
.paleta-fondo { position: fixed; inset: 0; z-index: 95; background: rgba(12,38,26,.45); backdrop-filter: blur(3px); display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; animation: fadeIn .15s var(--ease) both; }
.paleta { width: min(640px, 94vw); background: var(--papel); border-radius: 16px; box-shadow: var(--sh-3); border: 1px solid var(--linea); overflow: hidden; animation: modalIn .22s var(--ease) both; }
.paleta-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--linea); }
.paleta-input .ic { color: var(--laton); width: 20px; height: 20px; }
.paleta-input input { flex: 1; border: none; outline: none; background: none; font-family: inherit; font-size: 16px; color: var(--tinta); }
.paleta-input input::placeholder { color: var(--gris-2); }
.paleta kbd, .atajos kbd, .paleta-pie kbd {
  font-family: 'Plex Mono', monospace; font-size: 10.5px; color: var(--gris); background: var(--marfil-2);
  border: 1px solid var(--linea-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
}
.paleta-lista { max-height: 50vh; overflow-y: auto; padding: 6px; }
.paleta-grupo { font-family: 'Plex Mono', monospace; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--laton); padding: 8px 12px 4px; }
.paleta-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; cursor: pointer;
  color: var(--tinta); font-size: 14px; transition: background .12s var(--ease);
}
.paleta-item .ic { width: 18px; height: 18px; color: var(--musgo); flex-shrink: 0; }
.paleta-item .sec { color: var(--gris); font-size: 12px; margin-left: auto; white-space: nowrap; }
.paleta-item:hover, .paleta-item.activo { background: var(--verde-cl); }
.paleta-item.activo .ic { color: var(--verde); }
.paleta-vacio { padding: 22px; text-align: center; color: var(--gris); font-size: 13px; }
.paleta-pie { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--linea); font-size: 11.5px; color: var(--gris); background: var(--marfil); }

/* ---- atajos ---- */
.atajos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; font-size: 13px; margin: 6px 0 14px; }
.atajos div { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--linea); }
.atajos kbd + kbd { margin-left: 3px; }

/* ---- vista previa del expediente ---- */
.modal-preview { width: min(1100px, 96vw); height: 92vh; max-height: 92vh; display: flex; flex-direction: column; padding: 22px 24px 18px; }
.modal-preview .preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.modal-preview .preview-head h3 { margin-bottom: 2px; }
.modal-preview .preview-head .sub { color: var(--gris); font-size: 12.5px; max-width: 60ch; }
.modal-preview iframe { flex: 1; width: 100%; border: 1px solid var(--linea); border-radius: var(--r-sm); background: #525659; }

/* ---- documentos: dos acciones por tarjeta ---- */
.doc-card .acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.doc-card .acciones .btn { flex: 1; justify-content: center; padding-left: 12px; padding-right: 12px; }
.doc-card .nuevo { position: absolute; top: 12px; right: 12px; }
.doc-card.destacada { border-color: var(--laton-bd); background: linear-gradient(180deg, var(--laton-tinte), var(--papel) 60%); }
.doc-card.destacada .ico { background: var(--laton-tinte); color: #7c5a15; border: 1px solid var(--laton-bd); }

/* ---- lista de predios: acciones rápidas ---- */
.predio-card .rapidas { display: flex; gap: 6px; opacity: 0; transform: translateX(6px); transition: opacity .18s var(--ease), transform .18s var(--ease); }
.predio-card:hover .rapidas, .predio-card:focus-within .rapidas { opacity: 1; transform: none; }
.predio-card .rapidas .btn { font-size: 12px; padding: 6px 10px; }
.predio-card .estado-doc { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
@media (hover: none) { .predio-card .rapidas { opacity: 1; transform: none; } }

/* ---- estados vacíos y esqueletos ---- */
.vacio { text-align: center; padding: 42px 24px; color: var(--gris); }
.vacio .ic { width: 44px; height: 44px; color: var(--laton); stroke-width: 1.3; margin-bottom: 8px; }
.vacio h3 { font-size: 18px; margin-bottom: 6px; }
.vacio p { max-width: 46ch; margin: 0 auto 16px; font-size: 13.5px; }
.esqueleto { position: relative; overflow: hidden; background: var(--marfil-2); border-radius: var(--r-sm); min-height: 14px; }
.esqueleto::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: brillo 1.3s ease-in-out infinite;
}
html[data-tema="oscuro"] .esqueleto::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); }
@keyframes brillo { to { transform: translateX(100%); } }
.esq-card { display: flex; align-items: center; gap: 18px; padding: 17px 22px; margin-bottom: 12px; border: 1px solid var(--linea); border-radius: var(--r); background: var(--papel); }
.esq-card .esqueleto.circ { width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0; }

/* ---- planes de licencia ---- */
.planes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 12px 0 6px; }
.plan .btn { white-space: normal; text-align: center; line-height: 1.25; }
.plan {
  position: relative; border: 1px solid var(--linea); border-radius: 12px; padding: 13px 13px 12px; background: var(--papel);
  display: flex; flex-direction: column; gap: 4px; transition: border-color .18s var(--ease), transform .18s var(--ease), box-shadow .18s var(--ease);
}
.plan:hover { border-color: var(--verde-bd); transform: translateY(-2px); box-shadow: var(--sh-2); }
.plan .nombre { font-weight: 600; font-size: 13px; }
.plan .precio { font-family: 'Plex Serif', serif; font-size: 20px; font-weight: 600; color: var(--verde-osc); }
.plan .det { font-size: 11px; color: var(--gris); flex: 1; line-height: 1.4; }
.plan .btn { margin-top: 8px; justify-content: center; font-size: 12.5px; padding: 8px 10px; text-decoration: none; }
.plan.destacado { border-color: var(--laton-bd); background: linear-gradient(180deg, var(--laton-tinte), var(--papel) 70%); }
.plan.destacado .etq { position: absolute; top: -9px; left: 12px; font-family: 'Plex Mono', monospace; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; background: var(--laton); color: #fff; padding: 2px 8px; border-radius: 999px; }
.inst-id { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; color: var(--gris); }
.inst-id code { font-family: 'Plex Mono', monospace; font-size: 13px; color: var(--tinta); background: var(--marfil-2); border: 1px solid var(--linea-2); border-radius: 6px; padding: 3px 9px; user-select: all; letter-spacing: .04em; }

/* ---- métricas con entrada escalonada ---- */
.metrica:nth-child(2) { animation-delay: .06s; } .metrica:nth-child(3) { animation-delay: .12s; } .metrica:nth-child(4) { animation-delay: .18s; }

/* ---- foco visible uniforme ---- */
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: none; }
.nav-item:focus-visible, .rail-foot button:focus-visible { outline: 2px solid var(--laton-cl); outline-offset: 2px; border-radius: 10px; }

/* ---- selección de trimestre en el modal ---- */
.trimestres { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 10px; }
.trimestres label { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border: 1.5px solid var(--linea-2); border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--gris); text-align: center; transition: border-color .15s var(--ease), background .15s var(--ease), color .15s; }
.trimestres label small { font-weight: 500; font-size: 10px; color: var(--gris-2); }
.trimestres label:has(input:checked) { border-color: var(--verde); background: var(--verde-cl); color: var(--verde-osc); }
.trimestres input { position: absolute; opacity: 0; pointer-events: none; }

@media (max-width: 900px) {
  .wizard-head { margin: 0 -18px; padding: 12px 18px; flex-wrap: wrap; }
  .wizard-head .wizard-titulo { flex-basis: 100%; }
  .atajos { grid-template-columns: 1fr; }
  .trimestres { grid-template-columns: 1fr 1fr; }
}

/* ---- validador de radicación (semáforo con la frase oficial) ---- */
.val-semaforo{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:10px;margin:0 0 10px;font-size:13.5px;line-height:1.5;border:1px solid transparent}
.val-verde{background:var(--verde-suave,#e6f0e8);color:var(--verde-osc,#0f4d32);border-color:#cfe0d3}
.val-ambar{background:#fbf3e2;color:#6b4a0f;border-color:#ecd9a8}
.val-rojo{background:#fbe9e7;color:#7a1f14;border-color:#f0c4bd}
.val-fuente{font-size:11.5px;margin-top:3px;opacity:.85}
.val-fuente a{color:inherit;text-decoration:underline}
.fecha-adjunto{display:flex;align-items:center;gap:6px;font-size:12px;flex-shrink:0;margin-left:8px}
.fecha-adjunto input[type=date]{font:inherit;font-size:12px;padding:3px 6px;border:1px solid var(--gris-claro,#cfd6d1);border-radius:6px}
