:root {
  --bg-page: #f5f0e8;
  --bg-card: #ffffff;
  --bg-soft: #f0ede5;
  --bg-softer: #faf8f3;

  --text-primary: #1a1a18;
  --text-secondary: #6b6b66;
  --text-tertiary: #9a9a93;

  --accent-violet: #4a3a5e;
  --accent-violet-deep: #2a2438;
  --accent-gold: #9a7a52;

  --text-danger: #a32d2d;
  --bg-danger: #fcebeb;
  --text-warning: #854f0b;
  --bg-warning: #faeeda;
  --text-success: #0f6e56;
  --bg-success: #e1f5ee;
  --text-info: #185fa5;
  --bg-info: #e6f1fb;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.06);

  --nav-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---- Transiciones (sutiles, respetando prefers-reduced-motion) ---- */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes screen-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes backdrop-in {
  from { background: rgba(26,26,24,0); }
  to { background: rgba(26,26,24,0.45); }
}
@keyframes list-stagger {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Animaciones a las superficies principales */
.screen, .fullbleed {
  animation: screen-in 260ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.screen.leaving, .fullbleed.leaving {
  animation: screen-out 180ms ease both;
}

/* Hover/press feedback unificado, sin sombras agresivas */
.list-item, .card, .toggle-pill, .pay-item, .tenant-card, .kv, .chip-file {
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.list-item:active, .card:active, .toggle-pill:active, .pay-item:active {
  transform: scale(0.985);
}

/* Botones y tabs / segmented */
.btn, .segmented button, .tabs button, .nav-bottom button, .icon-btn {
  transition: background-color 160ms ease, color 160ms ease, opacity 160ms ease, transform 120ms ease;
}
.btn:active { transform: translateY(0.5px); }
.nav-bottom .fab-circle { transition: transform 160ms ease, box-shadow 200ms ease; }
.nav-bottom .fab:active .fab-circle { transform: scale(0.94); }

/* Inputs */
.field input, .field select, .field textarea {
  transition: border-color 160ms ease, background-color 160ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--text-info);
}

/* prefers-reduced-motion: anulamos animaciones */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; }
a { color: inherit; text-decoration: none; }

.serif { font-family: var(--font-serif); font-weight: 500; letter-spacing: 0.005em; }
.italic { font-style: italic; }
.mono-num { font-variant-numeric: tabular-nums; }

/* ---- Layout shell ---- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}
.app.no-nav { padding-bottom: env(safe-area-inset-bottom); }

.screen {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 18px 32px;
}

/* ---- Bottom nav ---- */
.nav-bottom {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  z-index: 50;
}
.nav-bottom button {
  background: transparent;
  border: 0;
  padding: 6px 0 4px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.nav-bottom button i { font-size: 20px; }
.nav-bottom button.active { color: var(--text-primary); }
.nav-bottom button.fab {
  position: relative;
}
.nav-bottom .fab-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-violet-deep);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -22px;
  box-shadow: 0 4px 12px rgba(42, 36, 56, 0.28);
}
.nav-bottom .fab-circle i { font-size: 24px; }

/* ---- Header ---- */
.app-header {
  padding: 18px 18px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 560px;
  margin: 0 auto;
}
.app-header .eyebrow {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.app-header .title { font-family: var(--font-serif); font-size: 22px; line-height: 1.1; font-weight: 500; }
.app-header .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-info); color: var(--text-info);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.app-header .back {
  background: transparent; border: 0; color: var(--text-secondary);
  padding: 6px 6px 6px 0; margin-left: -6px;
  display: flex; align-items: center; gap: 4px; font-size: 13px;
}
.app-header .icon-btn {
  background: transparent; border: 0; color: var(--text-secondary);
  padding: 6px; font-size: 18px; cursor: pointer;
}

/* ---- Cards & lists ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-card);
}
.card + .card { margin-top: 10px; }

.section-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 22px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title.danger { color: var(--text-danger); }
.section-title.warning { color: var(--text-warning); }
.section-title.success { color: var(--text-success); }
.section-title.muted { color: var(--text-tertiary); }
.section-title .count {
  background: var(--bg-soft);
  color: var(--text-secondary);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
}
.list-item + .list-item { margin-top: 8px; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; }
.list-item .sub { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }
.list-item .right { text-align: right; }
.list-item .amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.list-item.danger { border-left: 3px solid var(--text-danger); }
.list-item.warning { border-left: 3px solid var(--text-warning); }
.list-item.neutral {}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}
.badge.danger { background: var(--bg-danger); color: var(--text-danger); }
.badge.warning { background: var(--bg-warning); color: var(--text-warning); }
.badge.success { background: var(--bg-success); color: var(--text-success); }
.badge.info { background: var(--bg-info); color: var(--text-info); }
.badge.neutral { background: var(--bg-soft); color: var(--text-secondary); }

/* ---- Dots ---- */
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0;
  background: transparent;
  border: 1.5px solid var(--text-tertiary);
}
.dot.danger { background: var(--text-danger); border-color: var(--text-danger); }
.dot.warning { background: var(--text-warning); border-color: var(--text-warning); }
.dot.success { background: var(--text-success); border-color: var(--text-success); }
.dot.info { background: var(--text-info); border-color: var(--text-info); }

