:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-soft: #eff4ff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
.hidden { display: none !important; }

/* ---------------- Login ---------------- */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 15% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #e0e7ff 0%, transparent 55%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card .logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  color: #fff; font-size: 22px;
  margin-bottom: 18px;
}

.login-card h1 { font-size: 21px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 6px 0 24px; }

.demo-box {
  margin-top: 22px;
  padding: 13px 15px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.demo-box b { color: var(--text); }
.demo-box code {
  background: #fff; border: 1px solid var(--border);
  padding: 1px 5px; border-radius: 5px; font-size: 12px;
}

/* ---------------- Layout ---------------- */

.app { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 20px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: linear-gradient(145deg, #3b82f6, #1e3a8a);
  display: grid; place-items: center; color: #fff; font-size: 17px;
}
.brand .name { font-size: 13.5px; font-weight: 650; color: #fff; line-height: 1.25; }
.brand .role { font-size: 11.5px; color: #64748b; }

.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em;
  color: #475569; padding: 16px 10px 6px; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  background: none; border: 0; width: 100%; text-align: left;
  color: #cbd5e1; cursor: pointer; font-size: 14px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 550; }
.nav-item .ico { width: 17px; text-align: center; font-size: 14px; }
.nav-item .pill {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
}
.nav-item.active .pill { background: rgba(255,255,255,.25); }

.sidebar-foot { margin-top: auto; padding-top: 18px; border-top: 1px solid #1e293b; }
.sidebar-foot .who { padding: 0 10px 10px; font-size: 12.5px; color: #94a3b8; }
.sidebar-foot .who b { display: block; color: #e2e8f0; font-size: 13px; }

.main { padding: 26px 30px 60px; max-width: 1240px; width: 100%; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h2 { font-size: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------- Componentes ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card h3 { font-size: 15.5px; margin-bottom: 3px; }
.card .card-sub { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); align-items: start; }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .value { font-size: 25px; font-weight: 680; letter-spacing: -.02em; margin-top: 4px; }
.stat .foot { font-size: 12.5px; color: var(--faint); margin-top: 2px; }
.stat.accent { background: linear-gradient(145deg, var(--brand), var(--brand-dark)); border-color: transparent; color: #fff; }
.stat.accent .label, .stat.accent .foot { color: rgba(255,255,255,.75); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-size: 13.5px; font-weight: 550;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: #fff; border-color: #fca5a5; color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border-strong); border-radius: 9px;
  background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 78px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

.file-drop {
  border: 1.5px dashed var(--border-strong); border-radius: 10px;
  padding: 16px; text-align: center; cursor: pointer;
  background: var(--surface-2); color: var(--muted); font-size: 13px;
  transition: border-color .12s, background .12s;
}
.file-drop:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.file-drop.filled { border-style: solid; border-color: var(--ok); background: var(--ok-soft); color: var(--ok); font-weight: 550; }
.file-drop input { display: none; }
.thumb { margin-top: 10px; max-height: 190px; border-radius: 9px; border: 1px solid var(--border); display: block; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; padding: 9px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.tag.info { background: var(--info-soft); color: var(--info); border-color: #bae6fd; }
.tag.mute { background: var(--surface-2); color: var(--muted); border-color: var(--border); }

/* Tabla de casillas de notificación en la ficha de unidad */
.tabla-notif th { font-size: 10.5px; text-align: center; padding: 6px 4px; }
.tabla-notif th:first-child { text-align: left; }
.tabla-notif td { padding: 8px 4px; }
.tabla-notif td.center { text-align: center; }
.tabla-notif input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

.empty { text-align: center; padding: 40px 20px; color: var(--faint); }
.empty .big { font-size: 30px; margin-bottom: 8px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sep { height: 1px; background: var(--border); margin: 16px 0; }

/* filtros */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input { width: auto; min-width: 130px; }
.chip-group { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 10px; border: 1px solid var(--border); }
.chip { border: 0; background: none; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.active { background: #fff; color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.08); }

/* ---------------- Bloque de acción de pago ---------------- */

.cta {
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  border-radius: 16px; padding: 22px 26px; margin-bottom: 16px;
  border: 1.5px solid transparent;
}
.cta-texto { flex: 1; min-width: 200px; }
.cta-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; opacity: .85;
}
.cta-monto {
  font-size: 40px; font-weight: 720; letter-spacing: -.025em;
  line-height: 1.1; margin: 4px 0 3px; font-variant-numeric: tabular-nums;
}
.cta-sub { font-size: 13.5px; opacity: .8; }

.cta-pendiente {
  background: linear-gradient(135deg, #eff4ff, #dbeafe);
  border-color: #bfdbfe; color: var(--brand-dark);
}
.cta-vencida {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  border-color: #fca5a5; color: #7f1d1d;
}
.cta-ok {
  background: var(--ok-soft); border-color: #a7f3d0; color: #065f46;
  padding: 16px 22px;
}
.cta-ok .cta-titulo { font-size: 16px; font-weight: 680; }
.cta-ok .cta-sub { font-size: 13px; margin-top: 2px; }
.cta-icono {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 20px;
  background: #fff; border: 1.5px solid #a7f3d0;
}

/* El botón grande: el elemento más pesado de la pantalla, a propósito */
.btn-cta {
  display: inline-flex; align-items: center; gap: 13px;
  padding: 15px 26px; border-radius: 13px; border: 0;
  background: var(--brand); color: #fff; cursor: pointer;
  text-align: left; box-shadow: 0 6px 20px -6px rgba(29, 78, 216, .65);
  transition: transform .1s, box-shadow .15s, background .15s;
  animation: latido 2.4s ease-out 3;
}
.btn-cta:hover { background: var(--brand-dark); box-shadow: 0 10px 26px -6px rgba(29, 78, 216, .75); }
.btn-cta:active { transform: translateY(1px); }
.btn-cta:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
.cta-vencida .btn-cta {
  background: #b91c1c; box-shadow: 0 6px 20px -6px rgba(185, 28, 28, .65);
}
.cta-vencida .btn-cta:hover { background: #991b1b; }
.btn-cta-ico { font-size: 24px; line-height: 1; }
.btn-cta-titulo { display: block; font-size: 16px; font-weight: 680; letter-spacing: -.01em; }
.btn-cta-sub { display: block; font-size: 12px; opacity: .85; margin-top: 1px; }

@keyframes latido {
  0%, 100% { box-shadow: 0 6px 20px -6px rgba(29, 78, 216, .65); }
  50% { box-shadow: 0 6px 20px -6px rgba(29, 78, 216, .65), 0 0 0 9px rgba(37, 99, 235, .13); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-cta { animation: none; }
}

/* ---------------- Modal ---------------- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: grid; place-items: center; padding: 20px; z-index: 60;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%;
  max-width: 560px; max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
}
.modal.wide { max-width: 900px; }
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.modal-head h3 { font-size: 17px; }
.modal-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.modal-body { padding: 18px 22px; }
.modal-foot { padding: 14px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 20px; color: var(--faint); cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.x:hover { background: var(--surface-2); color: var(--text); }

/* ---------------- Gráfico de torta ---------------- */

.chart-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 30px; align-items: center; }
.pie { display: block; width: 100%; max-width: 300px; margin: 0 auto; }

/* Separación fina entre porciones: con el anillo delgado se leen mejor */
.pie .slices path {
  cursor: pointer;
  stroke: var(--surface);
  stroke-width: .7;
  transition: opacity .14s;
}
.pie .slices:hover path { opacity: .35; }
.pie .slices path:hover { opacity: 1; }

.pie .center-val { font-size: 8.5px; font-weight: 700; fill: var(--text); }
.pie .center-lbl {
  font-size: 4px; fill: var(--faint); text-transform: uppercase;
  letter-spacing: .12em; font-weight: 600;
}
.pie-total {
  text-align: center; margin-top: 10px;
  font-size: 13px; font-weight: 650; color: var(--text);
  font-variant-numeric: tabular-nums;
}

.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-row {
  display: grid; grid-template-columns: 12px minmax(0,1fr) auto auto;
  gap: 11px; align-items: center; padding: 8px 9px; border-radius: 8px;
  cursor: default; font-size: 13.5px;
}
.legend-row:hover { background: var(--surface-2); }
.legend-row .dot { width: 11px; height: 11px; border-radius: 3px; }
.legend-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .pc { color: var(--muted); font-size: 12.5px; width: 52px; text-align: right; font-variant-numeric: tabular-nums; }
.legend-row .mt { font-weight: 600; font-variant-numeric: tabular-nums; width: 110px; text-align: right; }

.bar-track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }

.spark { display: flex; align-items: flex-end; gap: 4px; height: 92px; }
.spark .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 5px; min-width: 0; }
.spark .bar { width: 100%; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 4px 4px 0 0; min-height: 3px; }
.spark .lb { font-size: 10px; color: var(--faint); }

/* ---------------- Avisos / reclamos ---------------- */

/* Barra de filtros de reclamos */
.filtros-reclamos {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 16px; margin-bottom: 16px;
}
.filtros-reclamos .filtro { display: flex; flex-direction: column; gap: 4px; }
.filtros-reclamos .filtro > span {
  font-size: 11px; font-weight: 650; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.filtros-reclamos select { width: auto; min-width: 140px; padding: 7px 10px; font-size: 13.5px; }
.filtros-reclamos .filtro-cuenta {
  margin-left: auto; font-size: 12.5px; color: var(--faint);
  font-variant-numeric: tabular-nums; padding-bottom: 8px;
}

.aviso { border: 1px solid var(--border); border-radius: 11px; padding: 15px 17px; background: var(--surface); }
.aviso.importante { border-color: #fdba74; background: #fffbf5; }
.aviso.fijado { box-shadow: inset 3px 0 0 var(--brand); }
.aviso h4 { font-size: 14.5px; }
.aviso .meta { font-size: 12px; color: var(--faint); margin: 3px 0 8px; }
.aviso p { margin: 0; font-size: 13.5px; color: #334155; white-space: pre-wrap; }

.thread { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.msg { padding: 10px 13px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.msg.admin { background: var(--brand-soft); border-color: #c7d7fe; }
.msg .who { font-size: 11.5px; color: var(--muted); font-weight: 650; margin-bottom: 3px; }

/* ---------------- Toast ---------------- */

.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 9px; z-index: 90; }
.toast {
  background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 10px 30px -8px rgba(15,23,42,.5);
  animation: pop .2s ease-out; max-width: 340px;
}
.toast.err { background: #991b1b; }
.toast.ok { background: #065f46; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

/* ---------------- Responsive ---------------- */

@media (max-width: 1080px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.split, .chart-layout { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; padding: 12px; gap: 6px;
  }
  .sidebar .nav-label { display: none; }
  .brand { padding: 0 8px 0 4px; width: 100%; }
  .nav-item { width: auto; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
  .sidebar-foot .who { display: none; }
  .main { padding: 18px 16px 50px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0,1fr); }
  .row { flex-direction: column; }

  /* En el celular el botón de pagar ocupa todo el ancho */
  .cta { padding: 18px 20px; gap: 16px; }
  .cta-monto { font-size: 34px; }
  .btn-cta { width: 100%; justify-content: center; }
  .filtros-reclamos { padding: 12px 14px; gap: 10px; }
  .filtros-reclamos .filtro { flex: 1; min-width: 130px; }
  .filtros-reclamos select { width: 100%; min-width: 0; }
  .filtros-reclamos .filtro-cuenta { margin-left: 0; width: 100%; padding: 0; }
}

@media print {
  .sidebar, .page-actions, .btn { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
