:root {
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0071e3;
  --blue-soft: #eaf3fe;
  --paper: #f5f5f7;
  --line: rgba(0, 0, 0, .08);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .03);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .06), 0 2px 6px rgba(0, 0, 0, .04);
  --radius: 18px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(1200px 600px at 15% -10%, rgba(0,113,227,.06), transparent 60%),
                     radial-gradient(900px 500px at 100% 0%, rgba(123,63,228,.05), transparent 55%);
  background-attachment: fixed;
  line-height: 1.5;
}
.wrap { width: min(1080px, 92%); margin: 0 auto; padding: 0 0 56px; }

/* --- Barra superior, en todas las páginas --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(245, 245, 247, .82);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  width: min(1080px, 92%); margin: 0 auto;
  padding: 18px 16px;
  min-height: 24px; display: flex; align-items: center; justify-content: space-between;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 16px; font-weight: 650; letter-spacing: -.01em;
  color: var(--ink); text-decoration: none;
}
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); }

.hero { padding: 40px 0 28px; }
h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -.025em;
  line-height: 1.08;
  margin: 0;
}
.lead { color: var(--muted); font-size: 16px; margin: 8px 0 0; }

a.volver {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 550;
  display: inline-flex; align-items: center; gap: 4px;
}
a.volver:hover { color: var(--ink); }

/* --- Tarjetas --- */
.card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .06);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 2px 8px rgba(0,0,0,.03), 0 12px 32px rgba(0,0,0,.035);
  padding: 28px;
  transition: box-shadow .2s ease;
  /* Una tabla con texto largo (descripciones de incidencias, orden del
     día...) no se encoge por debajo de su contenido — sin esto se lleva
     la tarjeta entera (y la página) de ancho en móvil. El scroll queda
     contenido aquí dentro, nunca en toda la página. */
  overflow-x: auto;
}
.card h2 {
  font-size: 19px; font-weight: 650; letter-spacing: -.015em;
  margin: 0 0 4px;
}
.subtitulo { color: var(--muted); font-size: 14px; margin: 0 0 18px; line-height: 1.45; }

.grid-secciones { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); margin-top: 28px; }

