.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh
}

body.sidebar-open .app-shell {
  grid-template-columns: var(--sidebar) 1fr
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 20px 14px;
  background: linear-gradient(180deg, rgba(7, 24, 51, .98), rgba(5, 17, 35, .97));
  border-right: 1px solid rgba(70, 148, 255, .22);
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  transform: translateX(-100%);
  transition: transform .2s
}

.sidebar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0
}

body.sidebar-open .sidebar {
  transform: translateX(0)
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 24px
}

.brand img {
  height: 44px;
  width: auto;
  object-fit: contain
}

.brand-fallback {
  font-size: 22px;
  font-weight: 850;
  letter-spacing: -.03em
}

.nav-title {
  font-size: 10px;
  color: #6f86a3;
  margin: 12px 9px 8px;
  font-weight: 800;
  letter-spacing: .08em
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px
}

.nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: 10px;
  color: #b5c5d9;
  font-size: 13px
}

.nav a:hover {
  background: rgba(255, 255, 255, .035);
  color: white
}

.nav a.active {
  color: white;
  border: 1px solid rgba(37, 128, 255, .5);
  background: linear-gradient(90deg, rgba(37, 128, 255, .30), rgba(0, 223, 255, .08));
  box-shadow: inset -2px 0 0 #3aa8ff, 0 0 22px rgba(37, 128, 255, .15);
}

.nav a .icon {
  width: 18px;
  height: 18px
}

/* Grupo de navegação colapsável (ex.: Cadastros) */
.nav-group {
  display: flex;
  flex-direction: column
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b5c5d9;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer
}

.nav-group-toggle:hover {
  background: rgba(255, 255, 255, .035);
  color: white
}

.nav-group-toggle .icon {
  width: 18px;
  height: 18px
}

.nav-group-label {
  flex: 1
}

.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 18px;
  padding-left: 16px;
  border-left: 1px solid rgba(70, 148, 255, .18)
}

.nav-group:not(.is-open) .nav-sub {
  display: none
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 4px
}

.nav-sub-item>a:not(.nav-sub-add) {
  flex: 1 1 auto
}

.nav-sub a:not(.nav-sub-add) {
  padding: 9px 12px;
  font-size: 12.5px
}

/* Item de nível superior com ação lateral (ex.: Comunicação + engrenagem SMTP) */
.nav-sub-item--top>a:not(.nav-sub-add) {
  padding: 11px 12px;
  font-size: 13px
}

.nav-sub-item--top .nav-sub-add {
  margin-right: 0
}

.nav .nav-sub-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-right: 12px;
  padding: 0;
  border-radius: 6px;
  background: rgba(70, 148, 255, .14);
  color: #cfe0ff;
  text-decoration: none;
  transition: background .15s, color .15s, transform .15s
}

.nav .nav-sub-add .icon {
  width: 13px;
  height: 13px
}

.nav .nav-sub-add:hover {
  background: rgba(70, 148, 255, .32);
  color: #fff;
  transform: scale(1.08)
}

.nav-sub-item.active {
  border: 1px solid rgba(37, 128, 255, .5);
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(37, 128, 255, .30), rgba(0, 223, 255, .08));
  box-shadow: inset -2px 0 0 #3aa8ff, 0 0 22px rgba(37, 128, 255, .15)
}

.nav-sub-item.active>a:not(.nav-sub-add) {
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #fff
}

.nav .nav-group-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-right: 0;
  padding: 0;
  border-radius: 6px;
  background: rgba(70, 148, 255, .14);
  color: #cfe0ff;
  transition: background .15s, color .15s, transform .18s
}

.nav .nav-group-indicator .icon {
  width: 14px;
  height: 14px;
  transition: transform .18s
}

.nav .nav-group.is-open .nav-group-indicator .icon {
  transform: rotate(90deg)
}

.nav-group-toggle:hover .nav-group-indicator {
  background: rgba(70, 148, 255, .32);
  color: #fff
}

.nav-sub-sep {
  height: 0;
  margin: 7px 0;
  border-top: 1px solid rgba(70, 148, 255, .18)
}

.sidebar-card {
  margin-top: 36px;
  padding: 15px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(30, 107, 255, .12), rgba(124, 58, 237, .12));
  border: 1px solid rgba(124, 58, 237, .35)
}

