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

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(var(--sidebar-w), 86vw);
  background:
    linear-gradient(180deg, rgba(165, 40, 64, 0.18) 0%, transparent 28%),
    linear-gradient(165deg, var(--brand-900) 0%, #2a0810 100%);
  color: #f8f0f2;
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform var(--motion);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 4px 0 24px rgba(26, 22, 23, 0.12);
}

.app-shell.is-sidebar-open .app-sidebar {
  transform: translateX(0);
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-5) var(--s-4);
  text-decoration: none;
  color: inherit;
}

.app-sidebar__brand-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--brand-500), var(--brand-700));
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.app-sidebar__brand-mark .icon {
  width: 1.15rem;
  height: 1.15rem;
}

.app-sidebar__brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.app-sidebar__brand-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.app-sidebar__brand-tag {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(248, 240, 242, 0.5);
}

.app-sidebar__nav {
  padding: var(--s-2) var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow-y: auto;
  flex: 1;
}

.app-sidebar__section {
  margin: var(--s-4) var(--s-3) var(--s-2);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(248, 240, 242, 0.42);
}

.app-sidebar__section:first-child {
  margin-top: var(--s-2);
}

.app-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0.65rem 0.85rem;
  border-radius: var(--r-md);
  color: rgba(248, 240, 242, 0.78);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background var(--motion), color var(--motion);
}

.app-nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.app-nav-link.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.app-nav-link.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: #f2c4cc;
}

.app-sidebar__footer {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-xs);
  color: rgba(248, 240, 242, 0.5);
  line-height: 1.4;
}

.app-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 28, 0.4);
  z-index: 25;
}

.app-shell.is-sidebar-open .app-backdrop {
  display: block;
}

.app-main {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-700), var(--brand-500) 40%, transparent 78%);
  pointer-events: none;
  z-index: 21;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 0 var(--s-5);
  background: rgba(239, 234, 234, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(208, 199, 201, 0.65);
}

.app-topbar__left,
.app-topbar__right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.app-topbar__org {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-700);
  display: none;
}

.app-topbar__bell {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-800);
  cursor: pointer;
}

.app-topbar__bell:hover {
  border-color: var(--brand-600);
  background: var(--brand-50);
  color: var(--brand-800);
}

.app-topbar__badge {
  position: absolute;
  top: -0.2rem;
  right: -0.25rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: var(--brand-700);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 1.1rem;
  text-align: center;
}

.dropdown--notifications .dropdown__menu--notifications {
  width: min(22rem, calc(100vw - 2rem));
  right: 0;
  padding: 0;
  overflow: hidden;
}

.notif-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}

.notif-panel__empty {
  margin: 0;
  padding: 1.25rem 0.85rem;
  font-size: var(--fs-sm);
}

.notif-item {
  display: grid !important;
  gap: 0.15rem;
  align-items: start;
  padding: 0.75rem 0.85rem !important;
  border-bottom: 1px solid rgba(208, 199, 201, 0.45);
  white-space: normal;
}

.notif-item:last-child {
  border-bottom: 0;
}

.notif-item.is-unread {
  background: var(--brand-50);
}

.notif-item__title {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--ink-900);
}

.notif-item__body {
  font-size: var(--fs-xs);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.notif-item__time {
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}

.app-topbar__user {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 36px;
  padding: 0.35rem 0.65rem 0.35rem 0.45rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-900);
  font-size: var(--fs-sm);
  font-weight: 500;
  cursor: pointer;
}

.app-topbar__user:hover {
  border-color: var(--brand-600);
  background: var(--brand-50);
}

.app-topbar__avatar {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-800);
  display: grid;
  place-items: center;
}

.app-content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-8);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-5);
  border-bottom: 1px solid var(--line);
}

.page-header__text {
  min-width: 0;
  flex: 1;
}

.page-header__desc {
  margin-top: var(--s-2);
  color: var(--ink-500);
  font-size: var(--fs-sm);
  max-width: 40rem;
  line-height: 1.5;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  padding-bottom: 0.15rem;
}

.guest-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-6) var(--s-4);
  background:
    radial-gradient(ellipse 70% 50% at 8% -8%, rgba(138, 28, 49, 0.14), transparent 52%),
    radial-gradient(ellipse 45% 35% at 100% 5%, rgba(26, 85, 122, 0.08), transparent 48%),
    linear-gradient(180deg, #f4efef 0%, var(--canvas) 100%);
}

