/* App shell: sidebar + topbar + content, responsive */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 100%;
  min-height: 100vh;
}

.nav-scrim {
  display: none;
}

.sidebar {
  background: linear-gradient(180deg, var(--color-surface) 0%, var(--color-bg) 100%);
  border-right: 1px solid rgba(212, 175, 55, 0.15);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 20;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-5);
}

.sidebar__brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.sidebar__brand-mark svg {
  width: 100%;
  height: 100%;
}

.sidebar__brand-text strong {
  display: block;
  font-size: var(--text-base);
}

.sidebar__brand-text span {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.nav-link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

.nav-link.is-active {
  background: rgba(57, 255, 136, 0.08);
  color: var(--color-text);
  border-left-color: var(--color-accent);
  box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.15);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

#boton-notificaciones {
  position: relative;
}

.topbar__avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: var(--color-surface-alt) center / cover no-repeat;
  color: var(--color-accent-gold-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  flex: none;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.topbar__avatar:hover {
  box-shadow: var(--shadow-gold);
  border-color: var(--color-accent-gold);
}

button.nav-toggle {
  display: none;
}

.content {
  padding: var(--space-5);
  flex: 1;
  min-width: 0;
}

.content__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.content__header p {
  color: var(--color-text-muted);
  margin-top: var(--space-1);
  max-width: 62ch;
}

.grid {
  display: grid;
  gap: var(--space-4);
}

.grid--kpi {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.grid--2col {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(80vw, 280px);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  .app-shell.is-nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 15;
  }

  .app-shell.is-nav-open .nav-scrim {
    display: block;
  }

  button.nav-toggle {
    display: inline-flex;
  }

  .content {
    padding: var(--space-4);
  }
}
