/* =====================================================================
   ERPO ACCESS  -  Estilos principales
   Paleta de marca (verde) + tema claro/oscuro + layout SaaS.
   ===================================================================== */

:root {
  /* Marca */
  --brand-1: #22C55E;
  --brand-2: #0F9D58;
  --brand-soft: #4ADE80;

  /* Estados */
  --ok:    #16A34A;
  --danger:#DC2626;
  --warn:  #F59E0B;
  --info:  #0EA5E9;

  /* Tema claro (por defecto) */
  --bg:        #F2FAF5;
  --surface:   #FFFFFF;
  --surface-2: #EEF7F1;
  --text:      #12241A;
  --muted:     #5C7268;
  --border:    #DCEDE2;
  --shadow:    0 1px 2px rgba(18,36,26,.06), 0 8px 24px rgba(18,36,26,.06);

  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
  --radius: 14px;
  --radius-sm: 10px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="oscuro"] {
  --bg:        #090F0B;
  --surface:   #11201A;
  --surface-2: #17291F;
  --text:      #E8F5EE;
  --muted:     #8FAB9C;
  --border:    #21362A;
  --shadow:    0 1px 2px rgba(0,0,0,.45), 0 12px 30px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--brand-1); text-decoration: none; }
a:hover { color: var(--brand-2); }

/* ---------- Wordmark ---------- */
.brand-mark {
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
  display: inline-flex;
  align-items: baseline;
  gap: .12em;
}
.brand-mark .erpo { color: #fff; }
.brand-mark .access {
  color: #fff;
  opacity: .72;
  font-weight: 600;
}

/* =====================================================================
   LOGIN
   ===================================================================== */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.auth-aside {
  position: relative;
  background: linear-gradient(150deg, var(--brand-1) 0%, var(--brand-2) 100%);
  color: #fff;
  padding: 56px 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
/* patron sutil de seguridad */
.auth-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,.10) 1px, transparent 0);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, transparent, #000 40%, #000 70%, transparent);
  pointer-events: none;
}
.auth-aside .brand-mark { font-size: 30px; position: relative; z-index: 1; }
.auth-aside .aside-body { position: relative; z-index: 1; }
.auth-aside h1 {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.12;
  margin: 0 0 14px;
  max-width: 18ch;
}
.auth-aside p { color: rgba(255,255,255,.82); max-width: 40ch; margin: 0; }
.auth-aside .shield {
  width: 64px; height: 64px;
  border-radius: 18px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  display: grid; place-items: center;
  font-size: 30px;
  margin-bottom: 28px;
}
.auth-aside .features {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 12px;
  color: rgba(255,255,255,.9);
}
.auth-aside .features span { display: flex; align-items: center; gap: 10px; }
.auth-aside .features i { opacity: .85; }

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--surface);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .eyebrow {
  color: var(--brand-1);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.auth-card h2 { font-weight: 800; margin: 8px 0 4px; font-size: 26px; }
.auth-card .sub { color: var(--muted); margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
.input-wrap { position: relative; }
.input-wrap > i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 16px;
}
.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 42px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}
.toggle-pass {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: 6px; font-size: 16px;
}

.btn-brand {
  width: 100%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease;
}
.btn-brand:hover { filter: brightness(1.06); }
.btn-brand:active { transform: translateY(1px); }
.btn-brand:disabled { opacity: .65; cursor: default; }

