* { margin:0; padding:0; box-sizing:border-box; }
[hidden] { display:none !important; }
body { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif; background:#f0f2f5; color:#333; }

/* Layout principal: sidebar + content */
#app { display:flex; height:100vh; }

/* Sidebar — ocupa toda la altura izquierda */
#sidebar {
  width:220px;
  min-width:220px;
  background:#1a3a2a;
  color:#fff;
  display:flex;
  flex-direction:column;
  overflow-y:auto;
  flex-shrink:0;
}
.sidebar-brand {
  font-size:1.2rem;
  font-weight:700;
  padding:16px 20px;
  border-bottom:1px solid rgba(255,255,255,.1);
  flex-shrink:0;
}
#sidebar-nav { display:flex; flex-direction:column; gap:2px; padding:8px 0; flex:1; }
.nav-item {
  background:transparent;
  border:none;
  color:#fff;
  padding:10px 20px;
  text-align:left;
  font-size:.9rem;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:10px;
  transition:background .15s;
  width:100%;
}
.nav-item:hover { background:rgba(255,255,255,.1); }
.nav-item.active { background:rgba(255,255,255,.2); font-weight:600; }
.nav-icon { opacity:.6; width:20px; text-align:center; }

/* Sidebar footer — usuario y logout */
#sidebar-footer {
  border-top:1px solid rgba(255,255,255,.1);
  padding:12px 20px;
  display:flex;
  flex-direction:column;
  gap:8px;
  flex-shrink:0;
}
#sidebar-user-info { font-size:.8rem; opacity:.8; }
#sidebar-logout {
  background:rgba(255,255,255,.15);
  border:none;
  color:#fff;
  padding:5px 10px;
  border-radius:4px;
  cursor:pointer;
  font-size:.8rem;
  text-align:center;
}
#sidebar-logout:hover { background:rgba(255,255,255,.25); }

/* Content area */
#content {
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}

/* Header dentro del content */
#header {
  background:#fff;
  padding:0 24px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  height:56px;
  border-bottom:1px solid #e0e0e0;
  flex-shrink:0;
}
#header h1 { font-size:1.1rem; font-weight:600; color:#1a3a2a; }
#auth-area { display:flex; gap:8px; align-items:center; }
#auth-area input { padding:6px 10px; border:1px solid #ccc; border-radius:4px; font-size:.85rem; }
#auth-status { font-size:.85rem; color:#666; }

/* Main scrollable content */
main {
  flex:1;
  padding:24px;
  overflow-y:auto;
}
.page { display:none; }
.page.active { display:block; }

