/* Vecinos App 3.3 - estilos (modo claro y oscuro automático) */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --grid: #e3e6eb;
  --text: #16181d;
  --text-2: #4d535e;
  --muted: #6b7280;
  --accent: #1f5fae;
  --accent-ink: #ffffff;
  --accent-soft: #e6effa;
  --focus: #1f5fae;
  --ok-bg: #e3f4e6; --ok-ink: #1b6b2c;
  --warn-bg: #fff1d1; --warn-ink: #7a5200;
  --bad-bg: #fde6e5; --bad-ink: #a42421;
  --pend: #d97a00;
  --neg: #b42318;
  --s1: #2a78d6;   /* serie 1: entradas */
  --s2: #eb6834;   /* serie 2: salidas */
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111214;
    --surface: #1b1c1f;
    --surface-2: #24262a;
    --border: #34373d;
    --grid: #2d3035;
    --text: #eceef1;
    --text-2: #c2c6cd;
    --muted: #9aa0a9;
    --accent: #4d8fe0;
    --accent-ink: #0b1220;
    --accent-soft: #1d2a3b;
    --focus: #6aa5ee;
    --ok-bg: #173522; --ok-ink: #8fdca0;
    --warn-bg: #3b2e10; --warn-ink: #f4cd75;
    --bad-bg: #3e1a19; --bad-ink: #f5a09c;
    --pend: #f0a33a;
    --neg: #f28b82;
    --s1: #3987e5;
    --s2: #d95926;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .6em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
.card h3:first-child, .card h4:first-child { margin-top: 0; }
a { color: var(--accent); }
small, .small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.pre { white-space: pre-wrap; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .95em; }
kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: .85em; background: var(--surface); }
.neg { color: var(--neg); }
.pos { color: var(--ok-ink); }
.strong { font-weight: 600; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* --- Botones y campos --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad-ink) 40%, var(--border)); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: .88rem; }
.btn.big { min-height: 48px; font-size: 1.05rem; width: 100%; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1rem; padding: 6px; border-radius: 6px; color: var(--text-2); }
.icon-btn:hover { background: var(--surface-2); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--text-2); font-weight: 500; margin-bottom: 12px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%;
}
label.inline input, label.inline select { width: auto; min-height: 34px; padding: 5px 8px; }
input[type=checkbox] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); }
input.big, select.big { font-size: 1.1rem; min-height: 48px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.buscar { max-width: 320px; margin: 0 0 10px; }
.buscar.big { max-width: none; min-height: 46px; font-size: 1.05rem; }
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }

/* --- Estructura --- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { border-radius: 8px; flex: none; }
.brand div { display: flex; flex-direction: column; min-width: 0; }
.brand .frac { font-size: .82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user { display: flex; gap: 4px; align-items: center; flex: none; }
.layout { display: flex; min-height: calc(100vh - 57px); }
.nav {
  flex: none; width: 230px; padding: 12px 10px; border-right: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text-2);
  text-decoration: none; font-weight: 500; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .ni { width: 22px; text-align: center; }
.badge-count { margin-left: auto; background: var(--pend); color: #fff; border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 700; }
main { flex: 1; min-width: 0; padding: 20px 24px 60px; outline: none; }
#view { max-width: 1400px; }

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .nav {
    width: 100%; height: auto; position: sticky; top: 53px; z-index: 15; display: flex; gap: 4px;
    overflow-x: auto; padding: 6px 10px; border-right: 0; border-bottom: 1px solid var(--border);
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: none; margin: 0; padding: 7px 12px; white-space: nowrap; font-size: .92rem; }
  main { padding: 14px 16px 60px; }
  .hide-sm { display: none; }
  .topbar { padding-left: 12px; padding-right: 8px; }
}

/* --- Tarjetas, mosaicos, rejillas --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.error-card { border-color: var(--bad-ink); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.grid2.wide-first { grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); }
@media (max-width: 900px) { .grid2.wide-first { grid-template-columns: 1fr; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.tile span { color: var(--text-2); font-size: .88rem; }
.tile strong { font-size: 1.55rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.tile small { color: var(--muted); }
.tile.link:hover { border-color: var(--accent); }
.big-input { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 44px; padding: 4px 8px; }
.meter { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 4px; }
.meter span { display: block; height: 100%; background: var(--s1); border-radius: 3px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head h2 { margin: 0; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 10px 0 12px; }
.toolbar .buscar { margin: 0; }
.year-nav { display: inline-flex; align-items: center; gap: 8px; }
.year-nav strong { font-size: 1.15rem; min-width: 3.2em; text-align: center; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .88rem; color: var(--text-2); text-decoration: none; }
.chip strong { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.hint { color: var(--text-2); font-size: .9rem; background: var(--surface-2); border-radius: 8px; padding: 8px 12px; margin: 8px 0 12px; }
.info { margin-top: 12px; background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: .9rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); margin: 8px 0 16px; }
.banner { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-weight: 500; }
.banner.error { background: var(--bad-bg); color: var(--bad-ink); }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner.ok { background: var(--ok-bg); color: var(--ok-ink); }
.banner.offline { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; margin: 0; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.form-grid .span { grid-column: 1 / -1; }
dl.datos { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.datos dt { color: var(--muted); }
dl.datos dd { margin: 0; overflow-wrap: anywhere; }
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.lista li:last-child { border-bottom: 0; }
.lista li > div:last-child { display: flex; gap: 6px; align-items: center; }

/* --- Etiquetas de estado (siempre con texto/icono, no solo color) --- */
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.aprobado { background: var(--ok-bg); color: var(--ok-ink); }
.badge.pendiente { background: var(--warn-bg); color: var(--warn-ink); }
.badge.rechazado { background: var(--bad-bg); color: var(--bad-ink); }