.alert-inline {
  display: none;
  background: rgba(220,38,38,.10);
  border: 1px solid rgba(220,38,38,.30);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-inline.show { display: block; }

/* ---------- Codigo de acceso de la residencial ---------- */
.codigo-boxes {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 8px;
}
.codigo-boxes input {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.codigo-boxes input:focus {
  border-color: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}
.codigo-ayuda { color: var(--muted); font-size: 13px; text-align: center; margin: 0 0 24px; }

/* ---------- Pagina de bienvenida (logo, descripcion, anuncios) ---------- */
.bienvenida-page {
  min-height: 100vh;
  background: linear-gradient(150deg, var(--brand-1) 0%, var(--brand-2) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 20px 32px;
}
.bienvenida-hero {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  margin-bottom: 22px;
}
.bienvenida-logo {
  width: 88px;
  height: 88px;
  border-radius: 20px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  font-size: 34px;
  color: var(--brand-1);
}
.bienvenida-logo img { width: 100%; height: 100%; object-fit: cover; }
.bienvenida-hero h1 { font-size: 23px; font-weight: 800; margin: 0 0 10px; }
.bienvenida-hero p { color: var(--muted); font-size: 14.5px; line-height: 1.5; margin: 0 0 24px; }
.bienvenida-hero .btn-brand { width: auto; padding: 11px 28px; display: inline-block; }
.bienvenida-anuncios { max-width: 480px; width: 100%; margin-bottom: 18px; }
.bienvenida-cambiar {
  color: rgba(255,255,255,.85);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bienvenida-cambiar:hover { color: #fff; }

/* ---------- Mi residencial (logo del encargado) ---------- */
.mires-logo {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
  font-size: 44px;
  color: var(--brand-1);
}
.mires-logo img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Lista de casillas (residenciales asignadas a un encargado) ---------- */
.checklist {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  background: var(--surface-2);
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 6px;
}
.checklist-item:hover { background: var(--surface); }
.checklist-item input { margin: 0; }
.checklist-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ---------- Insignia de residencial activa (pantalla de login) ---------- */
.residencial-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 22px;
  font-size: 14px;
}
.residencial-badge i { color: var(--brand-1); font-size: 18px; flex-shrink: 0; }
.residencial-badge .nombre { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.residencial-badge a { margin-left: auto; font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* =====================================================================
   LAYOUT (sidebar + topbar + content)
   ===================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-1) 0%, var(--brand-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .2s ease;
  z-index: 30;
}
.sidebar .sb-head {
  height: 64px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  font-size: 19px;
}
.sidebar .sb-head .logo-box {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: rgba(255,255,255,.16);
  display: grid; place-items: center; font-size: 18px;
}
.sidebar nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-group { margin-bottom: 2px; }
.nav-group-label {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: rgba(255,255,255,.55); padding: 14px 12px 6px;
}
.nav-group-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: 0; margin: 0; font-family: inherit; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  text-align: left; outline: none;
  transition: color .12s;
}
.nav-group-toggle:focus-visible { box-shadow: 0 0 0 2px rgba(255,255,255,.35); border-radius: 6px; }
.nav-group-toggle:hover { color: rgba(255,255,255,.85); }
.nav-group-caret { font-size: 13px; transition: transform .18s ease; flex-shrink: 0; }
.nav-group.collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group-items {
  overflow: hidden;
  max-height: 1200px;
  transition: max-height .22s ease;
}
.nav-group.collapsed .nav-group-items { max-height: 0; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.85);
  font-size: 14.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  margin-bottom: 2px;
  position: relative;
  transition: background-color .12s;
}
.nav-item i { font-size: 18px; flex-shrink: 0; width: 22px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: #fff;
}
.nav-item.disabled {
  color: rgba(255,255,255,.42);
  cursor: not-allowed;
}
.nav-item.disabled:hover { background: transparent; color: rgba(255,255,255,.42); }
.sidebar .sb-foot {
  padding: 12px; border-top: 1px solid rgba(255,255,255,.14);
}
.sb-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; white-space: nowrap; overflow: hidden;
}
.sb-user .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,.20);
  display: grid; place-items: center; font-weight: 700;
}
.sb-user .meta { line-height: 1.2; overflow: hidden; }
.sb-user .meta strong { font-size: 13.5px; display: block; }
.sb-user .meta small { color: rgba(255,255,255,.65); font-size: 11.5px; }

/* Sidebar colapsado */
body.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .sidebar .label,
body.sb-collapsed .sidebar .nav-group-label,
body.sb-collapsed .sidebar .sb-user .meta { display: none; }
body.sb-collapsed .sidebar .nav-group-items { max-height: none !important; overflow: visible; }
body.sb-collapsed .sidebar .nav-item { justify-content: center; }
body.sb-collapsed .sidebar .sb-head { justify-content: center; padding: 0; }

/* Contenido */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 20;
}
.icon-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text); width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer; font-size: 18px;
  transition: background-color .12s;
}
.icon-btn:hover { background: var(--surface-2); }
.topbar .page-title { font-weight: 700; font-size: 17px; }
.topbar .spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; cursor: pointer;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.user-chip .uname { font-size: 14px; font-weight: 600; }

.content { padding: 26px 22px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14.5px; }