.sidebar-card h4 {
  font-size: 12px;
  margin: 0 0 7px
}

.sidebar-card p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 13px
}

.sidebar-footer {
  margin-top: 30px;
  padding: 18px 8px;
  color: #657995;
  font-size: 10px;
  border-top: 1px solid rgba(148, 163, 184, .10)
}

.topbar {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: var(--topbar);
  z-index: 25;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 560px) 1fr;
  align-items: center;
  padding: 0 24px;
  background: rgba(3, 11, 24, .74);
  border-bottom: 1px solid rgba(148, 163, 184, .13);
  backdrop-filter: blur(16px);
}

body.sidebar-open .topbar {
  left: var(--sidebar)
}

.topbar-left {
  display: flex;
  align-items: center
}

.topbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 11px
}

/* Seletor de idioma (header) */
.lang-switch {
  position: relative
}

/* Botão do seletor de idioma: largura automática p/ caber ícone + texto */
.lang-switch .btn {
  width: auto;
  padding: 0 12px
}

.lang-current {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .03em
}

.lang-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: linear-gradient(180deg, rgba(14, 31, 54, .96), rgba(8, 20, 38, .96));
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  z-index: 40
}

.lang-menu[hidden] {
  display: none
}

.lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  transition: background .15s ease
}

.lang-item:hover {
  background: rgba(30, 107, 255, .14)
}

.lang-item.is-active {
  background: rgba(30, 107, 255, .18);
  color: #bcd4ff
}

.lang-code {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em
}

.lang-name {
  flex: 1
}

.profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 9px
}

.profile-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  box-shadow: var(--glow-violet)
}

.profile-copy {
  line-height: 1.2;
  min-width: 0
}

.profile-copy strong {
  display: block;
  font-size: 12px;
  white-space: nowrap
}

.profile-copy span {
  color: var(--muted);
  font-size: 10px
}

/* Dropdown do perfil (menu do usuário no header) */
.profile-menu-wrap {
  position: relative
}

.profile-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 4px 8px 4px 4px;
  cursor: pointer;
  color: var(--text);
  transition: background .15s, border-color .15s
}

.profile-trigger:hover,
.profile-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, .04);
  border-color: var(--line)
}

.profile-caret {
  width: 14px;
  height: 14px;
  opacity: .7;
  transition: transform .18s
}

.profile-trigger[aria-expanded="true"] .profile-caret {
  transform: rotate(90deg)
}

.profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  min-width: 244px;
  padding: 8px;
  background: #0c1726;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .45);
  display: flex;
  flex-direction: column;
  gap: 2px
}

.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  text-decoration: none;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer
}

.profile-item .icon {
  width: 17px;
  height: 17px;
  opacity: .8
}

.profile-item:hover {
  background: rgba(0, 223, 255, .10)
}

.profile-item-logout {
  color: #ff9aae
}

.profile-item-logout:hover {
  background: rgba(244, 63, 94, .12)
}

.profile-divider {
  height: 1px;
  background: var(--line);
  margin: 5px 4px
}

.profile-logout {
  margin: 0;
  padding: 0
}

.main {
  grid-column: 1;
  padding: calc(var(--topbar) + 28px) 28px 40px;
  max-width: 1700px;
  width: 100%;
  min-width: 0;
  margin: 0 auto
}

body.sidebar-open .main {
  grid-column: 2
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px
}

.page-head h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -.035em
}

.page-head h1 img.icon {
  width: 30px;
  height: 30px;
  margin-right: 10px;
  vertical-align: -4px
}

.page-head p {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 13px
}

.period-btn {
  min-width: 150px
}

.section {
  margin-top: 18px
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(320px, .75fr) minmax(0, 1.6fr);
  gap: 16px
}

.chart-card,
.table-card {
  border-radius: 18px;
  padding: 18px;
  min-width: 0
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px
}

.mini-stat {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .025);
  border: 1px solid var(--line)
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 10px
}

.mini-stat strong {
  display: block;
  font-size: 20px;
  margin-top: 3px
}

.design-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px
}

.design-card {
  border-radius: 18px;
  padding: 18px
}

.span-3 {
  grid-column: span 3
}

.span-4 {
  grid-column: span 4
}

.span-5 {
  grid-column: span 5
}

.span-6 {
  grid-column: span 6
}

.span-7 {
  grid-column: span 7
}