/* --- Tablas simples --- */
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: 0; }
.card .tbl th, .card .tbl td { padding: 7px 6px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.acciones { white-space: nowrap; }
td.acciones .btn { margin: 2px; }

/* --- HOJAS TIPO EXCEL --- */
.sheet-wrap {
  overflow: auto; max-height: calc(100vh - 150px); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.sheet { border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; min-width: 100%; font-size: .92rem; }
.sheet th, .sheet td { border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid); padding: 0; background: var(--surface); }
.sheet thead th {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2); padding: 8px 8px; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .03em; color: var(--text-2); white-space: nowrap; text-align: left;
}
.sheet thead th.mes-actual { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.sheet .stick { position: sticky; left: 0; z-index: 2; }
.sheet thead .stick { z-index: 4; }
.sheet th.casa { padding: 6px 10px; text-align: left; min-width: 150px; max-width: 200px; font-weight: 400; }
.sheet th.casa strong { display: block; }
.sheet th.casa small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet td.num, .sheet th.num { padding: 6px 10px; }
.sheet tbody th.stick, .sheet tfoot th.stick { padding: 6px 10px; text-align: left; box-shadow: 1px 0 0 var(--grid); }
.sheet input, .sheet select {
  border: 0; border-radius: 0; background: transparent; min-height: 36px; padding: 6px 8px; width: 100%; min-width: 90px;
}
.sheet input.num { text-align: right; }
.sheet input[type=date] { min-width: 140px; }
.sheet input[type=checkbox] { width: 20px; min-width: 0; margin: 8px auto; display: block; }
.sheet input:focus, .sheet select:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--accent-soft); }
.sheet input[readonly] { cursor: pointer; }
.sheet tfoot td, .sheet tfoot th { position: sticky; bottom: 0; z-index: 2; background: var(--surface-2); font-weight: 600; }
.sheet tfoot tr.sub td, .sheet tfoot tr.sub th { position: static; font-weight: 400; color: var(--text-2); }
.sheet tr.tot td, .sheet tr.tot th { font-weight: 700; }
.sheet tr.sub td, .sheet tr.sub th { color: var(--text-2); background: var(--surface-2); }
.sheet tr.inactiva th, .sheet tr.inactiva td { opacity: .55; }
.sheet tr.saved td, .sheet td.saved { animation: guardado .9s ease; }
.sheet tr.nueva td, .sheet tr.nueva-casa td { background: var(--accent-soft); }
.sheet tr.nueva td:last-child, .sheet tr.nueva-casa td:last-child { padding: 3px 8px; }
.sheet-ro td.num { padding: 8px 12px; }
@keyframes guardado { from { box-shadow: inset 0 0 0 2px var(--ok-ink); } to { box-shadow: inset 0 0 0 2px transparent; } }