/* ---- Metric tiles ---- */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0 6px;
}
.metric {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}
.metric.danger { background: var(--bg-danger); border-color: transparent; color: var(--text-danger); }
.metric.warning { background: var(--bg-warning); border-color: transparent; color: var(--text-warning); }
.metric .label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; }
.metric .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .hint { font-size: 11px; opacity: 0.7; margin-top: 2px; }

/* ---- Buttons ---- */
.btn {
  border: 0;
  background: var(--bg-soft);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent-violet-deep); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border-strong); }
.btn.block { width: 100%; }
.btn.sm { padding: 8px 12px; font-size: 13px; }

/* ---- Forms ---- */
.field { margin-top: 14px; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 72px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--text-tertiary); margin-top: 4px; }
.field .row { display: flex; gap: 8px; }
.field .row > * { flex: 1; }
.field .prefix-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding-left: 12px;
}
.field .prefix-wrap span { color: var(--text-secondary); padding-right: 6px; }
.field .prefix-wrap input { border: 0; padding-left: 0; }

.toggle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.toggle-pill {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
}
.toggle-pill.on { background: var(--bg-info); border-color: transparent; color: var(--text-info); }
.toggle-pill .check { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--text-tertiary); display: inline-flex; align-items: center; justify-content: center; }
.toggle-pill.on .check { border-color: var(--text-info); background: var(--text-info); color: #fff; }
.toggle-pill .check i { font-size: 11px; }
.toggle-pill.on .check i { color: #fff; }
.toggle-pill:not(.on) .check i { display: none; }

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
}
.segmented button {
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 9px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.segmented button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-card); }

/* ---- Status bar de pills (cartera por inmueble) ---- */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.status-pill {
  font-size: 10.5px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}