/* =====================================================================
   TARJETAS KPI
   ===================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.kpi .kpi-icon {
  width: 52px; height: 52px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
}
.kpi .kpi-icon.brand { background: rgba(34,197,94,.12); color: var(--brand-1); }
.kpi .kpi-icon.ok    { background: rgba(21,163,74,.12);  color: var(--ok); }
.kpi .kpi-icon.info  { background: rgba(14,165,233,.12); color: var(--info); }
.kpi .kpi-icon.warn  { background: rgba(245,158,11,.14); color: var(--warn); }
.kpi .kpi-val { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi .kpi-label { color: var(--muted); font-size: 13.5px; margin-top: 6px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-top: 22px;
}
.panel h3 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.panel p { color: var(--muted); margin: 0; font-size: 14px; }
.badge-soft {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34,197,94,.12); color: var(--brand-1);
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}

/* Overlay para sidebar en movil */
.sb-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 25;
}
.sb-overlay.show { display: block; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 992px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { padding: 36px 28px; min-height: auto; }
  .auth-aside .features { display: none; }
}

@media (max-width: 380px) {
  .codigo-boxes input { width: 44px; height: 52px; font-size: 22px; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform .22s ease;
  }
  body.sb-open .sidebar { transform: translateX(0); }
  body.sb-collapsed .sidebar { width: var(--sidebar-w); }
  body.sb-collapsed .sidebar .label,
  body.sb-collapsed .sidebar .nav-group-label,
  body.sb-collapsed .sidebar .sb-user .meta { display: block; }
  .topbar .user-chip .uname { display: none; }
}

/* Accesibilidad: foco visible */
:focus-visible { outline: 2px solid var(--brand-soft); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* =====================================================================
   BLOQUE 2 - Listados, formularios, toolbar, estado, toasts
   ===================================================================== */

/* Encabezado de pagina con accion a la derecha */
.page-head.with-action {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.page-head.with-action .actions { flex-shrink: 0; }

/* Botones */
.btn-brand.inline { width: auto; display: inline-flex; align-items: center; gap: 8px; }
.btn-soft {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 14px; font-weight: 600; font-size: 14px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: background-color .12s, border-color .12s;
}
.btn-soft:hover { border-color: var(--brand-soft); color: var(--text); }
.btn-icon {
  background: transparent; border: 1px solid var(--border);
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-grid; place-items: center; cursor: pointer;
  color: var(--muted); font-size: 15px;
  transition: background-color .12s, color .12s, border-color .12s;
}
.btn-icon:hover { color: var(--brand-1); border-color: var(--brand-soft); }
.btn-icon.danger:hover { color: var(--danger); border-color: var(--danger); }
.btn-icon.ok:hover { color: var(--ok); border-color: var(--ok); }

/* Toolbar de filtros */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .search {
  position: relative; flex: 1; min-width: 220px; max-width: 360px;
}
.toolbar .search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 15px;
}
.toolbar .search input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 9px 12px 9px 36px; font-size: 14px; outline: none;
}
.toolbar .search input:focus { border-color: var(--brand-soft); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.toolbar select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 14px; outline: none;
}
.toolbar select:focus { border-color: var(--brand-soft); }
.toolbar .spacer { flex: 1; }

/* Tabla de datos */
.card-table {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted);
  padding: 13px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.codigo-tag {
  font-family: 'SFMono-Regular', Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  letter-spacing: .06em;
  font-size: 13px;
}
.res-thumb {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 16px;
  color: var(--muted);
}
.res-thumb img { width: 100%; height: 100%; object-fit: cover; }
.res-thumb-lg { width: 64px; height: 64px; border-radius: 14px; font-size: 26px; }
.data-table .col-acciones { text-align: right; white-space: nowrap; }
.data-table .col-acciones .btn-icon { margin-left: 4px; }
.data-table .principal { font-weight: 600; }
.data-table .sub { color: var(--muted); font-size: 12.5px; }

/* Badge de estado */
.estado {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.estado.activo  { background: rgba(21,163,74,.12);  color: var(--ok); }
.estado.inactivo{ background: rgba(220,38,38,.10);  color: var(--danger); }
.estado .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.chip-count {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}

/* Estado vacio */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 38px; opacity: .5; display: block; margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: 14.5px; }

