/* App TOPOTEC. Letra del sistema, sin librerías: carga rápido incluso con datos lentos. */
:root {
  --navy: #0F2A3A;
  --navy-deep: #0B1F2B;
  --ink: #1C1C1E;
  --ink-2: #3A3A3F;
  --muted: #6B6B70;
  --ground: #F2F2F7;
  --card: #FFFFFF;
  --line: #ECECEF;
  --fill: #E3E3E8;
  --tint: #EAF0F4;
  --green: #1E6B3C;
  --green-bg: #E6F2EA;
  --red: #E2443A;
  --red-ink: #B3261E;
  --red-bg: #FDECEB;
  /* Colores que cambian en modo oscuro (ver el final del archivo). */
  --accent: var(--navy);
  --accent-bg: var(--navy);
  --seg-on: #fff;
  --seg-on-ink: var(--navy);
  --field-focus: #FAFBFC;
  --chip-line: #DCDCE0;
  --dashed: #AEAEB2;
  --media: #D9D9DE;
  --backdrop: rgba(0, 0, 0, 0.36);
  --sheet: #fff;
  --sheet-group: var(--ground);
  --sheet-line: #E2E2E7;
  --sheet-focus: #EDEDF1;
  --grabber: #D1D1D6;
  --locked: #C7C7CC;
  --bar: rgba(255, 255, 255, 0.94);
  --bar-line: #DCDCE0;
  --toast: #1C1C1E;
  --skel-a: #E9E9EE;
  --skel-b: #F4F4F7;
  --switch-off: #8E8E93;
  --flash: rgba(15, 42, 58, 0.35);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Margen lateral de la pantalla: 20 px como las apps de iPhone, 24 px en celulares grandes. */
  --gutter: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
img { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

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

.app {
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(100px + var(--safe-b));
  outline: none;
}

/* Pantallas */
.screen {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: calc(18px + var(--safe-t)) var(--gutter) 8px;
}

.title {
  margin: 0;
  font-size: 34px;
  line-height: 41px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 21px;
  color: var(--muted);
}

.h2 {
  margin: 0;
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.caps {
  margin: 4px 4px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 44px;
  margin: -6px 0 -6px -6px;
  padding-right: 8px;
  color: var(--accent);
  text-decoration: none;
  font-size: 17px;
}

/* Inicio */
.hero {
  position: relative;
  overflow: hidden;
  padding: calc(18px + var(--safe-t)) var(--gutter) 70px;
  background: var(--navy-deep);
  color: #fff;
}

.hero-lines {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 560px;
  height: 100%;
  pointer-events: none;
}

.hero-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 20px;
  background: #fff;
}

.hero-actions { display: flex; gap: 8px; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

.install-btn {
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 22px;
  background: #fff;
  color: var(--navy-deep);
  font-size: 15px;
  font-weight: 600;
}

.hero h1 {
  position: relative;
  margin: 44px 0 0;
  font-size: 36px;
  line-height: 40px;
  font-weight: 800;
  letter-spacing: -1px;
}

.hero p {
  position: relative;
  margin: 14px 0 0;
  max-width: 420px;
  font-size: 16px;
  line-height: 23px;
  color: #C7D6E0;
}

.pills {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 13px;
  font-weight: 600;
}

.stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -38px var(--gutter) 0;
}

.stat {
  padding: 14px 12px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(11, 31, 43, 0.12);
}

.stat-num {
  display: flex;
  align-items: center;
  height: 32px;
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--accent);
}

.stat-num.ok { color: var(--green); }

.stat-label {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 15px;
  color: var(--muted);
}

.section { padding: 26px var(--gutter) 0; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.see-all {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.rail {
  display: flex;
  gap: 10px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 14px var(--gutter) 4px;
  scroll-padding-inline: var(--gutter);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar { display: none; }

.area-card {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 136px;
  padding: 14px;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  scroll-snap-align: start;
}

.area-card span:last-child {
  font-size: 15px;
  line-height: 19px;
  font-weight: 600;
}

/* Servicios del inicio: son botones que abren la cotización con el servicio elegido. */
.service-card {
  width: 156px;
  border: 0;
  text-align: left;
  cursor: pointer;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

.tile {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--tint);
  color: var(--accent);
}

/* Color por área, para los íconos del inicio y los avatares de Personal. */
:is(.tile, .avatar)[data-area="topografia"] { background: #E6EEF7; color: #1F4E79; }
:is(.tile, .avatar)[data-area="deteccion"] { background: #EEE8F7; color: #4B2E83; }
:is(.tile, .avatar)[data-area="seguridad"] { background: #FDF0E3; color: #8A4B08; }
:is(.tile, .avatar)[data-area="civil"] { background: #E8F1EC; color: #1E6B3C; }
:is(.tile, .avatar)[data-area="mecanica"] { background: #F1ECE6; color: #6B4E2E; }
:is(.tile, .avatar)[data-area="electricidad"] { background: #FBF4DA; color: #7A5C00; }
:is(.tile, .avatar)[data-area="gestion"] { background: #E9EEF1; color: #34495E; }

.list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  border-radius: 18px;
  background: var(--card);
  overflow: hidden;
}

.list > li {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.list > li:last-child { border-bottom: 0; }

.eq-list { margin-top: 12px; }

.eq-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.eq-row:last-child { border-bottom: 0; }
.eq-row > svg { flex: none; color: var(--muted); }

.eq-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--tint);
  color: var(--accent);
}

.eq-thumb img { width: 100%; height: 100%; object-fit: cover; }

.list-year {
  flex: none;
  width: 52px;
  font-size: 15px;
  line-height: 20px;
  font-weight: 700;
  color: var(--accent);
}

.stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
p.small, p.strong { margin: 0; }
.strong { font-size: 15px; line-height: 20px; font-weight: 600; }
.small { font-size: 13px; line-height: 18px; color: var(--muted); }

.cta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px;
  border: 0;
  border-radius: 18px;
  background: var(--accent-bg);
  color: #fff;
  text-align: left;
  text-decoration: none;
}

.cta-row .tile { width: 44px; height: 44px; background: rgba(255, 255, 255, 0.12); color: #fff; }
.cta-row .small { color: #C7D6E0; }

.cta-light { background: var(--card); color: var(--ink); }
.cta-light .tile { background: var(--tint); color: var(--accent); }
.cta-light .small { color: var(--muted); }
.cta-light > svg { color: var(--muted); }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  padding: 28px var(--gutter) 8px;
  font-size: 13px;
  color: var(--muted);
}

.foot a {
  color: var(--muted);
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}

.ios-hint { flex-basis: 100%; text-align: center; }

.section-actions { display: flex; flex-direction: column; gap: 10px; }
.list-gap { display: flex; flex-direction: column; gap: 12px; }
.stack-form { display: flex; flex-direction: column; gap: 16px; }
.sheet-body { display: flex; flex-direction: column; gap: 16px; }

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  text-decoration: none;
}

.btn-primary { background: var(--accent-bg); color: #fff; }
.btn-light { background: var(--card); color: var(--accent); }
.btn-soft { background: var(--fill); color: var(--accent); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.btn-pill {
  flex: none;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 22px;
  background: var(--accent-bg);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

/* Filtros */
.chips {
  display: flex;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 2px var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--chip-line);
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent-bg);
  background: var(--accent-bg);
  color: #fff;
}

/* Personal */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
}

.search:focus-within { box-shadow: 0 0 0 2px var(--accent); }

.search input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 17px;
  color: var(--ink);
  outline: none;
}

.search input::placeholder { color: var(--muted); }

.notice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  border-radius: 16px;
  background: var(--card);
}

.notice-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--ink-2);
}

.notice .tile { width: 36px; height: 36px; border-radius: 10px; }

.btn-tint {
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--tint);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.pcard {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  text-align: left;
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  background: var(--tint);
  color: var(--accent);
}

.pcard-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }

.pcard-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.pcard-role { font-size: 17px; line-height: 22px; font-weight: 600; }
.pcard-code { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); }
.pcard-meta { font-size: 14px; line-height: 19px; color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.badge {
  height: 24px;
  padding: 0 9px;
  border-radius: 12px;
  background: var(--ground);
  color: var(--ink-2);
  font-size: 12px;
  line-height: 24px;
  font-weight: 600;
}

.dashed {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 4px;
  padding: 16px;
  border: 1.5px dashed var(--dashed);
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
}

.dashed .round {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: var(--accent-bg);
  color: #fff;
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 20px;
  border-radius: 20px;
  background: var(--card);
  text-align: center;
}

.empty p { margin: 0; }

/* Equipos */
.steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 14px 10px;
  list-style: none;
  border-radius: 18px;
  background: var(--card);
}

.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
}

.steps .tile { border-radius: 20px; }
.tile.ok { background: var(--green-bg); color: var(--green); }

.ecard {
  border-radius: 20px;
  background: var(--card);
  overflow: hidden;
}

.ecard-media {
  display: flex;
  height: 190px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  background: var(--media);
  scrollbar-width: none;
}

.ecard-media::-webkit-scrollbar { display: none; }

.ecard-media img {
  flex: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  scroll-snap-align: start;
}

.media-btn {
  flex: none;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  scroll-snap-align: start;
  cursor: zoom-in;
}

/* Visor de fotos */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  animation: fade 0.2s ease both;
  outline: none;
}

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + var(--safe-t)) var(--gutter) 10px;
}

