:root {
  --bg: #f4f3f7;
  --panel: #ffffff;
  --panel2: #f6f3fa;
  --line: #e6e3ee;
  --txt: #221d2e;
  --muted: #7c768c;
  --accent: #5e2d8f;       /* morado de marca (logo Ruiz) */
  --accent2: #471f70;      /* morado oscuro hover/active */
  --accent-soft: #efe7f8;  /* morado muy suave para fondos */
  --green: #1a9c4e;
  --red: #d92d20;
  --amber: #c77700;
  --shadow: 0 4px 18px rgba(40,20,60,.10);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; background: #fff; border: 1px solid var(--line);
  color: var(--txt); border-radius: 6px; padding: 7px 9px; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---- Login ---- */
#login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #efe7f8 0%, #f4f3f7 60%);
}
.login-box {
  background: var(--panel); padding: 36px; border-radius: 14px; width: 350px;
  box-shadow: var(--shadow); border: 1px solid var(--line); text-align: center;
}
.login-box img.logo { width: 220px; max-width: 85%; margin: 4px auto 6px; display: block; }
.login-box p { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.login-box input { width: 100%; margin-bottom: 12px; }
.login-box button { width: 100%; }

/* ---- Layout ---- */
#app { display: none; min-height: 100vh; }
header {
  display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 60px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
  box-shadow: 0 1px 6px rgba(40,20,60,.04);
}
header .brand img { height: 34px; display: block; }
nav { display: flex; gap: 4px; flex: 1; }
nav a {
  padding: 8px 14px; border-radius: 7px; color: var(--muted); text-decoration: none;
  font-weight: 500; font-size: 13.5px;
}
nav a:hover { color: var(--accent); background: var(--accent-soft); }
nav a.active { color: #fff; background: var(--accent); }
nav a.soon { opacity: .5; cursor: not-allowed; pointer-events: none; }
nav a.soon::after { content: "próximamente"; font-size: 9px; margin-left: 5px; vertical-align: super; }
header .user { color: var(--muted); font-size: 13px; font-weight: 600; }
main { padding: 22px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

h2.title { margin: 0 0 16px; font-size: 19px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
label.fld { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }

.btn { background: var(--accent); color: #fff; border: none; border-radius: 7px; padding: 8px 14px; font-weight: 600; }
.btn:hover { background: var(--accent2); }
.btn.sec { background: #fff; border: 1px solid var(--line); color: var(--txt); }
.btn.sec:hover { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; color: var(--red); border: 1px solid transparent; padding: 4px 8px; }
.btn.danger:hover { background: rgba(217,45,32,.10); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.link { background: none; border: none; color: var(--accent); font-weight: 600; padding: 0; }
.btn.link:hover { text-decoration: underline; }

/* ---- Cards comunidades ---- */
.grid-com { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; }
.com-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: .15s; position: relative;
}
.com-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.com-card h3 { margin: 0 0 4px; font-size: 16px; color: var(--accent); }
.com-card .dir { color: var(--muted); font-size: 12.5px; min-height: 16px; }
.com-card .meta { margin-top: 12px; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.com-card .badge { background: var(--accent-soft); color: var(--accent); padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.com-card .acts { position: absolute; top: 12px; right: 10px; display: flex; gap: 2px; opacity: 0; transition: .15s; }
.com-card:hover .acts { opacity: 1; }

.crumb { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; }
.crumb .sep { color: var(--muted); }

/* ---- Tables ---- */
.tablewrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 72vh; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
thead th { position: sticky; top: 0; background: var(--panel2); z-index: 2; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: var(--accent-soft); }
.fp { padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.fp-Efectivo { background: rgba(26,156,78,.14); color: var(--green); }
.fp-Domiciliado { background: var(--accent-soft); color: var(--accent); }
.fp-Transferencia { background: rgba(199,119,0,.14); color: var(--amber); }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ---- Rejilla de pagos por mes ---- */
th.mes-h { text-align: center; padding: 8px 4px; }
td.mes {
  text-align: center; cursor: pointer; user-select: none; width: 38px; min-width: 38px;
  padding: 8px 4px; color: var(--green); font-weight: 800; border-left: 1px solid var(--line);
}
td.mes:hover { background: var(--accent-soft); }
td.mes.pagado { background: rgba(26,156,78,.16); }
td.mes.pagado:hover { background: rgba(26,156,78,.28); }

/* ---- Modal ---- */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(25,15,40,.45); z-index: 50; align-items: center; justify-content: center; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; width: 460px; max-width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 12px 40px rgba(40,20,60,.25); }
.modal h3 { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal .body { padding: 20px; display: grid; gap: 12px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.modal input, .modal select, .modal textarea { width: 100%; }

#toast { position: fixed; bottom: 24px; right: 24px; background: var(--green); color: #fff; padding: 12px 18px; border-radius: 8px; font-weight: 600; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .25s; z-index: 100; }
#toast.show { opacity: 1; transform: translateY(0); }
#toast.err { background: var(--red); }
.muted { color: var(--muted); }