/* Paginacion */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pager .info { color: var(--muted); font-size: 13px; }
.pager .pages { display: flex; gap: 6px; }
.pager a, .pager span.cur {
  min-width: 34px; height: 34px; padding: 0 8px; border-radius: 9px;
  display: inline-grid; place-items: center; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--border);
}
.pager a { color: var(--text); background: var(--surface); }
.pager a:hover { border-color: var(--brand-soft); color: var(--brand-1); }
.pager span.cur { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; border-color: transparent; }
.pager span.disabled { opacity: .4; }

/* Grid de dos columnas (estructura) */
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .cols-2 { grid-template-columns: 1fr; } }

.block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.block-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.block-head h3 { margin: 0; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.block-head h3 i { color: var(--brand-1); }
.block-body { padding: 6px 0; }
.list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .grow strong { font-size: 14px; font-weight: 600; display: block; }
.list-row .grow small { color: var(--muted); font-size: 12.5px; }

/* Form fields dentro de modales */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.field-modal label { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: block; }
.field-modal .req { color: var(--danger); }
.field-modal input, .field-modal select, .field-modal textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14.5px; outline: none; font-family: inherit;
}
.field-modal input:focus, .field-modal select:focus, .field-modal textarea:focus {
  border-color: var(--brand-soft); box-shadow: 0 0 0 3px rgba(34,197,94,.15);
}
.field-modal textarea { resize: vertical; min-height: 70px; }

/* Modal Bootstrap con tokens de marca */
.modal-content {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-weight: 700; font-size: 17px; }
.modal-error {
  display: none; background: rgba(220,38,38,.10); border: 1px solid rgba(220,38,38,.3);
  color: var(--danger); border-radius: var(--radius-sm); padding: 9px 12px;
  font-size: 13.5px; margin-bottom: 14px;
}
.modal-error.show { display: block; }

/* Toasts */
.toast-stack {
  position: fixed; right: 18px; bottom: 18px; z-index: 1080;
  display: flex; flex-direction: column; gap: 10px;
}
.toast-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 12px 16px; box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500;
  transform: translateY(12px); opacity: 0;
  transition: transform .22s ease, opacity .22s ease;
  min-width: 240px; max-width: 360px;
}
.toast-item.show { transform: translateY(0); opacity: 1; }
.toast-item i { font-size: 18px; }
.toast-item.is-ok i { color: var(--ok); }
.toast-item.is-error i { color: var(--danger); }

/* =====================================================================
   BLOQUE 3 - Dias (tabla y selector)
   ===================================================================== */
.dias-row { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.dia-tag {
  width: 22px; height: 22px; border-radius: 6px;
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.dia-tag.on { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff; border-color: transparent; }

.dias-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.dia-check { position: relative; cursor: pointer; margin: 0; }
.dia-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.dia-check span {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-weight: 700; font-size: 14px;
  transition: background-color .12s, color .12s, border-color .12s;
}
.dia-check input:checked + span {
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; border-color: transparent;
}
.dia-check input:focus-visible + span { outline: 2px solid var(--brand-soft); outline-offset: 2px; }

/* =====================================================================
   BLOQUE 4 - Matriz de permisos por rol
   ===================================================================== */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.perm-card .block-head { background: var(--surface-2); }
.perm-all {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; margin: 0;
}
.perm-all input { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--brand-1); }
.perm-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; margin: 0;
}
.perm-row:last-child { border-bottom: 0; }
.perm-row:hover { background: var(--surface-2); }
.perm-row input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; cursor: pointer; accent-color: var(--brand-1); }
.perm-row input:disabled { cursor: not-allowed; }
.perm-row .grow { min-width: 0; }
.perm-row .grow strong { display: block; font-size: 14px; font-weight: 600; }
.perm-row .grow small { color: var(--muted); font-size: 12px; }

/* =====================================================================
   BLOQUE 8 - QR en modal de invitacion
   ===================================================================== */
.qr-box { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 14px; }
.qr-box canvas { display: block; }
.qr-link {
  margin-top: 12px; font-size: 12px; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-all; line-height: 1.4;
}

/* =====================================================================
   BLOQUE 9 - Validacion de QR en garita
   ===================================================================== */