.viewer-count { font-size: 15px; font-weight: 600; }

.viewer-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.viewer-track {
  flex: 1;
  display: flex;
  min-height: 0;
  padding-bottom: var(--safe-b);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.viewer-track::-webkit-scrollbar { display: none; }

.viewer-slide {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  margin: 0;
  scroll-snap-align: center;
}

.viewer-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.ecard-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: var(--tint);
  color: var(--accent);
}

.ecard-body { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px 14px; }
.ecard-name { margin: 0; font-size: 17px; line-height: 22px; font-weight: 600; }

.seal {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--green);
}

.seal.own { color: var(--accent); }
.seal img { width: 18px; height: 18px; border-radius: 9px; }

.ecard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.tag {
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: var(--tint);
  color: var(--accent);
  font-size: 13px;
  line-height: 26px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-wrap { position: relative; }

.media-wrap[data-count]::after {
  content: attr(data-count);
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

/* Trayectoria */
.client-pills { display: flex; flex-wrap: wrap; gap: 8px; }

.client-pills span {
  height: 32px;
  padding: 0 12px;
  border-radius: 16px;
  background: var(--card);
  font-size: 13px;
  line-height: 32px;
  font-weight: 600;
}

.timeline {
  margin: 0;
  padding: 20px 16px 4px;
  list-style: none;
  border-radius: 20px;
  background: var(--card);
}

.timeline li {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
}

.timeline-year {
  font-size: 14px;
  line-height: 20px;
  font-weight: 700;
  color: var(--accent);
}

.timeline-body {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 22px 20px;
  border-left: 2px solid var(--fill);
}

.timeline-dot {
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 6px;
  background: var(--accent-bg);
  box-shadow: 0 0 0 3px var(--card);
}

.timeline-dot.now { background: var(--red); }

.now-tag {
  align-self: flex-start;
  height: 22px;
  padding: 0 8px;
  border-radius: 11px;
  background: var(--red-bg);
  color: var(--red-ink);
  font-size: 12px;
  line-height: 22px;
  font-weight: 600;
}

.note {
  display: flex;
  gap: 8px;
  margin: 0 4px;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

/* Formularios */
.group {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--card);
  overflow: hidden;
}

.group legend {
  float: left;
  width: 100%;
  padding: 14px 16px 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.field {
  clear: both;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.field:last-child { border-bottom: 0; }
.field:focus-within { background: var(--field-focus); }

.field > label,
.field > .label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 32px;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 17px;
  color: var(--ink);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.field textarea { min-height: 72px; resize: vertical; }
.field input::placeholder,
.field textarea::placeholder { color: var(--muted); }

.field select {
  padding-right: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236B6B70' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

.field.invalid > label,
.field.invalid > .label { color: var(--red-ink); }

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
}

.field-row:last-child { border-bottom: 0; }

.switch {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: var(--switch-off);
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch:checked { background: var(--accent-bg); }
.switch:checked::after { transform: translateX(20px); }

.seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
  padding: 3px;
  border-radius: 14px;
  background: var(--fill);
}

.seg label { position: relative; display: block; }

.seg input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
}

.seg span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
}

.seg input:checked + span {
  background: var(--seg-on);
  color: var(--seg-on-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--card);
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
}

.check input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--accent-bg);
}

