.es-app {
  display: grid;
  grid-template-columns: var(--es-sidebar-current) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.es-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--es-navy);
  color: #e8eef5;
  overflow-x: hidden;
  overflow-y: hidden;
  z-index: 40;
}

.es-sidebar > * {
  min-width: 0;
  max-width: 100%;
}

.es-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.15rem 1rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.es-brand-collapse {
  display: none;
  margin-left: auto;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  place-items: center;
  padding: 0;
  transition: background 0.15s ease;
}

.es-brand-collapse:hover {
  background: rgba(255, 255, 255, 0.12);
}

.es-app[data-sidebar="collapsed"] .es-brand-collapse svg {
  transform: rotate(180deg);
}

.es-brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.es-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.es-brand-text strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.es-brand-solar {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--es-solar);
}

.es-selectors {
  padding: 0.85rem 1rem 0;
  display: grid;
  gap: 0.45rem;
}

.es-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  height: 36px;
  padding: 0 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.es-selector:hover {
  background: rgba(255, 255, 255, 0.11);
}

.es-selector-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--es-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35);
  flex-shrink: 0;
}

.es-selector-flag {
  font-size: 0.95rem;
  line-height: 1;
}

.es-selector-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-selector-chev {
  flex-shrink: 0;
  opacity: 0.65;
}

.es-selector--lang {
  height: 32px;
}

.es-app[data-sidebar="collapsed"] .es-brand-text,
.es-app[data-sidebar="collapsed"] .es-nav-label,
.es-app[data-sidebar="collapsed"] .es-nav-badge,
.es-app[data-sidebar="collapsed"] .es-quick-title,
.es-app[data-sidebar="collapsed"] .es-quick-btn span,
.es-app[data-sidebar="collapsed"] .es-user-meta,
.es-app[data-sidebar="collapsed"] .es-selectors,
.es-app[data-sidebar="collapsed"] .es-selector-label,
.es-app[data-sidebar="collapsed"] .es-selector-chev,
.es-app[data-sidebar="collapsed"] .es-selector-flag {
  display: none;
}

.es-nav {
  flex: 1;
  overflow: auto;
  padding: 0.5rem 0.65rem;
  display: grid;
  gap: 2px;
  align-content: start;
}

.es-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  min-height: 44px;
  padding: 0.45rem 0.75rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.es-nav-item:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.08);
}

.es-nav-item.is-active {
  background: var(--es-solar);
  color: var(--es-navy);
  font-weight: 700;
}

.es-nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.es-nav-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.es-nav-item[data-es-nav="conversas"]:not(.is-active) .es-nav-icon {
  color: #25d366;
}

.es-nav-label {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-nav-badge {
  min-width: 1.25rem;
  padding: 0 0.35rem;
  height: 1.2rem;
  border-radius: 999px;
  background: var(--es-solar);
  color: var(--es-navy);
  font-size: 0.65rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.es-nav-item.is-active .es-nav-badge {
  background: rgba(11, 42, 91, 0.12);
}

.es-quick {
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
}

.es-quick-title {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 0.4rem;
}

.es-quick-btn {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.es-quick-btn:hover {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(255, 255, 255, 0.05);
}

.es-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
  flex-shrink: 0;
  min-width: 0;
}

.es-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--es-primary), var(--es-navy));
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.es-user-meta {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.es-user-meta strong {
  display: block;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-user-meta span {
  display: block;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-logout-btn {
  flex-shrink: 0;
  margin-left: auto;
  padding: 0.35rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
}

.es-logout-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.es-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--es-bg);
  overflow: visible;
}

/* Header — gradiente igual ao mock (navy → blue → solar) */
.es-header {
  position: relative;
  z-index: 40;
  flex-shrink: 0;
  min-height: 4.5rem;
  padding: 1rem 1.75rem 1.15rem;
  color: #fff;
  background: linear-gradient(
    90deg,
    var(--es-navy) 0%,
    #163d73 18%,
    var(--es-primary) 48%,
    #3b7dd9 72%,
    #6b9ee8 88%,
    rgba(251, 191, 36, 0.72) 100%
  );
  /* visible: dropdown do perfil/notificações não pode ser cortado */
  overflow: visible;
}

.es-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 55% 120% at 92% -10%, rgba(251, 191, 36, 0.45), transparent 58%);
  pointer-events: none;
}

