:root {
  --primary: #3b82f6; /* Blue 500 */
  --primary-dark: #2563eb; /* Blue 600 */
  --secondary: #64748b; /* Slate 500 */
  --bg-body: #f1f5f9; /* Slate 100 */
  --bg-sidebar: #1e293b; /* Slate 800 */
  --bg-surface: #ffffff;
  --text-main: #1e293b; /* Slate 800 */
  --text-muted: #64748b; /* Slate 500 */
  --text-light: #f8fafc; /* Slate 50 */
  --border: #e2e8f0; /* Slate 200 */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --radius: 0.5rem;
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar .brand {
  height: 64px;
  /* Sin esto el logo se recorta: como hijo de un flex en columna, su
     flex-shrink por defecto es 1 y `height` no actúa de mínimo, así que
     cuando el menú no cabe la cabecera se aplasta. */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-weight: 700;
  font-size: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  gap: 12px;
}
.sidebar .brand .material-icons-round { color: var(--primary); }

.sidebar nav {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* El menú es lo único que hace scroll: el logo y el usuario se quedan fijos.
     min-height: 0 es imprescindible — el valor por defecto (auto) impide que un
     hijo flex encoja por debajo de su contenido, y sin él overflow-y no llega a
     activarse nunca y las últimas entradas quedan inalcanzables. */
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Barra de scroll discreta sobre el fondo oscuro de la barra lateral */
.sidebar nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb {
  background-color: rgba(255,255,255,0.2);
  border-radius: 4px;
}
.sidebar nav::-webkit-scrollbar-thumb:hover { background-color: rgba(255,255,255,0.35); }

/* Los enlaces tampoco deben encogerse ni partir el texto en dos líneas */
.sidebar nav a { flex-shrink: 0; white-space: nowrap; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: #94a3b8; /* Slate 400 */
  text-decoration: none;
  border-radius: var(--radius);
  transition: all 0.2s;
  font-weight: 500;
}

.sidebar nav a:hover {
  background-color: rgba(255,255,255,0.05);
  color: var(--text-light);
}

.sidebar nav a.active {
  background-color: var(--primary);
  color: #fff;
}

.sidebar .user-info {
  padding: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;   /* se queda anclado abajo, no se aplasta con el menú */
}
.sidebar .avatar {
  width: 40px; height: 40px;
  flex-shrink: 0;

  background: var(--primary-dark);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.sidebar .details { display: flex; flex-direction: column; }
.sidebar .details .name { font-weight: 600; font-size: 0.9rem; }
.sidebar .details .role { font-size: 0.8rem; color: #94a3b8; }

/* Main Content */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  flex-shrink: 0;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* Typography & Elements */
h1, h2, h3 { margin-top: 0; color: var(--text-main); font-weight: 600; }
h2 { font-size: 1.5rem; margin-bottom: 1.5rem; }
h3 { font-size: 1.125rem; margin-bottom: 1rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Cards */
section, .card {
  background: var(--bg-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 24px;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem; /* Injected into page content usually */
  display: flex; gap: 8px; align-items: center;
}
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }

/* Tables */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}
th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background-color: #f8fafc; }

/* Buttons */
.btn, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn.small { padding: 6px 12px; font-size: 0.8rem; }
.btn.primary, button[type="submit"] {
  background-color: var(--primary);
  color: white;
}
.btn.primary:hover, button[type="submit"]:hover {
  background-color: var(--primary-dark);
}
.btn.secondary {
  background-color: white;
  border-color: var(--border);
  color: var(--text-main);
}
.btn.secondary:hover {
  background-color: #f8fafc;
}

/* Forms */
input, select, textarea {
  display: block;
  width: 100%;
  max-width: 500px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-main);
  background: #fff;
  transition: border-color 0.2s;
  margin-top: 4px;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 12px;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.stat-card .label { font-size: 0.875rem; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 1.875rem; font-weight: 700; color: var(--text-main); margin-top: 8px; }
.stat-card .trend { font-size: 0.75rem; margin-top: 4px; color: var(--success); }

/* Badges */
.badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.blue { background: #eff6ff; color: #1d4ed8; }
.badge.green { background: #f0fdf4; color: #15803d; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badge.yellow { background: #fffbeb; color: #b45309; }

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 12px 24px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text-main); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Material Icons adjustment */
.material-icons-round { font-size: 20px; vertical-align: middle; }