.guest-card {
  width: min(26.5rem, 100%);
  background: var(--surface);
  border: 1px solid rgba(208, 199, 201, 0.85);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-6) var(--s-5);
  box-shadow: var(--shadow-2);
}

.guest-card__brand-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.guest-card__mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--brand-500), var(--brand-800));
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.guest-card__brand {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--brand-900);
  margin: 0;
  line-height: 1.15;
}

.guest-card__lede {
  margin: 0 0 var(--s-5);
  color: var(--ink-500);
  font-size: var(--fs-sm);
}

@media (min-width: 960px) {
  .app-shell {
    grid-template-columns: var(--sidebar-w) 1fr;
  }

  .app-sidebar {
    transform: none;
    position: sticky;
    top: 0;
    height: 100vh;
  }

  .app-shell.is-sidebar-collapsed {
    grid-template-columns: 72px 1fr;
  }

  .app-shell.is-sidebar-collapsed .app-sidebar {
    width: 72px;
  }

  .app-shell.is-sidebar-collapsed .app-sidebar__brand-copy,
  .app-shell.is-sidebar-collapsed .app-sidebar__section,
  .app-shell.is-sidebar-collapsed .app-nav-link span,
  .app-shell.is-sidebar-collapsed .app-sidebar__footer {
    display: none;
  }

  .app-shell.is-sidebar-collapsed .app-sidebar__brand {
    justify-content: center;
    padding-inline: var(--s-3);
  }

  .app-backdrop {
    display: none !important;
  }

  .app-topbar__org {
    display: inline;
  }

  .app-topbar__menu {
    display: none;
  }

  .app-topbar__collapse {
    display: inline-flex;
  }
}

.app-topbar__collapse {
  display: none;
}

/* Styleguide extras */
.sg-section {
  margin-bottom: var(--s-8);
  scroll-margin-top: 5rem;
}

.sg-section__title {
  margin-bottom: var(--s-2);
}

.sg-section__desc {
  color: var(--ink-500);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-4);
  max-width: 40rem;
}

.panel,
.sg-panel {
  background: var(--surface);
  border: 1px solid rgba(208, 199, 201, 0.75);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}

.panel--flush,
.sg-panel--flush {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.panel__eyebrow {
  margin: 0 0 var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-700);
}

.panel__title,
.sg-panel__title {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0 0 var(--s-4);
}

.panel__title--inline,
.sg-panel__title--inline {
  margin: 0;
}

.fields-grid,
.sg-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--s-4);
}

.fields-grid .field--full,
.sg-fields-grid .field--full {
  grid-column: 1 / -1;
}

.kpi-grid,
.sg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--s-4);
}

.fieldset-plain,
.sg-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.gap-mb,
.sg-demo-mb {
  margin-bottom: var(--s-5);
}

.gap-mt,
.sg-demo-stack-mt {
  margin-top: var(--s-4);
}

.gap-block,
.sg-demo-gap {
  margin-top: var(--s-5);
}

.sg-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
  gap: var(--s-3);
}

.sg-swatch {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}

.sg-swatch__color {
  height: 3.5rem;
}

.sg-swatch__color--brand-900 { background: var(--brand-900); }
.sg-swatch__color--brand-700 { background: var(--brand-700); }
.sg-swatch__color--brand-500 { background: var(--brand-500); }
.sg-swatch__color--brand-100 { background: var(--brand-100); }
.sg-swatch__color--ink-900 { background: var(--ink-900); }
.sg-swatch__color--ink-500 { background: var(--ink-500); }
.sg-swatch__color--canvas { background: var(--canvas); }
.sg-swatch__color--ok { background: var(--ok); }
.sg-swatch__color--warn { background: var(--warn); }
.sg-swatch__color--danger { background: var(--danger); }
.sg-swatch__color--info { background: var(--info); }

.status-code { font-size: var(--fs-sm); }
.sg-mono-block {
  overflow: auto;
  font-size: var(--fs-xs);
  margin-top: var(--s-5);
  font-family: var(--font-mono);
}
.sg-chart-desc {
  font-size: var(--fs-sm);
  margin: 0;
}

.sg-swatch__meta {
  padding: var(--s-2);
  font-size: var(--fs-xs);
}

.sg-toc {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  margin-bottom: var(--s-6);
}

.sg-toc a {
  font-size: var(--fs-sm);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-700);
}

.sg-toc a:hover {
  border-color: var(--brand-600);
  color: var(--brand-700);
}