/* --- Formularios --- */
label {
  display: block; font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 18px 0 6px;
}
label:first-of-type { margin-top: 18px; }
input, textarea, select {
  display: block; width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
input::placeholder, textarea::placeholder { color: #a8a8ad; }

/* --- Botones --- */
button {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: -.01em;
  cursor: pointer;
  margin-top: 18px;
  transition: opacity 120ms ease, transform 100ms ease;
}
button:hover { opacity: .88; }
button:active { transform: scale(.97); }
.btn-secundario { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn-pequeno { padding: 7px 14px; font-size: 13px; margin-top: 0; }
button:disabled { opacity: .5; cursor: default; }
.pre-line { white-space: pre-line; }
.fila-detalle td { background: var(--paper); padding-top: 16px; padding-bottom: 16px; }
.fila-detalle label:first-of-type { margin-top: 0; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.texto-mudo { color: var(--muted); font-size: 13px; margin-top: 4px; }
.aviso-mantenimiento { font-size: 12.5px; margin-top: 6px; padding: 6px 10px; background: var(--blue-soft); border-radius: 8px; color: #0058b0; }
.aviso-mantenimiento a { color: inherit; font-weight: 600; }

.error { color: #c0392b; font-size: 14px; margin-top: 10px; font-weight: 550; }

/* --- Tablas: listas limpias, no cuadrícula densa --- */
table { width: 100%; border-collapse: collapse; margin-top: 22px; }
th, td { text-align: left; padding: 13px 10px; }
th {
  color: var(--muted); font-weight: 600; font-size: 12px;
  letter-spacing: .02em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
td { border-bottom: 1px solid var(--line); font-size: 14.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(0, 0, 0, .012); }

/* --- Estados: pastel, nunca gritando --- */
.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
  background: #f0f0f2; color: var(--muted);
}
.badge.urgente, .badge.fallida { background: #fdecea; color: #b3261e; }
.badge.alta { background: #fff4e0; color: #9a5b00; }
.badge.pagada, .badge.publicada, .badge.resuelta, .badge.triada { background: #e6f6ec; color: #1c7a40; }
.badge.media, .badge.celebrada { background: var(--blue-soft); color: #0058b0; }
.badge.ingreso { background: #e6f6ec; color: #1c7a40; }
.badge.gasto { background: #fdecea; color: #b3261e; }

@media (max-width: 640px) {
  .grid-secciones { grid-template-columns: 1fr; }
  .card { padding: 20px; }
}

/* ======================================================================
   Panel con barra lateral (dashboard) — prefijo dash- para no chocar con
   las páginas de una sola columna (portal, login) que usan .topbar/.wrap.
   ====================================================================== */
:root {
  --dash-sidebar-w: 248px;
  --green: #1c7a40;
  --orange: #9a5b00;
  --red: #b3261e;
  --purple: #7b3fe4;
}

.dash-shell { display: flex; min-height: 100vh; }

.dash-sidebar {
  width: var(--dash-sidebar-w); flex-shrink: 0;
  background: rgba(255, 255, 255, .6);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-right: 1px solid rgba(255, 255, 255, .4);
  box-shadow: 1px 0 0 rgba(0, 0, 0, .04), 4px 0 24px rgba(0, 0, 0, .04);
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.dash-sidebar-header { padding: 22px 20px 16px; border-bottom: 1px solid rgba(0, 0, 0, .06); }
.dash-sidebar-nav { flex: 1; padding: 10px; overflow-y: auto; }
.dash-nav-title {
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 14px 10px 6px;
}
.dash-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink); font-size: 14px; font-weight: 550;
  text-decoration: none; cursor: pointer; transition: background .15s ease, transform .1s ease;
}
.dash-nav-item:hover { background: rgba(0, 0, 0, .045); }
.dash-nav-item:active { transform: scale(.98); }
.dash-nav-item.active {
  background: linear-gradient(180deg, rgba(0,113,227,.14), rgba(0,113,227,.09));
  color: #0058b0; font-weight: 650;
  box-shadow: inset 0 0 0 1px rgba(0,113,227,.12);
}
.dash-nav-item svg { width: 18px; height: 18px; opacity: .75; flex-shrink: 0; }
.dash-nav-item.active svg { opacity: 1; }
.dash-nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 650; padding: 1px 7px; border-radius: 10px;
}
.dash-sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(0, 0, 0, .06); font-size: 12px; color: var(--muted); }

.dash-main { flex: 1; margin-left: var(--dash-sidebar-w); min-width: 0; }
.dash-topbar {
  height: 60px; background: rgba(245, 245, 247, .72); backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, .5);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .05), 0 8px 24px rgba(0, 0, 0, .03);
  display: flex; align-items: center;
  padding: 0 28px; gap: 16px; position: sticky; top: 0; z-index: 50;
}
.dash-topbar-title { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.dash-content { padding: 32px; max-width: 1180px; }

.dash-view { display: none; }
.dash-view.active { display: block; }

/* Tarjetas de estadística */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 26px; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; color: #fff; }
.stat-icon.blue { background: var(--blue); }
.stat-icon.green { background: var(--green); }
.stat-icon.orange { background: var(--orange); }
.stat-icon.purple { background: var(--purple); }
.stat-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 26px; }

/* Dona de incidencias por estado */
.donut-wrap { display: flex; align-items: center; gap: 28px; justify-content: center; padding: 10px 0; }
.donut { width: 128px; height: 128px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.donut-center { width: 76px; height: 76px; background: #fff; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center-val { font-size: 1.2rem; font-weight: 700; }
.donut-center-label { font-size: 10.5px; color: var(--muted); }
.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Actividad reciente */
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-icon svg { width: 16px; height: 16px; color: #fff; }
.activity-icon.blue { background: var(--blue); }
.activity-icon.green { background: var(--green); }
.activity-icon.orange { background: var(--orange); }
.activity-icon.purple { background: var(--purple); }
.activity-text { font-size: 13.5px; line-height: 1.4; }
.activity-time { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Rejilla de comunidades */
.community-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.community-card { cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.community-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.community-name { font-size: 16px; font-weight: 650; margin-bottom: 10px; }
.community-stats { display: flex; gap: 20px; }
.community-stat { text-align: center; }
.community-stat-val { font-size: 1.1rem; font-weight: 700; color: var(--blue); }
.community-stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }

/* Filtros */
/* Accesos rápidos de comunidad.html — para que no haga falta bajar a
   ciegas buscando documentos/juntas/espacios, que quedan varias
   pantallas más abajo (hallazgo real: un administrador que entra y mira
   solo la primera pantalla cree que esas secciones no existen). */
.accesos-rapidos {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0;
}
.accesos-rapidos a {
  background: rgba(255,255,255,.7); backdrop-filter: blur(12px);
  border: 1px solid rgba(0,0,0,.07); border-radius: 999px;
  padding: 7px 15px; font-size: 13px; font-weight: 600;
  color: var(--ink); text-decoration: none; transition: background .12s ease, transform .1s ease;
}
.accesos-rapidos a:hover { background: var(--blue-soft); color: #0058b0; }
.accesos-rapidos a:active { transform: scale(.96); }

.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-bar select { width: auto; padding: 8px 12px; font-size: 13.5px; }
.filter-count { font-size: 13px; color: var(--muted); margin-left: auto; }

/* Fila de propietario con avatar */
.owner-row { display: flex; align-items: center; gap: 10px; }
.owner-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 650; font-size: 12px; color: #fff; flex-shrink: 0;
}

.hamburger {
  display: none; width: 36px; height: 36px; align-items: center; justify-content: center;
  background: transparent; color: var(--ink); border: none;
  border-radius: var(--radius-sm); padding: 0; margin: 0; cursor: pointer;
}
.hamburger:hover { background: rgba(0, 0, 0, .05); opacity: 1; }
.hamburger:active { transform: scale(.94); }
.hamburger svg { width: 22px; height: 22px; }
.dash-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .3); z-index: 99; }
.dash-sidebar-overlay.show { display: block; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2col { grid-template-columns: 1fr; }
  .dash-sidebar { transform: translateX(-100%); }
  .dash-sidebar.open { transform: translateX(0); }
  .dash-main { margin-left: 0; }
  .hamburger { display: flex; }
  .dash-content { padding: 18px; }
  .dash-topbar { padding: 0 16px; }
}

.amount { font-weight: 650; font-variant-numeric: tabular-nums; }
.amount.positive { color: var(--green); }
.amount.negative { color: var(--red); }

/* --- Importar vecinos --- */
.importar-form { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 760px) { .importar-form { grid-template-columns: 1.4fr 1fr auto; align-items: end; } }
.importar-form .importar-zona {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  margin: 0; padding: 22px 16px; border: 1.5px dashed rgba(0, 113, 227, .35); border-radius: var(--radius-sm);
  background: var(--blue-soft); color: var(--blue); cursor: pointer; text-align: center;
  transition: background .15s ease, border-color .15s ease;
}
.importar-zona:hover, .importar-zona:focus-within, .importar-zona.arrastrando { border-color: var(--blue); background: #e2eefd; }
.importar-zona svg { width: 26px; height: 26px; }
.importar-zona span { font-size: 14px; font-weight: 600; color: var(--ink); word-break: break-all; }
.importar-zona small { font-size: 12px; font-weight: 500; color: var(--muted); }
.importar-zona input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.importar-resumen { margin: 18px 0 10px; font-size: 14px; color: var(--ink); }
.tabla-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabla-importar td { vertical-align: middle; white-space: nowrap; }
.tabla-importar td:first-child, .tabla-importar td:nth-child(2) { width: 1%; }
.tabla-importar .celda-input { margin: 0; padding: 6px 8px; font-size: 13px; width: 100%; }
.tabla-importar .celda-avisos { font-size: 12px; color: #9a6700; min-width: 180px; max-width: 260px; white-space: normal; }
.tabla-importar .fila-error td { background: #fff5f5; }
.tabla-importar .fila-error .celda-avisos { color: #c4314b; }
.importar-acciones { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.importar-acciones button { margin-top: 0; }
.importar-hecho { margin-top: 16px; padding: 10px 14px; border-radius: var(--radius-sm); background: #e9f8ee; color: #1a7f37; font-size: 14px; font-weight: 600; }
