:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 64px;
  --content-padding: 24px;
  --surface: #1e293b;
  --border: #334155;
  --accent: #38bdf8;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0f172a;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 400;
}

h1 {
  color: var(--accent);
  font-size: 1.4rem;
}

/* ---- Auth (login / registro) -- rutas separadas, sin layout de sidebar ---- */

.auth-view {
  max-width: 420px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.auth-view h2 {
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
}

.auth-view form {
  flex-direction: column;
  align-items: stretch;
}

.auth-cross-link {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-cross-link a { color: var(--accent); }

/* ---- App layout: sidebar por entidad + area de contenido ---- */

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

#sidebar-toggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 3.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  transition: width 0.15s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
}

.sidebar.collapsed .sidebar-brand,
.sidebar.collapsed .sidebar-link,
.sidebar.collapsed .sidebar-logout {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
}

.sidebar-brand {
  color: var(--accent);
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0 1rem 1rem;
}

.sidebar-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
}

.sidebar-link {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-link.active {
  color: #ffffff;
  border-left-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.sidebar-logout {
  margin: 1rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.content-area {
  flex: 1;
  padding: var(--content-padding);
  padding-top: calc(var(--content-padding) + 2.5rem);
  max-width: 720px;
}

.breadcrumb {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 1rem;
}

.page-title {
  color: var(--accent);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 1rem;
}

.section-title {
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
}

/* ---- Vistas / formularios (compartido) ---- */

.view, .auth-view form {
  background: var(--surface);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.view { border: 1px solid var(--border); }

/* ---- Tablas de listado (fila clickeable, sin ID crudo visible) ---- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.5rem;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem;
}

.data-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.data-table td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.data-table td a:hover { text-decoration: underline; }

.data-table td button {
  font-size: 0.8rem;
  padding: 0.3rem 0.6rem;
}

/* ---- Panel de detalle (vista de solo lectura de un registro) ---- */

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.back-link {
  display: inline-block;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.back-link:hover { color: var(--text-primary); }

.detail-fields {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1rem;
}

.detail-fields dt {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.detail-fields dd {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}

form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

input, select, textarea, button {
  background: #0f172a;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 1rem;
}

button {
  background: var(--accent);
  color: #0f172a;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.status {
  min-height: 1.2em;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.status.ok { color: #4ade80; }
.status.error { color: #f87171; }

.hidden { display: none; }

ul { padding-left: 1.2rem; }

@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 10;
    width: var(--sidebar-width-collapsed);
  }
  .sidebar.collapsed { width: 0; border: none; overflow: hidden; }
  .content-area { margin-left: var(--sidebar-width-collapsed); }
  .sidebar:not(.collapsed) ~ .content-area { margin-left: var(--sidebar-width); }
}
