/* App shell: a top bar (hamburger + brand) over the page; the menu panel opens under the bar. */
.shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--sidebar-bg);
  border-block-end: 1px solid var(--divider);
}

.menu-panel {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-start: 12px;
  width: 400px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sidebar-bg);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.sidebar {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Popovers open inline inside the (scrolling) panel instead of floating over it. */
.menu-panel .popover {
  position: static;
  width: auto;
  max-width: none;
  margin-block-start: 8px;
}
.menu-panel .header-tools {
  flex-direction: column;
  align-items: stretch;
}
.menu-panel .segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}
.menu-panel .segmented__btn {
  padding-inline: 6px;
  white-space: nowrap;
}
.menu-panel .segmented__btn--custom {
  border-inline-start: 0;
  border-radius: 8px;
}
.menu-panel .segmented--small {
  grid-template-columns: 1fr 1fr;
}

.menu-btn {
  flex: none;
  width: var(--touch-target);
  height: var(--touch-target);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-control);
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.menu-btn:hover,
.menu-btn--open {
  background: var(--track);
  border-color: var(--accent-soft);
}

.main {
  min-width: 0;
  min-height: calc(100vh - 66px);
  padding: 32px 36px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (max-width: 720px) {
  .topbar {
    padding: 8px 12px;
  }
  .menu-panel {
    inset-inline: 8px;
    width: auto;
    max-width: none;
  }
  .main {
    padding: 24px 16px 40px;
  }
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand__logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.brand__name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}
.brand__tagline {
  font-size: 12px;
  color: var(--text-muted);
}

/* Navigation */
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav__link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--touch-target);
  padding: 11px 14px;
  border-radius: var(--radius-control);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.nav__link:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.nav__link[aria-current='page'] {
  background: var(--track);
  color: #fff;
  font-weight: 700;
}
.nav__link[aria-current='page'] svg {
  stroke: var(--accent);
}

.sidebar__divider {
  height: 1px;
  background: var(--divider);
}

.sidebar__footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-faint);
  line-height: 1.5;
}
.sidebar__footer::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  flex: none;
}

/* Page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.page-header__title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.page-header__subtitle {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 15px;
}

.page {
  display: flex;
  flex-direction: column;
  gap: 24px;
  transition: opacity 0.15s;
}
.page.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

/* Grids */
.grid {
  display: grid;
  gap: 16px;
}
.grid--kpis {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.grid--two {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
}
.grid--cards {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}
.grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr));
  align-items: start;
}

/* The area list opens inline too, so the panel scrolls instead of clipping it. */
.menu-panel .combobox__panel {
  position: static;
  margin-block-start: 6px;
}

.range-tools__heading {
  margin-block-end: 10px;
}

/* Footer and credits dialog */
.site-footer {
  margin-block-start: auto;
  padding-block-start: 16px;
  border-block-start: 1px solid var(--divider);
  display: flex;
  justify-content: center;
}
.credits-link {
  min-height: var(--touch-target);
  padding: 8px 16px;
  background: transparent;
  border: 0;
  color: var(--text-faint);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.credits-link:hover {
  color: var(--text);
}
.credits {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.credits::backdrop {
  background: rgba(5, 7, 10, 0.7);
}
.credits__title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
}
.credits__lead {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
}
.credits__list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.credits__list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.credits__role {
  font-size: 12px;
  color: var(--text-faint);
}
.credits__list a {
  color: var(--info);
  font-weight: 600;
}
