.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(178, 24, 44, 1), rgba(196, 36, 58, 1)),
    var(--bg);
}

.app-shell {
  min-height: 100vh;
  background: #eeeeef;
  /* Fonte unica da altura do topbar - todo modulo que faz
     calc(100vh - Npx) usa var(--topbar-h) em vez de repetir o numero,
     senao cada breakpoint que muda a altura do topbar quebra as telas
     que ainda descontam o valor antigo (ex.: Venda Mesa). */
  --topbar-h: 68px;
}

/* ── Top bar ────────────────────────────────────────── */

.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 0 26px;
  color: #ffffff;
  background: linear-gradient(135deg, #b2182c, #c4243a);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.22);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-area,
.top-actions,
.session-box,
.form-actions,
.list-header {
  display: flex;
  align-items: center;
}

.brand-area {
  gap: 26px;
  min-width: 0;
}

.top-logo {
  width: 140px;
  height: 50px;
  border: 0;
  box-shadow: none;
  background: transparent;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.top-empresa-nome {
  font-size: 1rem;
  font-weight: bold;
  text-transform: uppercase;
  color: #fff;
  margin-left: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.system-name {
  font-size: 1rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.top-actions {
  gap: 16px;
}

.top-icon-button {
  color: #ffffff;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 700;
  min-width: 36px;
  min-height: 36px;
  padding: 6px;
}

.delivery-bell {
  position: relative;
  font-size: 18px;
  opacity: 0.7;
}

.delivery-bell.bell-enabled {
  opacity: 1;
}

.delivery-bell.bell-ringing .delivery-bell-icon {
  display: inline-block;
  animation: dlvp-bell-shake 0.6s ease-in-out infinite;
}

.delivery-bell-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.delivery-bell-badge.hidden {
  display: none;
}

@keyframes dlvp-bell-shake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(12deg); }
  60% { transform: rotate(-8deg); }
  80% { transform: rotate(5deg); }
}


.hamburger-icon,
.hamburger-icon::before,
.hamburger-icon::after {
  display: block;
  width: 20px;
  height: 3px;
  border-radius: 3px;
  background: #ffffff;
}

.hamburger-icon {
  position: relative;
}

.hamburger-icon::before,
.hamburger-icon::after {
  content: "";
  position: absolute;
  left: 0;
}

.hamburger-icon::before {
  top: -7px;
}

.hamburger-icon::after {
  top: 7px;
}

.session-user {
  max-width: 170px;
  margin: 0;
  overflow: hidden;
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Workspace ──────────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
  margin-top: -2px;
  transition: grid-template-columns 0.18s ease;
}

.app-shell.menu-collapsed .workspace {
  grid-template-columns: 64px minmax(0, 1fr);
}

/* ── Sidebar ────────────────────────────────────────── */

.sidebar {
  height: calc(100vh - 68px);
  overflow-y: auto;
  background: #ffffff;
  border-right: 1px solid #d7d9de;
  box-shadow: 5px 0 14px rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 68px;
  align-self: start;
  z-index: 50;
}

.menu-list {
  display: grid;
  padding: 22px 0 28px;
}

.menu-button {
  width: 100%;
  min-height: 45px;
  display: grid;
  grid-template-columns: 34px 1fr 24px;
  align-items: center;
  gap: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0 14px 0 12px;
  background: transparent;
  color: #565d66;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  transition: background 0.16s ease, color 0.16s ease;
}

.app-shell.menu-collapsed .menu-button {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
}

.app-shell.menu-collapsed .menu-button span:not(.menu-icon) {
  display: none;
}

.menu-button:hover,
.menu-button.active {
  background: #bd1f33;
  color: #ffffff;
}

.menu-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.menu-chevron {
  justify-self: end;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ── Submenu group ──────────────────────────────────── */

.submenu-group {
  display: none;
  flex-direction: column;
  background: #f7f4fa;
  border-left: 3px solid var(--purple);
  margin: 0;
  overflow: hidden;
}

.submenu-group.open {
  display: flex;
}

.submenu-button {
  width: 100%;
  min-height: 38px;
  padding: 0 14px 0 20px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background 0.14s, color 0.14s;
  border-bottom: 1px solid rgba(93,22,116,0.06);
  display: flex;
  align-items: center;
  gap: 8px;
}

.submenu-button:last-child { border-bottom: 0; }

.submenu-button:hover {
  background: rgba(93,22,116,0.07);
  color: var(--purple);
}

.submenu-button.active {
  background: rgba(93,22,116,0.12);
  color: var(--purple);
}

.submenu-icon {
  font-size: 1rem;
  flex-shrink: 0;
  width: 1.4em;
  text-align: center;
  display: inline-block;
}

/* ── Submenu colapsado ──────────────────────────────── */

.app-shell.menu-collapsed .submenu-group.open {
  display: flex;
}

.app-shell.menu-collapsed .submenu-button {
  padding: 0;
  justify-content: center;
  min-height: 42px;
  font-size: 0;
  letter-spacing: 0;
  gap: 0;
}

.app-shell.menu-collapsed .submenu-icon {
  font-size: 1.2rem;
}

/* ── Content area ───────────────────────────────────── */

.content-stack {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 18px;
}

/* Overlay escuro da sidebar — oculto por padrão em todos os tamanhos */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 499;
}

/* Com a gaveta aberta no mobile, trava o conteudo de tras: nao rola nem
   recebe clique/toque, so a propria gaveta e o overlay respondem. O scroll
   real e da <body> (o layout aqui nao usa altura fixa + scroll interno tipo
   pdv_off), entao precisa travar a body mesmo, nao so um wrapper interno. */
body.sidebar-locked {
  overflow: hidden;
  touch-action: none;
}
.app-shell.sidebar-open #module-content {
  overflow: hidden;
  touch-action: none;
  pointer-events: none;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 820px) {
  .app-shell { --topbar-h: 52px; }
  .topbar {
    height: auto;
    min-height: 52px;
    flex-wrap: nowrap;
    padding: 0 12px;
    gap: 10px;
  }

  .brand-area {
    gap: 8px;
  }

  .top-logo {
    width: 90px;
    height: 34px;
  }

  .system-name {
    display: none;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Sidebar desliza como overlay — não empilha */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 270px;
    height: 100vh;
    overflow-y: auto;
    z-index: 500;
    transition: left 0.22s ease;
    box-shadow: none;
  }

  .app-shell.sidebar-open .sidebar {
    left: 0;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.3);
  }

  .app-shell.sidebar-open .sidebar-overlay {
    display: block;
  }

  .menu-list {
    padding: 8px 0;
  }

  .menu-button {
    border-radius: 0;
  }

  .content-stack {
    padding: 8px;
  }

  /* Igual pdv_off: a pagina em si nao rola/balanca (sem bounce do iOS) -
     so a area de conteudo rola por dentro, isolada, com o topbar sempre
     parado. Usa overflow-y (nao "hidden" puro como no pdv_off) porque as
     telas da gestao web foram feitas pra rolar a pagina toda, nao tem
     scroll interno proprio — travar de vez cortaria conteudo. */
  html { height: 100%; }
  /* So trava o body depois do login (app-shell visivel) - a tela de login
     e curta mas nao vale o risco de cortar o botao de entrar se o teclado
     abrir num celular bem pequeno. */
  body:has(.app-shell:not(.hidden)) {
    height: 100%;
    overflow: hidden;
  }
  .content-stack {
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Responsivo: celular (mesmo tratamento do pdv_off PWA) ─────────── */
@media (max-width: 600px) {
  /* iPhone: viewport-fit=cover deixa a pagina ir por baixo do notch/relogio -
     soma o respiro do status bar na altura do topbar (0 em Android/desktop,
     ja que env() so retorna valor no iOS com notch). */
  .topbar {
    height: calc(56px + env(safe-area-inset-top, 0px));
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 8px 0;
    gap: 8px;
  }
  .brand-area { gap: 8px; }
  .top-logo { width: 76px; height: 28px; }
  .top-empresa-nome { display: none; }
  .top-actions { gap: 6px; }
  .session-user { display: none; }
  .top-icon-button { min-width: 32px; min-height: 32px; padding: 4px; }
  .app-shell.sidebar-open .sidebar { width: 84vw; left: 0; }
  .workspace { min-height: calc(100vh - 56px - env(safe-area-inset-top, 0px)); }
  .sidebar {
    height: calc(100vh - 56px - env(safe-area-inset-top, 0px));
    top: calc(56px + env(safe-area-inset-top, 0px));
  }
  /* Sem folga embaixo, o ultimo card/tabela da tela fica colado na barra
     do navegador (some antes de acabar de rolar). */
  .content-stack { padding: 8px 8px calc(48px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 480px) {
  .topbar          { padding: env(safe-area-inset-top, 0px) 8px 0; min-height: calc(48px + env(safe-area-inset-top, 0px)); height: calc(48px + env(safe-area-inset-top, 0px)); }
  .top-logo        { width: 76px; height: 28px; }
  .session-user    { display: none; }
  .top-empresa-nome { display: none; }
  .content-stack   { padding: 4px 4px calc(48px + env(safe-area-inset-bottom, 0px)); }
  .workspace { min-height: calc(100vh - 48px - env(safe-area-inset-top, 0px)); }
  .sidebar {
    height: calc(100vh - 48px - env(safe-area-inset-top, 0px));
    top: calc(48px + env(safe-area-inset-top, 0px));
  }
}
