/* Portal — shell, navegação e ritmo visual unificado */

.page-panel {
  --portal-content-max: none;
  --portal-gutter: clamp(0.85rem, 2vw, 1.5rem);
  --sidebar-width: 260px;
}

.app-view {
  width: 100%;
}

.app-view-skeleton {
  padding: 1.15rem var(--portal-gutter) 1.35rem;
  max-width: none;
  margin: 0 auto;
  box-sizing: border-box;
}

.app-view-skeleton__bar {
  height: 4.5rem;
  margin-bottom: 1rem;
  border-radius: 0.75rem;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.08) 0%,
    rgba(148, 163, 184, 0.16) 50%,
    rgba(148, 163, 184, 0.08) 100%
  );
  background-size: 200% 100%;
  animation: app-view-skeleton-shimmer 1.2s ease-in-out infinite;
}

.app-view-skeleton__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
}

.app-view-skeleton__tile {
  min-height: 6.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.06) 0%,
    rgba(148, 163, 184, 0.12) 50%,
    rgba(148, 163, 184, 0.06) 100%
  );
  background-size: 200% 100%;
  animation: app-view-skeleton-shimmer 1.2s ease-in-out infinite;
}

.app-view-skeleton__tile:nth-child(2) {
  animation-delay: 0.12s;
}

.app-view-skeleton__tile:nth-child(3) {
  animation-delay: 0.24s;
}

.app-view-skeleton__tile:nth-child(4) {
  animation-delay: 0.36s;
}

@keyframes app-view-skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@media (max-width: 960px) {
  .app-view-skeleton__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-view-skeleton__grid {
    grid-template-columns: 1fr;
  }
}

.app-view > .page-header,
.app-view > .portal-dashboard-hero,
.app-view > .support-header,
.app-view > .support-desk-page,
.app-view > .main-content {
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  box-sizing: border-box;
}

.app-view > .page-header,
.app-view > .portal-dashboard-hero {
  padding: 1.1rem var(--portal-gutter) 0.9rem;
}

.page-panel .main-content,
.page-records.page-panel .main-content,
.page-dashboard.page-panel .main-content,
.page-store.page-panel .main-content {
  padding: 1.15rem var(--portal-gutter) 1.35rem;
}

.page-panel.page-support .app-view {
  min-height: 0;
  overflow: hidden;
}

.page-panel.page-support .main-content.support-desk-page {
  padding: 0;
}

.page-header--split,
.page-header.page-header--infra,
.page-header.page-header--sites-monitor {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header--split .page-header__head,
.page-header.page-header--infra .page-header__head,
.page-header.page-header--sites-monitor .page-header__head {
  flex: 1 1 16rem;
  min-width: 0;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Sidebar — seções */
.sidebar__section {
  margin: 0.85rem 0 0.35rem;
  padding: 0 0.85rem;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.72);
}

.sidebar__section:first-child {
  margin-top: 0.15rem;
}

.sidebar__link--monitor {
  padding-left: 0.85rem;
}

.sidebar__link--monitor .sidebar__icon {
  opacity: 0.78;
}

/* Topbar mobile */
.portal-topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem var(--portal-gutter);
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  background: var(--surface-topbar);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 120;
}

.portal-topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: var(--surface-card);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
}

.portal-topbar__menu:hover {
  border-color: rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.1);
}

.portal-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.portal-topbar__logo {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 800;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: #fff;
  flex-shrink: 0;
}

.portal-topbar__title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 190;
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

/* Footer único no shell */
.portal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: auto;
  padding: 0.85rem var(--portal-gutter);
  max-width: none;
  width: 100%;
  text-align: left;
}

.portal-footer .records-app-footer-total:not(:empty) {
  display: inline;
}

.portal-footer__hint {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
}

.portal-footer__hint.hidden {
  display: none;
}

/* Dashboard — insights com 2 colunas */
.dashboard-insights {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.portal-footer .records-app-footer-total:empty {
  display: none;
}

@media (max-width: 960px) {
  .page-panel {
    --sidebar-width: 0;
  }

  .app-main {
    margin-left: 0;
  }

  .portal-topbar {
    display: flex;
  }

  .sidebar {
    width: min(288px, 88vw);
    padding: 1rem 0.75rem;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.28);
  }

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

  body.portal-nav-open .portal-backdrop {
    display: block;
  }

  .sidebar__identity,
  .sidebar__label,
  .sidebar__section {
    display: block;
  }

  .sidebar__brand {
    justify-content: flex-start;
    padding-left: 0.65rem;
    padding-right: 0.65rem;
    flex-shrink: 0;
  }

  .sidebar__nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar__link,
  .sidebar__group-toggle {
    justify-content: flex-start;
    padding: 0.65rem 0.75rem;
  }

  .sidebar__footer {
    flex-shrink: 0;
  }

  .sidebar-user__email {
    display: block;
  }
}

@media (max-width: 720px) {
  .dashboard-insights {
    grid-template-columns: 1fr;
  }

  .dashboard-audit-grid {
    grid-template-columns: 1fr;
  }

  .page-records .records-stats {
    grid-template-columns: 1fr;
  }

  .records-panel {
    overflow: visible;
  }

  .records-panel__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .records-panel__head {
    flex-wrap: wrap;
    width: 100%;
  }

  .records-panel__controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .records-panel__controls .field--compact {
    width: 100%;
  }

  .records-panel__controls .field--compact select {
    width: 100%;
    min-width: 0;
  }

  .records-table-wrap {
    overflow-x: visible;
  }

  .records-table {
    table-layout: auto;
  }

  .records-table thead {
    display: none;
  }

  .records-table tbody tr {
    display: block;
    padding: 0.75rem 0.85rem;
    margin-bottom: 0.55rem;
    border-radius: 12px;
    background: var(--surface-inset);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: none !important;
  }

  .records-table tbody tr.records-table__row--fail {
    border-color: rgba(239, 68, 68, 0.28);
    background: rgba(239, 68, 68, 0.06);
  }

  .records-table td {
    display: grid !important;
    grid-template-columns: minmax(5.25rem, 36%) minmax(0, 1fr);
    gap: 0.35rem 0.65rem;
    align-items: start;
    width: 100%;
    height: auto;
    padding: 0.32rem 0;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    box-shadow: none !important;
  }

  .records-table td::before {
    content: attr(data-label);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .records-table td.records-table__time {
    display: block !important;
    grid-column: unset;
    padding-bottom: 0.45rem;
    margin-bottom: 0.35rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 0.84rem;
    font-weight: 600;
  }

  .records-table td.records-table__time::before {
    display: none;
  }

  .records-table td.records-table__action {
    font-weight: 700;
    text-transform: uppercase;
  }

  .records-panel__footer {
    flex-wrap: wrap;
    gap: 0.65rem;
  }
}