.es-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06) 0%, transparent 40%);
  pointer-events: none;
}

.es-header-inner {
  position: relative;
  z-index: 2;
  display: flex;
  overflow: visible;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 3.25rem;
}

.es-header-inner--toolbar {
  width: 100%;
}

.es-header-inner--toolbar .es-header-toolbar {
  width: 100%;
}

.es-header-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.es-header-menu-btn,
.es-header-mobile-title {
  display: none;
}

.es-header-menu-btn {
  width: 2.75rem;
  height: 2.75rem;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  padding: 0;
  place-items: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.es-header-menu-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.34);
}

.es-header-menu-btn:active {
  transform: scale(0.96);
}

.es-header-mobile-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.es-header-search {
  position: relative;
  flex: 1 1 auto;
  max-width: none;
  min-width: 10rem;
}

.es-header-search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}

.es-header-search input {
  width: 100%;
  height: 2.75rem;
  padding: 0 1.15rem 0 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.875rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transition: border-color 0.15s, background 0.15s;
}

.es-header-search input::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.es-header-search input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.16);
}

.es-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.es-icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background 0.15s ease;
}

.es-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.es-icon-btn--sun svg {
  stroke-width: 2.25;
}

.es-notify-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: var(--es-solar);
  color: var(--es-navy);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.05rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(11, 42, 91, 0.25);
}

.es-profile-wrap {
  position: relative;
  z-index: 60;
  margin-left: 0.1rem;
}

.es-profile-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  height: 2.85rem;
  padding: 0 0.7rem 0 0.28rem;
  border: 1.5px solid rgba(11, 42, 91, 0.55);
  border-radius: 999px;
  background: rgba(8, 24, 48, 0.28);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.es-profile-chip:hover,
.es-profile-chip[aria-expanded="true"] {
  background: rgba(8, 24, 48, 0.42);
  border-color: rgba(11, 42, 91, 0.72);
}

.es-profile-avatar {
  width: 2.05rem;
  height: 2.05rem;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: rgba(11, 42, 91, 0.65);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.es-profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.es-profile-avatar-img[hidden] {
  display: none !important;
}

.es-profile-avatar-initials {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff;
}

.es-profile-menu {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 0;
  min-width: 12.5rem;
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--es-border);
  background: var(--es-surface);
  color: var(--es-text);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
  z-index: 200;
  pointer-events: auto;
}

.es-profile-menu[hidden] {
  display: none !important;
}

.es-profile-menu-meta {
  margin: 0;
  padding: 0.45rem 0.65rem 0.55rem;
  font-size: 0.75rem;
  color: var(--es-text-muted);
  line-height: 1.35;
  border-bottom: 1px solid var(--es-border);
}

.es-profile-menu-item {
  display: block;
  width: 100%;
  margin: 0.2rem 0 0;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--es-text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.es-profile-menu-item:hover {
  background: #f1f5f9;
}

.es-profile-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
  text-align: left;
}

.es-profile-text strong {
  font-size: 0.8rem;
  font-weight: 600;
}

.es-profile-text > span {
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.72);
}

.es-profile-chev {
  flex-shrink: 0;
  opacity: 0.75;
  margin-left: 0.1rem;
}

.es-nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(11, 42, 91, 0.45);
  backdrop-filter: blur(2px);
  cursor: pointer;
  animation: es-scrim-in 0.2s ease;
}

.es-nav-scrim[hidden] {
  display: none !important;
}

@keyframes es-scrim-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.es-mobile-nav-open {
  overflow: hidden;
  touch-action: none;
}

