:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #1c2128;
  --bg4: #22272e;
  --border: #30363d;
  --border2: #3d444d;
  --accent: #a78bfa;
  --accent-dim: rgba(167, 139, 250, 0.12);
  --accent-hover: #8b5cf6;
  --blue: #388bfd;
  --blue-dim: rgba(56, 139, 253, 0.12);
  --amber: #d29922;
  --amber-dim: rgba(210, 153, 34, 0.12);
  --danger: #f85149;
  --danger-dim: rgba(248, 81, 73, 0.12);
  --success: #3fb950;
  --success-dim: rgba(63, 185, 80, 0.12);
  --purple: #bc8cff;
  --purple-dim: rgba(188, 140, 255, 0.12);
  --teal: #00d4aa;
  --teal-dim: rgba(0, 212, 170, 0.12);
  --text: #e6edf3;
  --text2: #b1bac4;
  --muted: #656d76;
  --sidebar-w: 240px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.5);
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
small { font-size: 0.8rem; color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.sidebar-logo .logo-text { font-size: 0.9rem; font-weight: 700; color: var(--text); line-height: 1.2; }
.sidebar-logo .logo-text small { display: block; font-size: 0.7rem; font-weight: 400; color: var(--muted); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-label {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 8px 10px 4px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius);
  color: var(--text2); cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: 0.88rem; font-weight: 500;
  border: none; background: none; width: 100%;
  text-align: left; text-decoration: none;
}
.nav-item:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; font-size: 0.68rem;
  background: var(--accent-dim); color: var(--accent);
  padding: 1px 6px; border-radius: 20px; font-weight: 600;
}
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius); background: var(--bg3);
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent); flex-shrink: 0;
}
.user-name { font-size: 0.82rem; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 0.7rem; color: var(--muted); }
.logout-btn {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px; margin-left: auto;
  border-radius: 4px; font-size: 14px; transition: color var(--transition);
}
.logout-btn:hover { color: var(--danger); }

.main { flex: 1; margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 12px;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-subtitle { font-size: 0.8rem; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.menu-toggle {
  display: none; background: none;
  border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 6px 8px; cursor: pointer; font-size: 16px;
}
.content { padding: 24px; flex: 1; }

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.card-title { font-size: 0.88rem; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: 0.04em; }
.card-icon { font-size: 18px; }
.stat-value { font-size: 1.8rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-sub { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.stat-accent { color: var(--accent); }
.stat-blue { color: var(--blue); }
.stat-amber { color: var(--amber); }
.stat-danger { color: var(--danger); }
.stat-teal { color: var(--teal); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 0.83rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition); white-space: nowrap; line-height: 1;
}
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }
.btn-xs { padding: 3px 8px; font-size: 0.72rem; }
.btn-icon { padding: 7px; }
.btn-primary { background: var(--accent); color: #0d1117; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-secondary:hover { background: var(--bg4); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-blue { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.btn-blue:hover { background: var(--blue); color: #fff; }
.btn-amber { background: var(--amber-dim); color: var(--amber); border-color: var(--amber); }
.btn-amber:hover { background: var(--amber); color: #fff; }
.btn-teal { background: var(--teal-dim); color: var(--teal); border-color: var(--teal); }
.btn-teal:hover { background: var(--teal); color: #0d1117; }
.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--bg3); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600; border: 1px solid;
}
.badge-accent { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.badge-blue { background: var(--blue-dim); color: var(--blue); border-color: var(--blue); }
.badge-amber { background: var(--amber-dim); color: var(--amber); border-color: var(--amber); }
.badge-danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.badge-success { background: var(--success-dim); color: var(--success); border-color: var(--success); }
.badge-purple { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.badge-muted { background: var(--bg3); color: var(--muted); border-color: var(--border2); }
.badge-teal { background: var(--teal-dim); color: var(--teal); border-color: var(--teal); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th {
  text-align: left; padding: 10px 12px;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 11px 12px; color: var(--text); vertical-align: middle; }
.td-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.82rem; }
.td-right { text-align: right; }
.td-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.td-center { text-align: center; }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 12px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-hint { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }
.input-group { display: flex; align-items: center; }
.input-prefix {
  padding: 8px 10px; background: var(--bg4);
  border: 1px solid var(--border); border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--muted); font-size: 0.82rem; white-space: nowrap;
}
.input-group .form-control { border-radius: 0 var(--radius) var(--radius) 0; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  z-index: 1000; display: none; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); width: 100%;
  max-width: 500px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 700px; }
.modal-header {
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg2); z-index: 1;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close {
  background: none; border: 1px solid var(--border); color: var(--muted);
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
  font-size: 16px; display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--danger); color: var(--danger); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

#toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: 2000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 0.85rem; font-weight: 500;
  background: var(--bg2); border: 1px solid var(--border2); color: var(--text);
  box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn 0.2s ease; min-width: 280px; max-width: 380px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--blue); }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo-icon {
  width: 56px; height: 56px;
  background: var(--accent-dim); border: 2px solid var(--accent);
  border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; margin: 0 auto 12px;
}
.login-logo h2 { font-size: 1.1rem; margin-bottom: 2px; }
.login-logo p { font-size: 0.8rem; color: var(--muted); }
.login-btn { width: 100%; padding: 10px; font-size: 0.9rem; justify-content: center; margin-top: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab-btn {
  padding: 10px 16px; background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--muted);
  cursor: pointer; font-size: 0.85rem; font-weight: 500;
  white-space: nowrap; transition: all var(--transition); margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.progress { height: 6px; background: var(--bg4); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 3px; background: var(--accent); transition: width 0.4s ease; }

.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 1rem; font-weight: 700; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 99; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity var(--transition); }
  .sidebar-overlay.open { opacity: 1; pointer-events: all; }
  .main { margin-left: 0; }
  .menu-toggle { display: flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .modal { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; align-self: flex-end; }
  .modal-overlay { align-items: flex-end; padding: 0; }
}
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-blue { color: var(--blue); }
.text-amber { color: var(--amber); }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ── Fondo cards ─── */
.fondo-comun { border-left: 3px solid var(--teal); }
.fondo-beneficencia { border-left: 3px solid var(--blue); }
.fondo-viajes { border-left: 3px solid var(--amber); }
.fondo-emergencia { border-left: 3px solid var(--danger); }

/* ── Socio colors ─── */
.socio-cb { --socio-color: var(--accent); }
.socio-cp { --socio-color: var(--teal); }
.socio-fp { --socio-color: var(--blue); }