.span-8 {
  grid-column: span 8
}

.span-9 {
  grid-column: span 9
}

.span-12 {
  grid-column: span 12
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(75px, 1fr));
  gap: 10px
}

.swatch {
  height: 66px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .17);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08)
}

.swatch-label {
  font-size: 10px;
  color: var(--muted);
  margin-top: 7px;
  line-height: 1.35
}

.type-sample h1,
.type-sample h2,
.type-sample h3,
.type-sample p {
  margin: 4px 0
}

.type-sample small {
  color: var(--muted);
  font-size: 10px
}

.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 10px
}

.icon-demo {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  border: 1px solid var(--line)
}

.icon-demo .icon {
  width: 20px;
  height: 20px;
  opacity: .92
}

.spacing-row {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-wrap: wrap
}

.space-block {
  background: linear-gradient(180deg, #2f8cff, #1558ff);
  border-radius: 4px;
  box-shadow: var(--glow-blue)
}

.radius-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap
}

.radius-demo {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(111, 183, 255, .5);
  background: rgba(255, 255, 255, .02)
}

.fx-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px
}

.fx {
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(14, 31, 54, .45);
  display: flex;
  align-items: end;
  padding: 8px;
  font-size: 10px;
  color: var(--muted)
}

.fx.glow {
  box-shadow: 0 0 22px rgba(30, 107, 255, .35)
}

.fx.neon {
  border-color: rgba(0, 223, 255, .62);
  box-shadow: inset 0 0 14px rgba(0, 223, 255, .06), 0 0 16px rgba(0, 223, 255, .12)
}

.fx.soft {
  box-shadow: 0 18px 28px rgba(0, 0, 0, .25)
}

.fx.gradient {
  background: linear-gradient(135deg, #1265ff, #6e33ff 60%, #9b4dff)
}

.mobile-toggle {
  display: inline-flex
}

@media(max-width:1250px) {
  .kpi-grid {
    grid-template-columns: repeat(3, 1fr)
  }

  .analytics-grid {
    grid-template-columns: 1fr
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-9 {
    grid-column: span 6
  }

  .color-grid {
    grid-template-columns: repeat(4, 1fr)
  }
}

@media(max-width:900px) {
  :root {
    --sidebar: 0px
  }

  .app-shell {
    grid-template-columns: 1fr
  }

  .sidebar {
    transform: translateX(-100%);
    transition: .2s;
    width: 250px
  }

  body.sidebar-open .sidebar {
    transform: translateX(0)
  }

  .topbar {
    left: 0;
    grid-template-columns: auto 1fr auto;
    padding: 0 12px;
    gap: 12px
  }

  .mobile-toggle {
    display: inline-flex
  }

  /* Overlay que fecha o menu ao tocar fora dele (mobile) */
  .sidebar-backdrop {
    display: none
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: rgba(2, 8, 18, .55);
    backdrop-filter: blur(2px);
    cursor: pointer
  }

  .profile-copy {
    display: none
  }

  .main {
    grid-column: 1;
    padding-left: 14px;
    padding-right: 14px
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .design-grid {
    display: block
  }

  .design-card {
    margin-bottom: 14px
  }
}

@media(max-width:620px) {
  .kpi-grid {
    grid-template-columns: 1fr
  }

  .main {
    padding-top: calc(var(--topbar) + 20px);
    padding-bottom: 28px
  }

  .page-head {
    flex-direction: column;
    gap: 12px
  }

  .page-head h1 {
    font-size: 26px
  }

  .page-head p {
    font-size: 12px;
    line-height: 1.5
  }

  .page-head .period-btn {
    width: 100%
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px
  }

  .section-title>div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%
  }

  .section-title>div .btn {
    flex: 1
  }

  .chart-card,
  .table-card {
    padding: 14px
  }

  .mini-stats {
    grid-template-columns: 1fr;
    gap: 8px
  }

  .mini-stat {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px
  }

  .mini-stat strong {
    margin-top: 0
  }

  .fields-grid {
    grid-template-columns: 1fr
  }

  .color-grid {
    grid-template-columns: repeat(2, 1fr)
  }

  .topbar-center {
    display: none
  }

  .topbar {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 8px;
    padding: 0 10px
  }

  .topbar-right {
    gap: 6px
  }

  .profile {
    padding-left: 2px
  }
}