/* celdas de cobranza */
.sheet-cob input { text-align: right; min-width: 88px; }
.sheet-cob td.cell { position: relative; }
.sheet-cob td.cuota { color: var(--text-2); }
.sheet-cob td.st-ok { background: var(--ok-bg); }
.sheet-cob td.st-ok input { color: var(--ok-ink); font-weight: 600; }
.sheet-cob td.st-parcial { background: var(--warn-bg); }
.sheet-cob td.st-parcial input { color: var(--warn-ink); font-weight: 600; }
.sheet-cob td.st-debe { background: var(--bad-bg); }
.sheet-cob td.has-pend::before {
  content: ""; position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--pend); pointer-events: none;
}
.sheet-cob td.multi input { text-decoration: underline dotted; }
.sheet-cob td.saving { opacity: .6; }
.sheet-cob .mas {
  display: none; position: absolute; right: 1px; top: 50%; transform: translateY(-50%); border: 0; border-radius: 5px;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; line-height: 1; padding: 4px 5px; cursor: pointer; z-index: 1;
}
.sheet-cob td.cell:focus-within .mas, .sheet-cob td.cell:hover .mas { display: block; }
.sheet-cob td.cell:focus-within input { padding-right: 26px; }
.sheet-cob sup { color: var(--muted); }
.legend-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; font-size: .85rem; }
.lg { border-radius: 6px; padding: 3px 10px; }
.lg.st-ok { background: var(--ok-bg); color: var(--ok-ink); }
.lg.st-parcial { background: var(--warn-bg); color: var(--warn-ink); }
.lg.st-debe { background: var(--bad-bg); color: var(--bad-ink); }
.lg.has-pend-l { background: var(--surface); border: 1px solid var(--border); }
.lg.has-pend-l::first-letter { color: var(--pend); }

/* --- Gráfica --- */
.chart { margin: 0 0 8px; }
.chart figcaption { display: flex; gap: 16px; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; flex-wrap: wrap; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart path.s1 { fill: var(--s1); }
.chart path.s2 { fill: var(--s2); }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: color-mix(in srgb, var(--text) 5%, transparent); }
.legend { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw.s1 { background: var(--s1); }
.sw.s2 { background: var(--s2); }
#tip {
  position: fixed; z-index: 80; pointer-events: none; display: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.15);
  font-variant-numeric: tabular-nums; max-width: 260px;
}