/* Área branca com cantos superiores arredondados (como no mock) */
.es-page-heading {
  margin: 0 0 1.15rem;
}

.es-page-heading h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--es-text);
}

.es-page-heading p {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--es-text-muted);
  line-height: 1.35;
}

body[data-es-panel-active="conversas"] .es-page-heading {
  display: none;
}

.es-content {
  flex: 1;
  margin-top: -0.65rem;
  padding: 1.35rem 1.75rem 2rem;
  background: var(--es-surface);
  border-radius: 1.35rem 1.35rem 0 0;
  box-shadow: 0 -4px 24px rgba(11, 42, 91, 0.06);
  position: relative;
  z-index: 1;
}

.es-date-bar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 1.15rem;
  padding-top: 0.15rem;
}

.es-date-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--es-border);
  border-radius: 10px;
  background: var(--es-surface);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--es-text);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.es-date-btn svg {
  color: var(--es-primary);
  flex-shrink: 0;
}

.es-date-btn:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.es-panel[hidden] {
  display: none !important;
}

.es-placeholder {
  padding: 3rem 1.5rem;
  text-align: center;
  background: var(--es-surface);
  border: 1px dashed var(--es-border);
  border-radius: var(--es-radius-lg);
  color: var(--es-text-muted);
}

@media (max-width: 960px) {
  .es-app {
    grid-template-columns: 1fr;
  }

  .es-brand-collapse {
    display: none;
  }

  /* Header abaixo do drawer — antes ambos tinham z-index 40 e o header ganhava pelo DOM */
  .es-header {
    z-index: 10;
    padding-top: max(0.75rem, env(safe-area-inset-top));
  }

  .es-header-actions {
    z-index: 11;
  }

  .es-profile-wrap {
    z-index: 12;
  }

  .es-nav-scrim {
    z-index: 90;
  }

  .es-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--es-sidebar-width), 88vw);
    max-width: 300px;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    z-index: 100;
    box-shadow: none;
  }

  .es-app[data-mobile-nav="open"] .es-sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.22);
  }

  .es-app[data-mobile-nav="open"] .es-main .es-header {
    pointer-events: none;
  }

  .es-header {
    min-height: auto;
    padding: 0.75rem 1rem 0.85rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .es-header-inner--toolbar {
    align-items: stretch;
  }

  .es-header-toolbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    gap: 0.65rem 0.75rem;
    align-items: center;
    width: 100%;
  }

  .es-header-menu-btn,
  .es-header-mobile-title {
    display: block;
  }

  .es-header-menu-btn {
    display: grid;
    grid-column: 1;
    grid-row: 1;
  }

  .es-header-mobile-title {
    grid-column: 2;
    grid-row: 1;
  }

  .es-header-actions {
    grid-column: 3;
    grid-row: 1;
    width: auto;
    justify-content: flex-end;
    gap: 0.4rem;
  }

  .es-header-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    width: 100%;
  }

  .es-header-search input {
    font-size: 16px;
    height: 2.5rem;
  }

  .es-profile-text {
    display: none;
  }

  .es-profile-chev {
    display: none;
  }

  .es-profile-chip {
    height: 2.5rem;
    padding: 0 0.35rem 0 0.22rem;
  }

  .es-icon-btn {
    width: 2.5rem;
    height: 2.5rem;
  }

  .es-content {
    padding: 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    border-radius: 1rem 1rem 0 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Título já aparece no header gradiente */
  .es-page-heading h1 {
    display: none;
  }

  .es-page-heading {
    margin-bottom: 0.5rem;
  }

  .es-page-heading p {
    font-size: 0.8125rem;
  }
}

@media (min-width: 961px) {
  .es-nav-scrim {
    display: none !important;
  }

  .es-brand-collapse {
    display: grid;
  }
}

@media (max-width: 640px) {
  .es-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Oculta ícones secundários — mantém notificações e perfil na mesma linha do menu */
  .es-header-actions .es-icon-btn:not(#esNotifyBtn) {
    display: none;
  }
}
