.app-navbar {
  width: 100%;
  max-width: none;
  margin: 0;
  background: var(--surface-0);
  border: none;
  border-bottom: 1px solid var(--border-default);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.app-navbar.is-sticky {
  position: sticky;
  top: 0;
  z-index: 120;
}

.navbar-inner {
  max-width: var(--max-w-shell);
  margin: 0 auto;
  padding: 0 var(--space-4);
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
}

.navbar-brand-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.navbar-brand {
  text-decoration: none;
  color: #60a5fa;
  font-family: var(--font-display);
  font-weight: 1000;
  font-size: var(--text-md);
  letter-spacing: 0.02em;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-lg);
  padding: var(--space-1) 6px;
}

.navbar-user:hover {
  background: rgba(255, 255, 255, 0.05);
}

.navbar-user:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.navbar-avatar-image,
.navbar-avatar-fallback {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  flex: 0 0 auto;
}

.navbar-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-bold);
}

.navbar-user-meta {
  display: grid;
  min-width: 0;
}

.navbar-user-meta strong,
.navbar-user-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navbar-user-meta strong {
  font-size: var(--text-sm);
}

.navbar-user-meta span {
  font-size: var(--text-xs);
  color: var(--shell-muted);
}

.navbar-user-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navbar-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
}

.navbar-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

.navbar-icon-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.navbar-badge {
  position: absolute;
  top: 1px;
  right: 1px;
  min-width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  pointer-events: none;
}

.navbar-guest-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: auto;
  white-space: nowrap;
  min-height: 40px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  text-decoration: none;
  padding: 0 var(--space-4);
  transition:
    background var(--duration-base) var(--ease-default),
    border-color var(--duration-base) var(--ease-default),
    transform var(--duration-base) var(--ease-default);
}

.navbar-guest-cta:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
  transform: translateY(-1px);
}

.navbar-guest-cta:active {
  transform: translateY(0);
}

.navbar-guest-cta:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

.shell {
  --sidebar-width-expanded: 270px;
  width: 100%;
  max-width: var(--max-w-shell);
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: var(--sidebar-width-expanded) minmax(0, 1fr);
  align-items: start;
  gap: 0;
}

.sidebar {
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-subtle);
  border-radius: 0;
  padding: var(--space-4);
  position: sticky;
  top: 0;
  align-self: start;
  box-shadow: none;
  backdrop-filter: none;
}

.sidebar-section {
  margin-top: 0;
}

.sidebar-section + .sidebar-section {
  margin-top: var(--space-4);
}

.sidebar-section-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--shell-muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: #cbd5e1;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: var(--text-base);
  margin-bottom: 5px;
  transition:
    color var(--duration-base),
    background var(--duration-base),
    border-color var(--duration-base);
}

.sidebar nav .sidebar-link:last-child {
  margin-bottom: 0;
}

.sidebar-link-profile {
  width: 100%;
}

.sidebar-link-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link-label {
  min-width: 0;
}

.sidebar-link-dot {
  margin-left: auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
  background: #fbbf24;
}

.sidebar-profile-avatar-wrap {
  display: inline-flex;
  flex: 0 0 auto;
}

.sidebar-profile-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-default);
  object-fit: cover;
  flex: 0 0 auto;
}

.sidebar-profile-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
}

.sidebar-link:hover {
  background: var(--sidebar-active-bg);
  border-color: var(--border-default);
  color: var(--shell-ink);
}

.sidebar-link.is-active {
  border-color: rgba(59, 158, 255, 0.4);
  background: rgba(59, 158, 255, 0.15);
  color: var(--brand);
  font-weight: var(--font-weight-semibold);
}

.content {
  display: grid;
  align-content: start;
  gap: var(--space-4);
  grid-template-columns: minmax(0, 1fr);
  padding: var(--space-4) var(--space-4);
}

/* Mobile hamburger: hidden by default (desktop) */
.navbar-mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-height: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--shell-muted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.navbar-mobile-menu-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.navbar-mobile-menu-btn:hover {
  background: var(--brand-soft);
  border-color: rgba(59, 158, 255, 0.3);
  color: var(--brand);
}

/* Sidebar mobile overlay backdrop */
.sidebar-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1099;
  cursor: pointer;
}

.sidebar-mobile-overlay.is-visible {
  display: block;
}

/* Bottom tab bar — hidden on desktop/tablet, shown on mobile */
.bottom-nav {
  display: none;
}

@media (min-width: 641px) and (max-width: 1080px) {
  .navbar-inner {
    grid-template-columns: 1fr;
  }

  .navbar-guest-cta {
    width: fit-content;
    min-height: 40px;
    justify-self: start;
  }

  .navbar-user {
    display: none;
  }

  /* Shell: bloque simple, el sidebar ya no ocupa columna */
  .shell {
    display: block;
  }

  /* Hamburger visible en tablet */
  .navbar-mobile-menu-btn {
    display: inline-flex;
  }

  /* Sidebar: drawer off-screen por defecto */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 280px;
    border-radius: 0;
    border-right: 1px solid var(--border-default);
    background: var(--surface-1);
    transform: translateX(-100%);
    z-index: 1100;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  /* Transición habilitada solo después del primer paint (evita flash al cargar) */
  .sidebar.sidebar-ready {
    transition:
      transform var(--duration-slow) var(--ease-default),
      box-shadow var(--duration-slow) var(--ease-default);
  }

  /* Drawer abierto */
  .sidebar.is-mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 22px;
  }

}

@media (max-width: 640px) {
  /* Navbar simplificado — solo logo. El grid de 3 cols colapsa a 1 sola
     fila visible; eliminamos el gap para que los items ocultos no inflen
     la altura con espacio reservado entre rows. */
  .navbar-inner {
    grid-template-columns: 1fr;
    padding: var(--space-2) var(--space-3);
    gap: 0;
  }

  .navbar-breadcrumbs-slot,
  .navbar-user-cluster {
    display: none;
  }

  .navbar-user {
    display: none;
  }

  .navbar-mobile-menu-btn {
    display: none;
  }

  .navbar-guest-cta {
    width: 100%;
    min-height: 44px;
    justify-self: stretch;
  }

  /* Shell: bloque simple */
  .shell {
    display: block;
    /* Espacio extra para el bottom nav */
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }

  /* Sidebar y overlay ocultos — bottom nav toma el control */
  .sidebar,
  .sidebar-mobile-overlay {
    display: none !important;
  }

  /* Bottom tab bar */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--surface-1);
    border-top: 1px solid var(--border-default);
    backdrop-filter: none;
    z-index: 1100;
    justify-content: space-around;
    align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    text-decoration: none;
    color: var(--shell-muted);
    padding: var(--space-2) 0;
    border-radius: 0;
    transition: color var(--duration-base);
    min-height: 44px;
  }

  .bottom-nav-item.is-active {
    color: var(--brand);
  }

  .bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .bottom-nav-label {
    font-size: var(--text-xs);
    font-weight: var(--font-weight-medium);
    line-height: 1;
  }
}