.val-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .val-grid { grid-template-columns: 1fr; } }
.val-reader { width: 100%; max-width: 320px; margin: 0 auto; border-radius: 12px; overflow: hidden; }
.val-reader video { width: 100% !important; border-radius: 12px; }
.val-datos { border-top: 1px solid var(--border); }
.val-fila { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.val-fila .k { color: var(--muted); }
.val-fila .v { font-weight: 600; text-align: right; }
.val-historial { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.val-sub { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.val-mov { font-size: 13.5px; padding: 5px 0; color: var(--text); }
.val-mov i { color: var(--brand-1); }

/* =====================================================================
   BLOQUE 12 - Facturacion (resumen de cobro)
   ===================================================================== */
.resumen-cobro {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); color: #fff;
  border-radius: 16px; padding: 18px 22px; margin-bottom: 16px;
}
.resumen-cobro .rc-label { font-size: 13px; opacity: .85; letter-spacing: .04em; text-transform: uppercase; }
.resumen-cobro .rc-monto { font-size: 26px; font-weight: 800; }

/* =====================================================================
   BLOQUE 13 - Caja (total del cobro en modal)
   ===================================================================== */
.cob-total {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px; padding: 14px 16px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.cob-total strong { font-size: 22px; color: var(--brand-1); }
.cob-tabla th, .cob-tabla td { padding: 8px 6px; }

/* =====================================================================
   BLOQUE 14 - Estado de cuenta (tarjetas de resumen)
   ===================================================================== */
.estado-resumen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .estado-resumen { grid-template-columns: 1fr; } }
.er-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 16px 18px; }
.er-card .er-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.er-card .er-monto { font-size: 22px; font-weight: 800; margin-top: 4px; }
.er-card.destacado { background: linear-gradient(135deg, var(--brand-1), var(--brand-2)); border: 0; color: #fff; }
.er-card.destacado .er-label { color: rgba(255,255,255,.85); }

/* =====================================================================
   BLOQUE 16 - Incidentes (timeline de seguimiento)
   ===================================================================== */
.timeline { position: relative; padding-left: 8px; }
.tl-item { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); }
.tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-dot { position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-1); border: 2px solid var(--surface); }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-estado { font-size: 13.5px; margin-top: 2px; }
.tl-nota { font-size: 14px; margin-top: 4px; white-space: pre-wrap; }

/* =====================================================================
   BLOQUE 17 - Comunicados (tablon de tarjetas)
   ===================================================================== */
.tablon { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.com-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; }
.com-card.fijado { border-color: var(--brand-1); box-shadow: 0 0 0 1px var(--brand-1) inset; }
.com-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.com-cat { font-size: 12px; font-weight: 700; color: var(--brand-1); text-transform: uppercase; letter-spacing: .03em; display: inline-flex; align-items: center; gap: 6px; }
.com-tags { display: flex; gap: 6px; }
.com-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.com-tag.fijado { color: var(--brand-1); background: rgba(34,197,94,.12); }
.com-tag.borrador { color: var(--muted); background: var(--surface-2); }
.com-tag.vencido { color: var(--danger); background: rgba(220,38,38,.10); }
.com-titulo { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.com-contenido { font-size: 14px; color: var(--text); margin: 0 0 14px; white-space: pre-wrap; flex: 1; }
.com-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--border); padding-top: 10px; }
.com-meta { font-size: 12px; color: var(--muted); }
.com-acciones { display: flex; gap: 4px; flex-shrink: 0; }

/* =====================================================================
   BLOQUE 19 - Dashboard con graficos
   ===================================================================== */
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .chart-val { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart-svg .chart-lab { fill: var(--muted); font-size: 11px; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: 96px 1fr 40px; align-items: center; gap: 10px; }
.hbar-lab { font-size: 13px; color: var(--text); }
.hbar-track { height: 14px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; min-width: 2px; transition: width .4s ease; }
.hbar-val { font-size: 13px; font-weight: 700; text-align: right; }

/* =====================================================================
   BLOQUE 20 - Respaldos / botones de peligro
   ===================================================================== */
.btn-soft.danger { color: var(--danger); border-color: rgba(220,38,38,.35); }
.btn-soft.danger:hover { background: rgba(220,38,38,.08); }

/* Mensajes flash (server-side) */
.flash-msg { border-radius: 10px; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.flash-msg.ok { background: rgba(21,163,74,.12); color: var(--ok); }
.flash-msg.err { background: rgba(220,38,38,.10); color: var(--danger); }

/* Zona de peligro (vaciar datos) */
.danger-zone { border-color: rgba(220,38,38,.35); }