.check.invalid { box-shadow: inset 0 0 0 2px var(--red); }

.photos {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.photo-add {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 104px;
  border: 1.5px dashed #8E8E93;
  border-radius: 16px;
  background: var(--card);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.photo-add input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
}

.photo-add:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.photo {
  position: relative;
  height: 104px;
  border-radius: 16px;
  overflow: hidden;
  background: var(--fill);
}

.photo img { width: 100%; height: 100%; object-fit: cover; }

.photo button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
}

.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.status {
  margin: 0;
  min-height: 20px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}

.status.error { color: var(--red-ink); }

.done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 24px;
  border-radius: 24px;
  background: var(--card);
  text-align: center;
}

.done-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 32px;
  background: var(--green-bg);
  color: var(--green);
}

.done h2 { margin: 6px 0 0; font-size: 24px; line-height: 30px; }
.done p { margin: 0; font-size: 15px; line-height: 21px; color: var(--muted); }
.done .btn { width: 100%; }

/* Hoja inferior */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  padding: 0;
  border: 0;
  background: var(--backdrop);
  animation: fade 0.25s ease both;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 560px;
  max-height: 92vh;
  margin: 0 auto;
  padding: 10px var(--gutter) calc(24px + var(--safe-b));
  overflow-y: auto;
  border-radius: 26px 26px 0 0;
  background: var(--sheet);
  animation: sheet-up 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  overscroll-behavior: contain;
}

