.app {
  display: flex;
  height: 100vh;
  min-height: 760px;
  background: var(--bg);
  color: var(--text);
}
.app__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* o host da barra lateral não participa do layout (a barra é filha direta do .app) */
.sidebar-host {
  display: contents;
}
.mobilebar,
.nav-backdrop {
  display: none;
}

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
}
.brand__mark {
  width: 34px;
  height: 34px;
  border: 1px solid var(--dim);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 16px;
  color: var(--acc);
  background: var(--card);
}
.brand__mark {
  overflow: hidden;
  flex: none;
}
.brand__logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* marca TechTie: sem moldura de quadrado, a arte já é o ícone */
.brand__mark:has(.brand__logo--mark) {
  border-color: transparent;
  background: none;
  width: 38px;
  height: 38px;
}
.brand__logo--mark {
  padding: 2px;
}
.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
  min-width: 0;
}
.brand__name,
.brand__sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand__name {
  font-weight: 600;
  letter-spacing: 0.22em;
  font-size: 17px;
  color: var(--acc);
  text-transform: uppercase;
}
.brand__sub {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--mute);
}
.sidebar__group {
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--mute);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius-pill);
  padding: 10px 14px;
  font-size: 14px;
  background: none;
  color: var(--mute);
  text-align: left;
  text-decoration: none;
}
.nav-item:hover {
  color: var(--acc);
}
.nav-item.is-active {
  background: var(--line);
  color: var(--acc2);
  font-weight: 600;
}
.nav-item__label {
  flex: 1;
}
.sidebar__spacer {
  flex: 1;
}
.sidebar__btn {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--acc);
  border-radius: var(--radius-input);
  padding: 9px 12px;
  font-size: 12.5px;
  text-align: left;
}
.sidebar__btn--dashed {
  background: none;
  border-style: dashed;
  color: var(--mute);
}
.sidebar__btn--dashed:hover {
  color: var(--acc);
  border-color: var(--dim);
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 8px 0;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.sidebar__user .avatar {
  width: 34px;
  height: 34px;
  background: var(--dim);
  color: var(--ink);
  font-weight: 700;
  border: 0;
}
.sidebar__user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.sidebar__user-text small {
  font-size: 12px;
  color: var(--mute);
}

.sidebar__group--spaced {
  margin-top: 10px;
}
.sidebar__viewas {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--mute);
  margin-top: 4px;
}
.sidebar__select {
  padding: 7px 10px;
  font-size: 12.5px;
  background: var(--card);
}

/* ---------- celular ---------- */
@media (max-width: 820px) {
  .app {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    flex-direction: column;
  }
  .mobilebar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
    background: var(--side);
    border-bottom: 1px solid var(--line);
  }
  .mobilebar__btn {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--card);
    color: var(--acc);
  }
  .mobilebar__logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
  }
  .mobilebar__title {
    min-width: 0;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--acc2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* a barra lateral vira um menu que desliza por cima do conteúdo */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(82vw, 300px);
    overflow-y: auto;
    padding-top: calc(env(safe-area-inset-top) + 20px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 16px);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }
  .app.is-nav-open .sidebar {
    transform: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  }
  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .app.is-nav-open .nav-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  /* alvos de toque maiores */
  .nav-item {
    padding: 13px 14px;
  }
  .sidebar__btn {
    padding: 12px;
    font-size: 14px;
  }
  /* 16px nos campos: abaixo disso o iPhone dá zoom ao focar */
  input,
  select,
  textarea {
    font-size: 16px;
  }
  .page {
    padding: 18px 14px;
    gap: 16px;
  }
  .page-header {
    gap: 12px;
  }
  .toast-host {
    bottom: calc(env(safe-area-inset-bottom) + 16px);
  }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .nav-backdrop {
    transition: none;
  }
}
