:root {
  --bg: #f6f5fa;
  --surface: #ffffff;
  --surface-2: #eeecf5;
  --text: #17142a;
  --text-2: #4a4660;
  --muted: #6c6882;
  --line: #e0dde9;
  --accent: #5b3fd0;
  --accent-ink: #ffffff;
  --accent-soft: #ebe6fc;
  --ok: #0f7a45;
  --ok-soft: #e0f3e8;
  --warn: #9a5800;
  --warn-soft: #fff0d8;
  --bad: #b3261e;
  --bad-soft: #fce3e1;
  --shadow: 0 1px 2px rgb(20 16 40 / .05), 0 6px 18px rgb(20 16 40 / .06);
  --radius: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121019;
    --surface: #1c1a26;
    --surface-2: #262333;
    --text: #efedf7;
    --text-2: #c9c5da;
    --muted: #9b97ae;
    --line: #322e42;
    --accent: #9d86ff;
    --accent-ink: #160f33;
    --accent-soft: #2a2347;
    --ok: #5fd39a;
    --ok-soft: #173326;
    --warn: #ffbe5c;
    --warn-soft: #382a14;
    --bad: #ff8b80;
    --bad-soft: #3c1d1b;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(100px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
h2, h3 { letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }

/* ---------- Cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand img { border-radius: 9px; }
.brand div { min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wrap { max-width: 760px; margin: 0 auto; padding: 4px 16px 0; }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; text-align: center;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.danger-solid { background: var(--bad); color: #fff; border-color: transparent; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.grow { flex: 1; }
.btn.wide { width: 100%; margin-bottom: 14px; }
.icon-btn { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; color: var(--text); flex: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.tiny { width: 30px; height: 30px; font-size: 13px; color: var(--muted); }
.link { border: 0; background: none; padding: 4px 0; color: var(--accent); font-weight: 600; font-size: 14px; }
.link.danger { color: var(--bad); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.row-btns.center { justify-content: center; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > span { font-size: 13.5px; font-weight: 700; color: var(--text-2); }
.field input, .field select, .field textarea, .suffix {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); outline: none;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input:disabled, .field textarea:disabled { opacity: .75; }
.suffix { display: flex; align-items: center; gap: 6px; padding: 0 12px; }
.field .suffix input { width: auto; flex: 1; min-width: 0; border: 0; padding: 0; min-height: 44px; background: transparent; box-shadow: none; }
.suffix span { color: var(--muted); font-size: 14px; white-space: nowrap; }
.error { color: var(--bad); font-size: 13px; }
.error:empty { display: none; }
.help { font-size: 12.5px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.form fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px 6px; margin: 4px 0 16px; }
.form legend { font-weight: 700; padding: 0 6px; }

.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.none { background: var(--surface-2); color: var(--muted); }

.info-box { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); margin-bottom: 14px; font-size: 14.5px; }
.info-box.ok { background: var(--ok-soft); }
.hint { font-size: 13.5px; color: var(--muted); text-align: center; margin: 18px 0; }

/* ---------- Inicio ---------- */
.empty { text-align: center; padding: 30px 6px 10px; }
.empty .big { font-size: 52px; }
.empty h2 { font-size: 26px; margin: 8px 0; }
.empty p { color: var(--text-2); max-width: 460px; margin: 0 auto 20px; }
.steps { list-style: none; counter-reset: s; padding: 0; margin: 26px 0 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 36px 1fr; gap: 2px 12px; padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.steps li::before { content: counter(s); grid-row: span 2; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.steps span { color: var(--muted); font-size: 14.5px; }

.props { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 10px; }
.prop-card { width: 100%; display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.prop-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); font-size: 24px; flex: none; }
.prop-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prop-info b { font-size: 16.5px; }
.prop-info > span:not(.chips) { color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.fab {
  position: fixed; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 22px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; white-space: nowrap;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- Piso ---------- */
.prop-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.prop-head dl { margin: 0; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.prop-head dt { font-size: 12.5px; color: var(--muted); }
.prop-head dd { margin: 0; font-weight: 600; }
.acta-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; margin-bottom: 12px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.acta-info { flex: 1 1 260px; min-width: 0; }
.acta-info h3 { margin: 0 0 4px; font-size: 17px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.acta-info p { margin: 0; color: var(--muted); font-size: 14px; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.cmp-link { width: 100%; display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 16px; margin-bottom: 12px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.cmp-link small { display: block; color: var(--accent); font-weight: 600; }
.cmp-link svg { margin-left: auto; color: var(--muted); }
.cmp-num { display: grid; place-items: center; min-width: 46px; height: 46px; padding: 0 8px; border-radius: 14px; font-size: 22px; font-weight: 800; flex: none; }
.cmp-num.ok { background: var(--ok-soft); color: var(--ok); }
.cmp-num.bad { background: var(--bad-soft); color: var(--bad); }
.deposit p { margin: 0 0 6px; }
.deposit .btn { margin-top: 6px; }
.danger-zone { text-align: center; margin: 20px 0; }

/* ---------- Acta ---------- */
.acta-top { display: grid; grid-template-columns: 180px 1fr; gap: 16px; align-items: center; }
.acta-top .field { margin: 0; }
.acta-progress span { font-size: 14.5px; }
.legend-mini { display: block; font-size: 12.5px !important; color: var(--muted); margin-top: 6px; }
@media (max-width: 520px) { .acta-top { grid-template-columns: 1fr; } }

.rooms { display: grid; gap: 10px; margin-bottom: 14px; }
.room { border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.room-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 15px 16px; border: 0; background: transparent; text-align: left; }
.room-name { font-weight: 700; font-size: 16.5px; flex: 1; min-width: 0; }
.room-meta { display: flex; align-items: center; gap: 8px; }
.count { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.count.full { color: var(--ok); }
.chev { color: var(--muted); transition: transform .15s; }
.room.open .chev { transform: rotate(180deg); }
.room.open .room-head { border-bottom: 1px solid var(--line); }
.room-body { padding: 12px 16px 16px; }
.room-photos { margin-bottom: 8px; }
.label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.room-tools { display: flex; justify-content: space-between; gap: 10px; margin-top: 10px; }

.item { padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-of-type { border-top: 0; }
.item-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item-name { font-weight: 600; flex: 1; min-width: 0; }
.was { font-size: 12.5px; color: var(--muted); }
.states { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.st { min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 600; font-size: 14px; padding: 0 4px; }
.st.on.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.st.on.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.st.on.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
@media (prefers-color-scheme: dark) { .st.on.ok, .st.on.warn, .st.on.bad { color: #111; } }
.item-extra { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.thumb { width: 54px; height: 54px; padding: 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.add-photo { width: 54px; height: 54px; border-radius: 10px; border: 1.5px dashed color-mix(in srgb, var(--accent) 50%, var(--line)); background: var(--accent-soft); font-size: 20px; }
.note-input { width: 100%; margin-top: 8px; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; font-size: 14.5px; }
.note-input:focus { border-color: var(--accent); }
.note { margin: 8px 0 0; font-size: 14px; color: var(--text-2); }
.add-item { display: flex; gap: 8px; margin-top: 12px; }
.add-item input { flex: 1; min-width: 0; min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); outline: none; }

.meter { display: flex; align-items: flex-end; gap: 12px; }
.meter .field { flex: 1; }
.meter .thumbs { margin-bottom: 14px; }
.acta-actions { position: sticky; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 10px; border-radius: 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------- Comparación ---------- */
.cmp-summary { display: flex; align-items: center; gap: 14px; }
.cmp-summary p { margin: 2px 0 0; }
.switch { margin: 0 0 10px; }
.cmp-room h3 { margin-bottom: 4px; }
.cmp-item { padding: 10px 0; border-top: 1px solid var(--line); }
.cmp-item.worse { background: linear-gradient(90deg, var(--bad-soft), transparent 70%); margin: 0 -16px; padding: 10px 16px; }
.cmp-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cmp-states { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.cmp-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }

/* ---------- Hojas ---------- */
dialog.sheet { width: 100%; max-width: 580px; max-height: 94dvh; margin: auto auto 0; padding: 0; border: 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--text); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: up .22s ease-out; }
dialog::backdrop { background: rgb(10 8 20 / .55); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 22px; max-height: 88dvh; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 8px 20px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { padding: 16px 20px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sig-block { margin-bottom: 12px; }
.sig-block .field { margin-bottom: 8px; }
.pad-wrap { position: relative; }
.pad { display: block; width: 100%; height: 150px; border-radius: 12px; border: 1.5px dashed var(--line); background: #fff; touch-action: none; cursor: crosshair; }
.pad-wrap .link { position: absolute; top: 6px; right: 10px; color: #5b3fd0; }
.set { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.set:last-child { border: 0; }
.set h3 { margin: 0 0 4px; font-size: 16px; }

dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: #000; }
dialog.viewer[open] { display: flex; flex-direction: column; }
dialog.viewer::backdrop { background: #000; }
#photoImg { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.viewer-bar { display: flex; justify-content: center; gap: 10px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); }

.toast {
  position: fixed; inset: auto auto calc(90px + env(safe-area-inset-bottom)) 50%; margin: 0; border: 0;
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 14.5px; transition: opacity .25s, transform .25s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Documento para imprimir / PDF ---------- */
#print { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  #app, .toast, dialog { display: none !important; }
  body { background: #fff; color: #111; padding: 0; font-size: 11pt; }
  #print { display: block; }
}
.p-doc { color: #111; font: 10.5pt/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; position: relative; }
.p-draft { position: fixed; top: 40%; left: 0; right: 0; text-align: center; font-size: 46pt; font-weight: 800; color: rgba(180, 0, 0, .12); transform: rotate(-24deg); pointer-events: none; }
.p-head { border-bottom: 3px solid #5b3fd0; margin-bottom: 10px; padding-bottom: 6px; }
.p-head h1 { margin: 0; font-size: 20pt; }
.p-head p { margin: 0; color: #555; }
.p-doc table { width: 100%; border-collapse: collapse; margin: 4px 0 8px; }
.p-doc th, .p-doc td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
.p-doc thead th { background: #f1effa; font-size: 9pt; }
.p-meta th { width: 34%; color: #555; font-weight: 600; }
.p-room table { table-layout: fixed; }
.p-room thead th:first-child { width: 34%; }
.p-room thead th:not(:first-child):not(:last-child) { width: 14%; }
.p-summary { background: #f6f5fb; padding: 6px 10px; border-radius: 6px; }
.p-room { break-inside: auto; margin-top: 12px; }
.p-room h3 { font-size: 13pt; margin: 0 0 4px; break-after: avoid; }
.p-state { font-weight: 700; }
.p-state.ok { color: #0f7a45; }
.p-state.warn { color: #9a5800; }
.p-state.bad { color: #b3261e; }
.p-state.none { color: #888; }
.p-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.p-photos figure { margin: 0; break-inside: avoid; }
.p-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; display: block; }
.p-photos figcaption { font-size: 7.5pt; color: #555; margin-top: 2px; }
.p-notes { white-space: pre-wrap; }
.p-signs { margin-top: 18px; break-inside: avoid; }
.p-sig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 10px; }
.p-sig img { height: 70px; max-width: 100%; object-fit: contain; display: block; }
.p-sig-empty { height: 70px; display: grid; place-items: center; color: #999; border: 1px dashed #ccc; }
.p-sig-line { border-top: 1px solid #333; padding-top: 4px; font-size: 9.5pt; }
.p-code { font-size: 9pt; color: #444; margin-top: 10px; }
.p-foot { margin-top: 14px; font-size: 8pt; color: #888; text-align: center; }

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