.grabber {
  align-self: center;
  flex: none;
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: var(--grabber);
}

.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 4px 0 0; font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -0.3px; }

.sheet-tools {
  display: flex;
  flex: none;
  gap: 8px;
  margin: -4px -8px 0 0;
}

.sheet-tools .close { margin: 0; }

.ecard-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.icon-round {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--ground);
  color: var(--accent);
}

.flash { animation: flash 1.4s ease 2; }

@keyframes flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 42, 58, 0); }
  35% { box-shadow: 0 0 0 4px var(--flash); }
}

.close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  margin: -4px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--ground);
  color: var(--ink-2);
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.facts div { padding: 12px; border-radius: 14px; background: var(--ground); }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 17px; font-weight: 600; }

.locked {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--locked);
  border-radius: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 18px;
}

.locked span { color: var(--ink-2); }

.sheet .group { background: var(--sheet-group); }
.sheet .field { border-bottom-color: var(--sheet-line); }
.sheet .field:focus-within { background: var(--sheet-focus); }

.legal { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); text-align: center; }

/* Barra de pestañas */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
  margin: 0 auto;
  padding: 6px 8px calc(8px + var(--safe-b));
  border-top: 1px solid var(--bar-line);
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
}

.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Avisos y estados de carga */
.toast {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(100px + var(--safe-b));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 528px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--toast);
  margin-block: 0;
  color: #fff;
  font-size: 15px;
  line-height: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  animation: pop 0.28s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.skel {
  height: 96px;
  border-radius: 18px;
  background: linear-gradient(90deg, var(--skel-a) 25%, var(--skel-b) 50%, var(--skel-a) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skel.tall { height: 290px; }

.rise { animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.d1 { animation-delay: 0.06s; }
.d2 { animation-delay: 0.14s; }
.d3 { animation-delay: 0.22s; }
.d4 { animation-delay: 0.3s; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Aviso de conexión */
.net {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: 50%;
  z-index: 70;
  max-width: calc(100% - 2 * var(--gutter));
  margin: 0;
  padding: 9px 16px;
  border-radius: 18px;
  background: var(--toast);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  transform: translateX(-50%);
  animation: fade 0.25s ease both;
}

/* Transición entre pantallas: la barra de pestañas queda fija y el contenido aparece suave. */
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root) { animation: screen-out 0.16s ease both; }
::view-transition-new(root) { animation: screen-in 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes screen-out { to { opacity: 0; } }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (min-width: 400px) {
  :root { --gutter: 24px; }
}

/* Modo oscuro: sigue el ajuste del teléfono. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #F5F5F7;
    --ink-2: #D1D1D6;
    --muted: #98989F;
    --ground: #000;
    --card: #1C1C1E;
    --line: #2C2C2E;
    --fill: #2C2C2E;
    --tint: #1C2A33;
    --green: #7BD197;
    --green-bg: #15301F;
    --red: #FF6961;
    --red-ink: #FF8A80;
    --red-bg: #3B1E1C;
    --accent: #8CBEDD;
    --accent-bg: #2B5F7E;
    --seg-on: #636366;
    --seg-on-ink: #fff;
    --field-focus: #232326;
    --chip-line: #3A3A3C;
    --dashed: #545458;
    --media: #2C2C2E;
    --backdrop: rgba(0, 0, 0, 0.6);
    --sheet: #1C1C1E;
    --sheet-group: #2C2C2E;
    --sheet-line: #38383A;
    --sheet-focus: #3A3A3C;
    --grabber: #48484A;
    --locked: #48484A;
    --bar: rgba(22, 22, 24, 0.94);
    --bar-line: #2C2C2E;
    --toast: #2C2C2E;
    --skel-a: #1C1C1E;
    --skel-b: #2C2C2E;
    --switch-off: #39393D;
    --flash: rgba(140, 190, 221, 0.5);
  }

  .badge, .facts div, .icon-round, .close { background: #2C2C2E; }

  :is(.tile, .avatar)[data-area="topografia"] { background: #1A2B40; color: #93BBEB; }
  :is(.tile, .avatar)[data-area="deteccion"] { background: #29213A; color: #C4ABF2; }
  :is(.tile, .avatar)[data-area="seguridad"] { background: #3A2914; color: #F2B46E; }
  :is(.tile, .avatar)[data-area="civil"] { background: #15301F; color: #7BD197; }
  :is(.tile, .avatar)[data-area="mecanica"] { background: #30271F; color: #D7B88F; }
  :is(.tile, .avatar)[data-area="electricidad"] { background: #332E10; color: #EACB5C; }
  :is(.tile, .avatar)[data-area="gestion"] { background: #222B32; color: #AFC2D1; }
}