.status-pill.danger { background: var(--bg-danger); color: var(--text-danger); }
.status-pill.warning { background: var(--bg-warning); color: var(--text-warning); }
.status-pill.success { background: var(--bg-success); color: var(--text-success); }
.status-pill.muted { background: transparent; color: var(--text-tertiary); border: 1px dashed var(--border-strong); }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 24, 0.45);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: backdrop-in 220ms ease both;
}
.modal-backdrop.closing { animation: backdrop-in 180ms ease reverse both; }
.modal {
  background: var(--bg-page);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: modal-in 280ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.modal-backdrop.closing .modal { animation: modal-in 200ms ease-in reverse both; }
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.modal-header .close { background: transparent; border: 0; padding: 6px; font-size: 18px; color: var(--text-secondary); cursor: pointer; }
.modal-header .title-block { flex: 1; }
.modal-header .title { font-family: var(--font-serif); font-size: 20px; font-weight: 500; }
.modal-header .sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.modal-body { flex: 1; overflow-y: auto; padding: 12px 16px 16px; }
.modal-footer {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  display: flex;
  gap: 10px;
}
.modal-footer .btn { flex: 1; }

/* ---- Toast ---- */
.toast-root {
  position: fixed;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 200;
}
.toast {
  background: var(--accent-violet-deep);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 6px 20px rgba(42,36,56,0.25);
  max-width: 90%;
  animation: toast-in 220ms ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Splash / fullscreen pages ---- */
.fullbleed {
  min-height: 100vh; min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: linear-gradient(180deg, var(--bg-page) 0%, #e8dec9 100%);
  text-align: center;
}
.fullbleed .brand { font-family: var(--font-serif); font-size: 90pt; line-height: 1; }
.fullbleed .tag { font-family: var(--font-serif); font-style: italic; font-size: 18pt; color: var(--text-secondary); margin-top: 14px; }
.fullbleed .actions { margin-top: 48px; width: 100%; max-width: 320px; }

/* ---- File chips ---- */
.chips-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.chip-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  font-size: 12px;
}
.chip-file .meta { flex: 1; min-width: 0; }
.chip-file .meta .n { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-file .meta .s { color: var(--text-tertiary); font-size: 10.5px; }
.chip-file button { background: transparent; border: 0; color: var(--text-tertiary); padding: 2px 4px; cursor: pointer; }

/* ---- Item rows (modal pago) ---- */
.pay-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
}
.pay-item + .pay-item { margin-top: 6px; }
.pay-item.selected { background: var(--bg-info); border-color: transparent; }
.pay-item .check {
  width: 20px; height: 20px; border-radius: 6px;
  border: 1.5px solid var(--text-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-card);
}
.pay-item.selected .check { background: var(--text-info); border-color: var(--text-info); color: #fff; }
.pay-item .check i { font-size: 13px; display: none; }
.pay-item.selected .check i { display: inline; }
.pay-item .body { flex: 1; min-width: 0; }
.pay-item .body .t { font-size: 14px; font-weight: 500; }
.pay-item .body .s { font-size: 12px; color: var(--text-secondary); }
.pay-item.selected .body .s { color: rgba(0,0,0,0.55); }
.pay-item .amt { font-weight: 600; font-variant-numeric: tabular-nums; }

.total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  margin-top: 12px;
  font-size: 13px;
}
.total-bar .sum { font-weight: 600; font-variant-numeric: tabular-nums; }
.total-bar.match { background: var(--bg-success); color: var(--text-success); }
.total-bar.diff { background: var(--bg-warning); color: var(--text-warning); }

/* ---- Empty states ---- */
.empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--text-secondary);
}
.empty i { font-size: 28px; color: var(--text-tertiary); }
.empty .t { font-family: var(--font-serif); font-size: 18px; margin-top: 8px; }
.empty .s { font-size: 13px; margin-top: 4px; color: var(--text-tertiary); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  margin: 12px 0 14px;
}
.tabs button {
  flex: 1;
  background: transparent;
  border: 0;
  padding: 9px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}
.tabs button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-card); }

/* ---- Tenant card / detail ---- */
.tenant-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.avatar-initials {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 15px;
}
.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.kv {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--bg-softer);
}
.kv .l { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-tertiary); }
.kv .v { font-size: 15px; font-weight: 500; margin-top: 2px; font-variant-numeric: tabular-nums; }

.service-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1px dashed var(--border);
}
.service-row:last-child { border-bottom: 0; }
.service-row .name { flex: 1; }
.service-row .name .n { font-weight: 500; }
.service-row .name .st { font-size: 12px; color: var(--text-secondary); }
.service-row .amt { font-weight: 600; font-variant-numeric: tabular-nums; }

.subsection {
  margin-top: 22px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.subsection.soft { background: var(--bg-softer); }
.subsection-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.subsection-head .name { flex: 1; }
.subsection-head .btn { padding: 6px 10px; font-size: 11.5px; }

/* ---- Install hint ---- */
.install-card { background: var(--bg-card); border: 1px solid var(--border); padding: 18px; border-radius: var(--radius-lg); }
.install-card h2 { font-family: var(--font-serif); font-weight: 500; margin: 0 0 8px; font-size: 22px; }
.install-card ol { padding-left: 20px; margin: 8px 0; color: var(--text-secondary); }
.install-card ol li { margin-bottom: 6px; }

/* ---- Utility ---- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-center { display: flex; align-items: center; gap: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-danger { color: var(--text-danger); }
.text-warning { color: var(--text-warning); }
.text-success { color: var(--text-success); }
.muted { color: var(--text-tertiary); }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.center { text-align: center; }
.hidden { display: none !important; }

/* Inputs sin spinners en number */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