/* --- Vecino --- */
.meses-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin: 0 0 16px; }
.mes-chip { border-radius: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.mes-chip .mc-icon { font-weight: 700; }
.mes-chip small { color: inherit; opacity: .9; }
.mes-chip.est-pagado { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.mes-chip.est-parcial, .mes-chip.est-en_revision { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.mes-chip.est-pendiente { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
.mes-chip.est-futuro { color: var(--muted); }

/* --- Guardia --- */
.msg { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.msg-casa { flex: none; width: 76px; text-align: center; background: var(--accent-soft); border-radius: 10px; padding: 8px 4px; }
.msg-casa span { display: block; font-size: .75rem; color: var(--text-2); text-transform: uppercase; }
.msg-casa strong { font-size: 1.5rem; color: var(--accent); overflow-wrap: anywhere; }
.msg-body { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.msg-nombre { font-size: 1.1rem; }
.msg .nota { background: var(--surface-2); border-radius: 6px; padding: 4px 8px; margin-top: 4px; }
.form-guardia { border-top: 4px solid var(--accent); }
.aviso-h { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 10px; }
details .aviso { box-shadow: none; }

/* --- Entrar --- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.login { width: 100%; max-width: 400px; }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head img { border-radius: 14px; }
.login-head h1 { margin: 8px 0 2px; font-size: 1.6rem; }
.login-head p { margin: 0; }
.login .btn.big { margin: 4px 0 10px; }
.demo { margin-top: 10px; font-size: .9rem; }
.demo summary { cursor: pointer; color: var(--text-2); }
.demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.acceso { background: var(--surface-2); padding: 12px; border-radius: 8px; white-space: pre-wrap; font-size: .9rem; }

/* --- Ventanas y avisos --- */
.modal-bg { position: fixed; inset: 0; z-index: 82; background: rgba(10, 12, 16, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 480px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px; }
.modal-h h3 { margin: 0; }
.modal-b { padding: 6px 16px 16px; }
#toasts { position: fixed; z-index: 90; pointer-events: none; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--text); color: var(--bg); border-radius: 10px; padding: 10px 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .4s, transform .4s; font-weight: 500; }
.toast.error { background: var(--bad-ink); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* --- Impresión: solo el contenido --- */
@media print {
  .topbar, .nav, .toolbar, .head-actions, .hint, .buscar, .legend-row, .mas, #toasts, .banner, tr.nueva, tr.nueva-casa, .btn, .icon-btn { display: none !important; }
  body, .card, .tile, .sheet th, .sheet td { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  main { padding: 0; }
  .sheet-wrap { max-height: none; overflow: visible; border: 0; box-shadow: none; }
  .sheet { font-size: 9pt; }
  .sheet th, .sheet td { position: static !important; border-color: #999 !important; }
  .sheet input, .sheet select { min-width: 0; padding: 2px 4px; min-height: 0; -webkit-appearance: none; appearance: none; }
  .sheet-cob td.st-ok, .sheet-cob td.st-parcial, .sheet-cob td.st-debe { background: #fff !important; }
  @page { size: landscape; margin: 10mm; }
}

/* --- Celular: más compacto para que la tabla aparezca pronto --- */
@media (max-width: 600px) {
  h2 { font-size: 1.2rem; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile strong { font-size: 1.2rem; }
  .chips { gap: 6px; }
  .chip { font-size: .8rem; padding: 3px 10px; }
  .hint { font-size: .82rem; padding: 6px 10px; }
  .legend-row { font-size: .78rem; gap: 6px; }
  .page-head .btn { min-height: 34px; padding: 5px 10px; }
  .toolbar { gap: 8px 10px; }
  .buscar { max-width: none; }
  .sheet th.casa { min-width: 112px; }
  .sheet-cob input { min-width: 76px; }
}
.chart { max-width: 860px; }

/* --- 3.2: sub-pestañas, ficha de casa, reglamento --- */
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 14px; overflow-x: auto; }
.subtab { padding: 9px 14px; text-decoration: none; color: var(--text-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; }
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.subtab:hover { background: var(--surface-2); }
.ficha h4 { margin: 18px 0 8px; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 1rem; }
.ficha h4:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.subhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 4px 0 8px; flex-wrap: wrap; }
.int-row { display: grid; grid-template-columns: 2fr 1.3fr 1.3fr auto; gap: 6px; margin-bottom: 6px; align-items: center; }
@media (max-width: 600px) { .int-row { grid-template-columns: 1fr 1fr auto; } .int-row input[name=int_nombre] { grid-column: 1 / -1; } }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: 10px 0 2px; margin-top: 12px; border-top: 1px solid var(--grid); }
ol.reglas { list-style: none; padding: 0; margin: 0; }
.regla-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.regla-h h3 { margin: 0 0 6px; }
.regla .art { color: var(--accent); }
.regla-acc { display: flex; gap: 4px; align-items: center; }
.regla-acc .icon-btn:disabled { opacity: .3; cursor: default; }
.regla p { margin: 0; }
@media print { .subtabs, .regla-acc, form.card { display: none !important; } }
.card h4 { margin: 14px 0 6px; }
.sheet-mov input[name=categoria], .sheet-mov input[data-k=categoria] { min-width: 200px; }
#tabla-casas td:nth-child(4) { white-space: nowrap; }

/* --- 3.3: pases de visita, pánico, conciliación --- */
.badge.info { background: var(--accent-soft); color: var(--accent); }
.badge.gris { background: var(--surface-2); color: var(--muted); }
.nav-item[data-count]:not([data-count=""]):not([data-count="0"])::after {
  content: attr(data-count); margin-left: auto; background: var(--accent); color: var(--accent-ink);
  border-radius: 999px; font-size: .75rem; padding: 1px 8px; font-weight: 700;
}
.pase { align-items: flex-start; }
.pase.est-dentro { border-left: 5px solid var(--ok-ink); }
.pase.est-pendiente { border-left: 5px solid var(--pend); }
.pase.est-fuera { border-left: 5px solid var(--accent); }
.pase.est-finalizado, .pase.est-cancelado { opacity: .7; }
.pase-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pase-acc { display: flex; flex-direction: column; gap: 6px; align-self: center; }
.btn.big-btn { min-height: 52px; font-size: 1.05rem; padding: 10px 18px; }
.movs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mov { background: var(--surface-2); border-radius: 6px; padding: 2px 8px; font-size: .85rem; font-variant-numeric: tabular-nums; }
details.invitados pre { white-space: pre-wrap; margin: 6px 0 0; font: inherit; background: var(--surface-2); padding: 8px; border-radius: 6px; }
.tipo-rapido { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-radio { flex-direction: row; align-items: center; gap: 6px; margin: 0; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--text); background: var(--surface); }
.chip-radio input { width: auto; min-height: 0; accent-color: var(--accent); }
.chip-radio:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.sos { background: #c62828; border-color: #c62828; color: #fff; font-weight: 700; }
.btn.sos:hover { background: #a31f1f; }
.sos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 12px; }
.sos-op { flex-direction: row; align-items: center; gap: 8px; margin: 0; border: 2px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; color: var(--text); font-size: 1rem; }
.sos-op input { width: auto; min-height: 0; }
.sos-op:has(input:checked) { border-color: #c62828; background: var(--bad-bg); }
.alerta-overlay { position: fixed; inset: 0; z-index: 75; background: rgba(120, 10, 10, .92); color: #fff; padding: 24px 16px; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.alerta-overlay h2 { font-size: 1.8rem; margin: 0 0 8px; }
.alerta-overlay.parpadea h2 { animation: parpadeo 1s steps(2, start) infinite; }
@keyframes parpadeo { to { visibility: hidden; } }
.alerta-card { background: #fff; color: #16181d; border-radius: 14px; padding: 16px; width: min(640px, 100%); display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; align-items: center; }
.alerta-casa { background: #fde6e5; color: #a42421; border-radius: 10px; padding: 10px 14px; text-align: center; font-size: .85rem; }
.alerta-casa strong { display: block; font-size: 2rem; }
.alerta-info a { color: #1f5fae; font-weight: 700; font-size: 1.1rem; }
.alerta-acc { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.alerta-acc .btn { flex: 1; }
.alerta-vecino { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--bad-bg); color: var(--bad-ink); }
.alerta-vecino.est-atendiendo, .alerta-vecino.est-resuelta { background: var(--ok-bg); color: var(--ok-ink); }
.conc-lineas { max-width: 640px; margin-bottom: 12px; }
.conc-linea { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.conc-linea label.check { margin: 0; font-weight: 400; }
.conc-linea.total { font-size: 1.1rem; border-top: 2px solid var(--text); }
.big-num { font-size: 1.4rem; }
@media print { .alerta-overlay, #alertas-box, .btn.sos { display: none !important; } }

/* --- 3.3.2: alerta minimizable (el guardia sigue trabajando) --- */
.alerta-top { width: min(640px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.alerta-top h2 { margin: 0; }
.btn.alerta-min { background: #fff; color: #7a1010; border-color: #fff; font-weight: 700; min-height: 48px; }
.btn.alerta-min:hover { background: #fde6e5; }
.alerta-barra { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; background: #c62828; color: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.alerta-barra.parpadea { animation: latido 1.2s ease-in-out infinite; }
@keyframes latido { 50% { background: #8e1616; } }
.alerta-chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.16); border-radius: 999px; padding: 3px 4px 3px 12px; font-size: .9rem; }
.alerta-barra .btn.small { background: #fff; color: #7a1010; border-color: #fff; }
.alertas-lista { display: grid; gap: 12px; margin-bottom: 16px; }
.alerta-card.claro { width: 100%; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.alerta-card.claro.est-activa { border-left: 6px solid #c62828; }
.alerta-card.claro.est-atendiendo { border-left: 6px solid var(--pend); }
.badge.atiende { font-size: .95rem; padding: 8px 12px; display: inline-flex; align-items: center; }
@media print { .alerta-barra { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .alerta-barra.parpadea { animation: none; } }
.nav-item[data-v=alertas][data-count]:not([data-count=""]):not([data-count="0"])::after { background: #c62828; color: #fff; }

/* --- 3.4: Finanzas para vecinos --- */
.aviso-info { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; }
.fin-tabla tr.futuro th, .fin-tabla tr.futuro td { color: var(--muted); }
.rubros { display: grid; gap: 14px; }
.rubro-h { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; font-variant-numeric: tabular-nums; }
.rubro-h.total { border-top: 2px solid var(--text); padding-top: 10px; font-size: 1.05rem; }
.rubro-barra { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.rubro-barra span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.rubro-cats { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid var(--grid); }
.rubro-cats li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; font-size: .92rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.fin-gastos tr.grupo th { background: var(--surface-2); text-align: left; padding-top: 10px; }
.fin-gastos tr.grupo th.num { text-align: right; }
.fin-gastos td:nth-child(3) { min-width: 220px; }
.nowrap { white-space: nowrap; }
@media print { .fin-gastos tr[hidden] { display: table-row !important; } details.card { display: block; } }
.solo-cel { display: none; }
@media (max-width: 600px) {
  .solo-cel { display: inline; }
  .solo-pc { display: none; }
  .fin-tabla th:nth-child(2), .fin-tabla td:nth-child(2), .fin-tabla th:nth-child(3), .fin-tabla td:nth-child(3),
  .fin-tabla th:nth-child(6), .fin-tabla td:nth-child(6), .fin-tabla th:nth-child(8), .fin-tabla td:nth-child(8) { display: none; }
  .sheet.fin-tabla { font-size: .82rem; }
  .sheet-ro.fin-tabla th, .sheet-ro.fin-tabla td, .sheet-ro.fin-tabla td.num, .sheet.fin-tabla thead th { padding: 8px 5px; }
  .fin-gastos thead { display: none; }
  .fin-gastos, .fin-gastos tbody, .fin-gastos tfoot { display: block; }
  .fin-gastos tr[data-buscar] { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; padding: 10px 12px; border-bottom: 1px solid var(--grid); }
  .fin-gastos tr[data-buscar][hidden] { display: none; }
  .fin-gastos tr[data-buscar] td { border: 0; padding: 0; min-width: 0 !important; }
  .fin-gastos tr[data-buscar] td:nth-child(2) { color: var(--text-2); font-size: .88rem; }
  .fin-gastos tr[data-buscar] td:nth-child(3) { grid-column: 1 / -1; order: 4; }
  .fin-gastos tr[data-buscar] td:nth-child(4) { font-weight: 700; }
  .fin-gastos tr.grupo, .fin-gastos tfoot tr { display: flex; justify-content: space-between; padding: 8px 12px; }
  .fin-gastos tr.grupo th, .fin-gastos tfoot td { border: 0; padding: 0; background: none; }
  .fin-gastos tr.grupo { background: var(--surface-2); }
}

/* --- 3.5: permisos y recuperar contraseña --- */
.permisos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 12px; }
.card.permisos h3 { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.switch-row { display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; margin: 0; padding: 10px 0; border-top: 1px solid var(--grid); color: var(--text); font-weight: 400; cursor: pointer; }
.switch-row.fijo { color: var(--muted); cursor: default; }
input.switch { appearance: none; -webkit-appearance: none; width: 46px; min-width: 46px; height: 26px; min-height: 26px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; padding: 0; border: 0; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s; }
input.switch:checked { background: var(--ok-ink); }
input.switch:checked::after { left: 23px; }
input.switch:disabled { opacity: .6; cursor: default; }
input.switch:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.card.solicitudes { border-left: 5px solid var(--pend); }
.sol-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--grid); }
.sol-acc { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-vacio { padding: 8px 12px; }
.code-input { font-size: 1.6rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.login .btn.big { white-space: normal; height: auto; min-height: 48px; line-height: 1.3; padding-top: 10px; padding-bottom: 10px; }

/* --- 3.6: encuestas y votaciones --- */
.card.encuesta { border-left: 5px solid var(--ok-ink); }
.card.encuesta.cerrada { border-left-color: var(--muted); }
.enc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.enc-head h3 { margin: 0; }
.opciones-voto { display: grid; gap: 8px; margin: 12px 0 6px; }
.btn.opcion { justify-content: flex-start; text-align: left; white-space: normal; height: auto; }
.btn.opcion.elegida { border-color: var(--ok-ink); background: var(--ok-bg); color: var(--ok-ink); font-weight: 700; }
.btn.opcion:disabled { opacity: .75; }
.votos { display: grid; gap: 10px; margin: 12px 0; }
.voto-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-variant-numeric: tabular-nums; }
.voto-linea.gana .voto-top strong { color: var(--ok-ink); }
.voto-barra { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 4px; }
.voto-barra span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.voto-barra span.s1 { background: var(--s1); } .voto-barra span.s2 { background: var(--s2); }
.voto-barra span.s3 { background: #7a5cd0; } .voto-barra span.s4 { background: #2a9d8f; }
.voto-barra span.s5 { background: #d97a00; } .voto-barra span.s6 { background: #a4508b; }
.enc-acc { gap: 8px; flex-wrap: wrap; margin-top: 12px; align-items: center; }
.ok-text { color: var(--ok-ink); }
details.mini summary { cursor: pointer; color: var(--accent); font-size: .92rem; margin-top: 8px; }
.nav-item[data-v=encuestas][data-count]:not([data-count=""]):not([data-count="0"])::after { background: var(--pend); color: #fff; }

/* ---- 3.7 REGISTRO de entradas y salidas ---- */
.placa { display: inline-block; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 700; letter-spacing: .08em;
  background: #fff; color: #16181d; border: 1.5px solid #3b4250; border-radius: 5px; padding: 0 6px; font-size: .86rem; line-height: 1.5; }
.prov-rapidos { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.prov-btn { font: inherit; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 10px;
  padding: 10px 14px; min-height: 46px; cursor: pointer; font-weight: 600; }
.prov-btn:hover { border-color: var(--accent); }
.prov-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.reg-destino { border: 0; padding: 0; margin: 0 0 8px; }
.reg-destino legend { font-weight: 600; margin-bottom: 6px; }
.placas-in { text-transform: uppercase; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .06em; }
.reg-tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); margin: 4px 0 6px; }
.seg-btn { font: inherit; border: 0; background: transparent; color: var(--text-2); padding: 9px 18px; min-height: 42px; cursor: pointer; font-weight: 600; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.on { background: var(--accent); color: var(--accent-ink); }
.reg-dia { margin: 18px 0 6px; font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.reg-tl { list-style: none; margin: 0 0 8px; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.reg-item { display: grid; grid-template-columns: 74px 34px 1fr; gap: 10px; align-items: start; padding: 12px 14px; }
.reg-item + .reg-item { border-top: 1px solid var(--grid); }
.reg-item.general { background: var(--surface-2); }
.reg-hora { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.reg-hora strong { font-size: 1.25rem; letter-spacing: -.01em; }
.reg-sal { font-size: .8rem; color: var(--muted); }
.reg-ico { font-size: 1.35rem; line-height: 1.4; text-align: center; }
.reg-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.reg-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
@media (max-width: 600px) { .reg-item { grid-template-columns: 62px 26px 1fr; gap: 8px; padding: 10px; } .reg-hora strong { font-size: 1.1rem; } }
@media print { .filtros-reg, .no-print { display: none !important; } }

/* ---- 3.8 Fraccionamiento grande ---- */
.lote-in { width: 110px; min-height: 34px; padding: 4px 8px; }
.fila-privada td { background: var(--surface-2); }

/* ---- 3.11 Privacidad y verificación en dos pasos ---- */
.legal-card { max-width: 720px; }
.legal-texto { max-height: 34vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px;
  background: var(--surface-2); font-size: .92rem; line-height: 1.5; margin-bottom: 10px; }
.legal-texto p { margin: 0 0 8px; }
.codigo-2fa { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .3em; text-align: center; font-size: 1.3rem; }
.clave-2fa code { font-size: 1.05rem; letter-spacing: .08em; word-break: break-all; }
.codigos-rec { font-size: 1.1rem; letter-spacing: .1em; line-height: 1.7; }
ol.pasos { padding-left: 1.2em; }

/* ---- 3.12 Medidor ---- */
.veredicto { border-left: 6px solid var(--border); }
.veredicto.v-verde { border-left-color: #2e8b57; }
.veredicto.v-amarillo { border-left-color: #d4a017; }
.veredicto.v-rojo { border-left-color: #c0392b; }
.grafica-medidor { width: 100%; height: auto; max-height: 230px; display: block; }
.g-linea { stroke: var(--grid); stroke-width: 1; }
.g-txt { fill: var(--muted); font-size: 11px; }
.g-barra { fill: var(--accent); opacity: .35; }
.g-barra-esc { fill: var(--accent); }
.leyenda { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: -1px; }
.leyenda.g-barra { background: var(--accent); opacity: .35; }
.leyenda.g-barra-esc { background: var(--accent); }