/* Stats grid */
.stats-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(180px,1fr));
  gap:16px;
  margin-bottom:24px;
}
.stat-card {
  background:#fff;
  border-radius:8px;
  padding:20px;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
  text-align:center;
}
.stat-value { font-size:2rem; font-weight:700; color:#1a3a2a; }
.stat-label { font-size:.8rem; color:#666; margin-top:4px; }

/* Info section */
.info-section {
  background:#fff;
  border-radius:8px;
  padding:20px;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
}
.info-section h3 { margin-bottom:12px; color:#1a3a2a; font-size:1rem; }
.info-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:12px; }
.info-item { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid #eee; font-size:.85rem; }
.info-item .label { color:#666; }
.info-item .value { font-weight:600; color:#333; }

/* Tables */
table { width:100%; border-collapse:collapse; font-size:.82rem; background:#fff; border-radius:8px; overflow:hidden; box-shadow:0 1px 3px rgba(0,0,0,.08); }
th, td { padding:10px; text-align:left; border-bottom:1px solid #eee; }
th { background:#f9f9f9; font-weight:600; color:#555; }
td button { padding:4px 10px; font-size:.75rem; background:#c62828; color:#fff; border:none; border-radius:4px; cursor:pointer; }
td button:hover { background:#b71c1c; }

/* User cards */
.user-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(300px,1fr)); gap:16px; }
.user-card {
  background:#fff;
  border-radius:8px;
  padding:20px;
  box-shadow:0 1px 3px rgba(0,0,0,.08);
}
.user-card-header { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
.user-card-header h4 { font-size:1rem; color:#1a3a2a; }
.user-badge { font-size:.7rem; padding:2px 8px; border-radius:10px; font-weight:600; }
.badge-superadmin { background:#1a3a2a; color:#fff; }
.badge-admin { background:#1565c0; color:#fff; }
.badge-user { background:#757575; color:#fff; }
.user-field { font-size:.85rem; padding:4px 0; color:#555; }
.user-field strong { color:#333; }
.user-owner { color:#c62828; font-weight:600; }
.user-card-actions { display:flex; gap:8px; margin-top:12px; }
.user-card-actions button {
  padding:5px 12px;
  font-size:.8rem;
  border:none;
  border-radius:4px;
  cursor:pointer;
}
.btn-edit { background:#1565c0; color:#fff; }
.btn-edit:hover { background:#0d47a1; }
.btn-destroy { background:#c62828; color:#fff; }
.btn-destroy:hover { background:#b71c1c; }
.btn-assign { background:#2e7d32; color:#fff; }
.btn-assign:hover { background:#1b5e20; }

/* Role selector modal */
.modal-overlay {
  position:fixed; top:0; left:0; right:0; bottom:0;
  background:rgba(0,0,0,.5);
  display:flex; align-items:center; justify-content:center;
  z-index:100;
}
.modal {
  background:#fff;
  border-radius:8px;
  padding:24px;
  width:90%;
  max-width:400px;
  box-shadow:0 4px 20px rgba(0,0,0,.2);
}
.modal h3 { margin-bottom:16px; color:#1a3a2a; }
.modal label { display:block; margin-bottom:8px; font-size:.85rem; }
.modal select, .modal input {
  width:100%;
  padding:8px;
  border:1px solid #ccc;
  border-radius:4px;
  font-size:.85rem;
  margin-top:4px;
}
.modal-actions { display:flex; gap:8px; margin-top:16px; justify-content:flex-end; }
.modal-actions button {
  padding:8px 16px;
  border:none;
  border-radius:4px;
  cursor:pointer;
  font-size:.85rem;
}
.modal-actions .btn-cancel { background:#e0e0e0; color:#333; }
.modal-actions .btn-save { background:#1a3a2a; color:#fff; }

/* Forms */
.form-row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.form-row label { display:flex; flex-direction:column; font-size:.8rem; gap:2px; }
.form-row input { padding:6px 8px; border:1px solid #ccc; border-radius:4px; font-size:.85rem; }
button[type="submit"] { padding:6px 14px; background:#1a3a2a; color:#fff; border:none; border-radius:4px; cursor:pointer; font-size:.85rem; }
button[type="submit"]:hover { background:#245a3a; }

/* Toast */
#toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:#333; color:#fff; padding:10px 20px; border-radius:6px; font-size:.9rem; opacity:0; transition:opacity .3s; }
#toast:empty { display:none; }

/* Search bar */
.search-bar {
  margin-bottom:16px;
  display:flex;
  gap:8px;
  align-items:center;
}
.search-bar input {
  flex:1;
  padding:8px 12px;
  border:1px solid #ccc;
  border-radius:4px;
  font-size:.85rem;
}

/* Empty state */
.empty-state {
  text-align:center;
  padding:40px;
  color:#999;
}

/* Responsive */
@media(max-width:768px) {
  #sidebar { width:170px; min-width:170px; }
  .sidebar-brand, .nav-item, #sidebar-footer { padding-left:12px; padding-right:12px; }
  main { padding:16px; }
  .stats-grid { grid-template-columns:repeat(2,1fr); }
  .user-grid { grid-template-columns:1fr; }
}
