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

body.is-authed {
  background: var(--surface);
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  background:
    radial-gradient(ellipse 120% 60% at 20% -10%, color-mix(in srgb, var(--accent) 32%, transparent), transparent 55%),
    var(--sidebar-bg);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 22px 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand__mark {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(145deg, var(--accent), var(--accent-hover));
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out);
}

.brand__mark:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--accent) 45%, transparent);
}

.brand__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: var(--white);
  padding: 4px;
}

.brand__logo.is-hidden,
.brand__icon.is-hidden {
  display: none !important;
}

.brand__mark.has-logo {
  background: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.brand__text {
  min-width: 0;
  width: 100%;
}

.brand__mark--sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.topbar__brand .brand__mark {
  background: var(--accent);
}

.topbar__brand .brand__mark.has-logo {
  background: var(--white);
  border: 1px solid var(--gray-200);
}

.brand__name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.brand__sub {
  font-size: 0.68rem;
  color: rgba(226, 232, 240, 0.55);
  margin-top: 4px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
}

.nav {
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  gap: 4px;
  flex: 1;
  overflow: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-fg, rgba(226, 232, 240, 0.82));
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.88rem;
  min-height: 44px;
  position: relative;
  cursor: pointer;
  transition:
    background 0.2s var(--ease-out),
    color 0.2s var(--ease-out),
    transform 0.18s var(--ease-out),
    box-shadow 0.2s var(--ease-out);
}

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.85;
  transition: transform 0.2s var(--ease-out), opacity 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
}

.nav-item:hover svg {
  opacity: 1;
  transform: scale(1.06);
}

.nav-item:active {
  transform: scale(0.98);
}

/* Activo: pill interno (no “pestaña” hacia el contenido) */
.sidebar .nav-item.is-active {
  background: color-mix(in srgb, var(--accent) 24%, rgba(255, 255, 255, 0.06));
  color: #fff;
  font-weight: 700;
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent),
    0 6px 18px color-mix(in srgb, var(--accent) 18%, transparent);
  z-index: 2;
}

.sidebar .nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent);
}

.sidebar .nav-item.is-active::after {
  content: none;
}

.sidebar .nav-item.is-active svg {
  opacity: 1;
  color: #fff;
}

.sidebar .nav-item.is-active:hover {
  background: color-mix(in srgb, var(--accent) 30%, rgba(255, 255, 255, 0.08));
  color: #fff;
}

.nav-item__badge {
  margin-left: auto;
  background: var(--amber-600);
  color: var(--white);
  font-size: 0.7rem;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 0 6px;
  transition: transform 0.2s var(--ease-spring);
}

.nav-item:hover .nav-item__badge {
  transform: scale(1.08);
}

#badge-pedidos,
#badge-pedidos-m {
  background: var(--red-600);
}

.sidebar .nav-item.is-active .nav-item__badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sidebar .nav-item.is-active #badge-pedidos,
.sidebar .nav-item.is-active #badge-pedidos-m {
  background: var(--red-600);
  color: var(--white);
}

/* Contenido a ras con el menú: misma altura, sin “isla” flotante */
.main {
  margin: 0 0 0 var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  background: var(--surface);
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  animation: none;
}

.topbar {
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface-elevated) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--gray-200) 75%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 20;
  gap: 10px;
  flex-shrink: 0;
}

.topbar__brand {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.topbar__brand-text {
  min-width: 0;
}

.topbar__brand .brand__name {
  color: var(--gray-900);
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__brand .brand__mark {
  background: var(--accent);
}

.topbar__brand .brand__mark.has-logo {
  background: var(--white);
  border: 1px solid var(--gray-200);
}

.topbar__page {
  min-width: 0;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn--notif {
  position: relative;
  padding: 6px 8px;
  min-width: 40px;
}

.btn--notif .nav-item__badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  font-size: 0.62rem;
  margin: 0;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  background: var(--gray-100);
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

.lang-switch--login {
  position: absolute;
  top: 12px;
  right: 12px;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: var(--gray-600);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 5px 8px;
  border-radius: 6px;
  min-height: 30px;
  cursor: pointer;
}

.lang-btn:hover {
  background: var(--accent-soft);
  color: var(--gray-900);
}

.lang-btn.is-active {
  background: var(--white);
  color: var(--accent-hover);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.lang-flag {
  width: 18px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
  display: inline-block;
}

.lang-flag--es {
  background: linear-gradient(
    to bottom,
    #c60b1e 0 25%,
    #ffc400 25% 75%,
    #c60b1e 75% 100%
  );
}

.lang-flag--fr {
  background: linear-gradient(
    to right,
    #0055a4 0 33.33%,
    #fff 33.33% 66.66%,
    #ef4135 66.66% 100%
  );
}

.btn--logout-m {
  display: none !important;
  gap: 4px;
  color: var(--gray-700);
  padding: 6px 10px;
  min-height: 34px;
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 750;
  color: var(--gray-900);
  letter-spacing: -0.03em;
}

.topbar__date {
  font-size: 0.78rem;
  color: var(--gray-500);
  font-weight: 500;
}

.content {
  padding: 12px 16px 20px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar__foot {
  padding: 10px 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar__foot .nav-item {
  border-radius: 12px;
  color: rgba(248, 113, 113, 0.92);
}

.sidebar__foot .nav-item:hover {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
}

.sidebar__foot .nav-item.is-active::before,
.sidebar__foot .nav-item.is-active::after {
  content: none;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
  animation: ledger-view-in 0.34s var(--ease-out);
}

@keyframes ledger-view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.bottom-nav {
  display: none;
}

.fab {
  display: none;
}

@media (max-width: 768px) {
  html,
  body {
    overflow-x: hidden;
  }

  body.is-authed {
    background: var(--surface);
    overflow: hidden;
    height: 100dvh;
  }

  .btn--logout-m {
    display: inline-flex !important;
    padding: 6px 8px;
    min-width: 40px;
    min-height: 40px;
  }

  .btn--logout-m span {
    display: none;
  }

  .topbar__brand .brand__mark {
    width: 34px;
    height: 34px;
  }

  .topbar__brand .brand__name {
    font-size: 0.85rem;
  }

  .topbar__date {
    font-size: 0.72rem;
  }
}
