.app-root,
.app-shell {
  min-height: 100vh;
}

.app-shell {
  min-width: 320px;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--header-height);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, auto) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-header);
  backdrop-filter: blur(10px);
}

.header__rail-slot {
  width: var(--sidebar-width);
  height: var(--header-height);
  display: grid;
  place-items: center;
}

.header__brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
}

.header__brand-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

.header__brand-mark:hover,
.header__brand-mark[aria-expanded="true"] {
  filter: brightness(1.03);
}

.header__brand-copy {
  min-width: 0;
  align-self: center;
  height: 30px;
  display: flex;
  align-items: flex-end;
  padding: 0 0 2.7px 10px;
}

.header__brand-title {
  margin: 0;
}

.header__brand-title {
  color: var(--color-text);
  font-size: calc(16.5px * var(--font-scale));
  font-weight: 780;
  line-height: 1.05;
  letter-spacing: -0.015em;
}

.header__search {
  width: clamp(72px, 28vw, 300px);
  min-width: 0;
  margin: 0;
}

.header__actions {
  grid-column: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 14px;
}

.header__context-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-steel);
  font-size: calc(10px * var(--font-scale));
  font-weight: 650;
  background: var(--color-surface);
}

.header__context-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
}

.app-body {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  z-index: 35;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--color-sidebar);
  overflow: visible;
  transition: width 170ms ease, box-shadow 170ms ease;
}


.app-shell[data-menu-open="true"] .sidebar {
  width: var(--sidebar-expanded-width);
  box-shadow: 12px 0 28px rgb(20 48 39 / 8%);
}

.sidebar__nav {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 0;
}

.sidebar__group {
  display: grid;
  gap: 5px;
}

.sidebar__divider {
  width: 24px;
  height: 1px;
  margin: 2px 0 2px 16px;
  background: var(--color-border);
}

.sidebar__nav-bottom {
  margin-top: auto;
  display: grid;
  gap: 6px;
}

.main-content {
  width: min(100%, var(--content-max-width));
  min-width: 0;
  margin: 0 auto;
  padding: 14px 18px 18px;
}

.page-stack {
  display: grid;
  align-content: start;
  gap: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
}

.dashboard-grid > .span-12 { grid-column: span 12; }
.dashboard-grid > .span-8 { grid-column: span 8; }
.dashboard-grid > .span-6 { grid-column: span 6; }
.dashboard-grid > .span-4 { grid-column: span 4; }
.dashboard-grid > .span-3 { grid-column: span 3; }

@media (min-width: 1280px) {
  .main-content { padding: 14px 22px 20px; }
}

@media (max-width: 1024px) {
  .dashboard-grid > .span-3 { grid-column: span 6; }
  .dashboard-grid > .span-8,
  .dashboard-grid > .span-4 { grid-column: span 6; }
}

@media (max-width: 760px) {
  .header__actions { gap: 6px; padding-right: 10px; }
  .header__context-chip span:not(.header__context-dot) { display: none; }
  .header__context-chip { width: 30px; justify-content: center; padding-inline: 0; }
  .main-content { padding: 14px; }
  .dashboard-grid > .span-8,
  .dashboard-grid > .span-6,
  .dashboard-grid > .span-4,
  .dashboard-grid > .span-3 { grid-column: span 12; }
}

@media (max-width: 420px) {
  .main-content { padding: 14px 12px 12px; }
  .dashboard-grid,
  .page-stack { gap: 10px; }
}
