/* Page shell: dark sidebar on the left, top bar with the trail, work area. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-7));
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  z-index: 20;
}

.skip-link:focus {
  top: var(--space-2);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Logo mark: a speech bubble with the bottom-left corner tight and three
   shortening lines. Sizes scale every part together. */
.mark {
  --mark-size: 30px;
  --mark-radius: 9px;
  --mark-corner: 3px;
  --mark-line: 3px;
  --mark-gap: 4px;
  --mark-pad: 7px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--mark-gap);
  flex-shrink: 0;
  width: var(--mark-size);
  height: var(--mark-size);
  padding: 0 var(--mark-pad);
  border-radius: var(--mark-radius) var(--mark-radius) var(--mark-radius) var(--mark-corner);
  background: var(--color-primary);
}

.mark__line {
  display: block;
  height: var(--mark-line);
  border-radius: var(--mark-line);
  background: var(--color-on-dark);
}

.mark__line:nth-child(2) { width: 70%; }
.mark__line:nth-child(3) { width: 40%; opacity: 0.6; }

.mark--large {
  --mark-size: 40px;
  --mark-radius: 12px;
  --mark-corner: 4px;
  --mark-line: 4px;
  --mark-gap: 5px;
  --mark-pad: 9px;
}

.mark--hero {
  --mark-size: 120px;
  --mark-radius: 32px;
  --mark-corner: 10px;
  --mark-line: 11px;
  --mark-gap: 14px;
  --mark-pad: 26px;
}

/* Logo: mark and wordmark */
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 2px var(--space-2);
  color: var(--color-on-dark);
  font-size: var(--text-md);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.app-brand:hover {
  color: var(--color-on-dark);
  text-decoration: none;
}

.app-brand__name {
  font-weight: 400;
}

.app-brand__name strong {
  font-weight: 700;
}

.app-brand--large {
  gap: var(--space-3);
  padding: 0;
  font-size: var(--text-xl);
}

/* Sidebar */
.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex-shrink: 0;
  width: var(--sidebar-width);
  height: 100vh;
  padding: 18px 14px;
  overflow-y: auto;
  background: var(--color-menu);
  color: var(--color-menu-ink);
}

.app-sidebar__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.app-sidebar__toggle {
  display: none;
}

.app-sidebar__menu {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
}

.app-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-base);
}

.app-nav__group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-nav__group--end {
  margin-top: auto;
  padding-top: var(--space-4);
}

.app-nav__heading {
  padding: 14px 10px 6px;
  color: var(--color-menu-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-nav__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 10px;
  border-radius: var(--radius-xs);
  color: var(--color-menu-ink);
}

.app-nav__link:hover {
  background: var(--color-menu-hover);
  color: var(--color-on-dark);
  text-decoration: none;
}

.app-nav__link[aria-current="page"] {
  background: var(--color-menu-active);
  color: var(--color-on-dark);
  font-weight: 500;
}

.app-nav__link[aria-current="page"]::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

/* «Nuovo contenuto»: the main action, above the groups */
.app-nav__cta,
.app-nav__cta[aria-current="page"] {
  justify-content: space-between;
  margin-bottom: var(--space-1);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-on-dark);
  font-weight: 600;
}

.app-nav__cta:hover {
  background: var(--color-primary-strong);
}

.app-nav__cta::after {
  content: "+";
  font-size: var(--text-lg);
  line-height: 1;
}

.app-nav__cta[aria-current="page"]::before {
  content: none;
}

/* Signed-in user, at the bottom of the sidebar */
.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: var(--space-2);
  padding: var(--space-3) 10px 0;
  border-top: 1px solid var(--color-menu-line);
  font-size: var(--text-base);
}

.app-user__avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-menu-hover);
  color: var(--color-on-dark);
  font-size: var(--text-xs);
  font-weight: 600;
}

.app-user__who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.app-user__name {
  overflow: hidden;
  color: var(--color-on-dark);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user__role {
  color: var(--color-menu-muted);
  font-size: var(--text-xs);
}

.app-user__sign-out {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-menu-muted);
  font-size: var(--text-sm);
  cursor: pointer;
}

.app-user__sign-out:hover {
  color: var(--color-on-dark);
}

/* Top bar with the trail */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-shrink: 0;
  height: var(--topbar-height);
  padding: 0 var(--page-gutter);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-topbar);
  backdrop-filter: blur(8px);
}

.breadcrumb {
  min-width: 0;
  font-size: var(--text-base);
}

.breadcrumb__list {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.breadcrumb__item + .breadcrumb__item::before {
  content: "/";
  color: var(--color-ink-faint);
}

.breadcrumb__link,
.breadcrumb__text {
  color: var(--color-ink-muted);
}

.breadcrumb__current {
  overflow: hidden;
  color: var(--color-ink);
  font-weight: 500;
  text-overflow: ellipsis;
}

/* Work area */
.app-main {
  flex: 1;
  width: 100%;
  padding: 32px var(--page-gutter) 56px;
}

/* Page header: title and description on the left, actions on the right */
.page__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-5);
}

.page__header > :first-child:not(:only-child) {
  flex: 1 1 360px;
  min-width: 0;
}

.page__title {
  margin: 0;
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-title);
}

.page__header p.muted,
.page__lead {
  max-width: 880px;
  margin: 6px 0 0;
  color: var(--color-ink-muted);
  line-height: var(--leading);
}

.page__title + .page__title-row {
  margin-top: 6px;
}

.page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Two columns: main content, summary or status on the right */
.layout-split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 20px;
}

.layout-split__main {
  display: flex;
  flex: 999 1 560px;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.layout-split__aside {
  display: flex;
  flex: 1 1 300px;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  max-width: var(--aside-width);
}

.layout-split__main > .card + .card,
.layout-split__aside > .card + .card {
  margin-top: 0;
}

/* Sign in, password reset and invitation pages */
.auth-body {
  background: var(--color-surface);
}

.auth-shell {
  display: flex;
  min-height: 100vh;
}

.auth-panel {
  display: flex;
  flex: 0 1 46%;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  min-width: 340px;
  padding: 40px 48px;
  background: var(--color-menu);
}

.auth-panel__claim {
  max-width: 460px;
  margin: 0;
  color: var(--color-on-dark);
  font-size: var(--text-2xl);
  font-weight: 500;
  line-height: 1.35;
  text-wrap: pretty;
}

.auth-panel__footer {
  margin: 0;
  color: var(--color-menu-muted);
  font-size: var(--text-sm);
}

.auth-main {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.auth-main__locale {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
}

/* Interface language: «IT | EN», a segmented control (T40) */
.locale-switch {
  display: inline-flex;
  flex-shrink: 0;
  gap: 2px;
  padding: 3px;
  border-radius: 9px;
  background: var(--color-neutral-soft);
}

.locale-switch__form {
  display: contents;
}

.locale-switch__option {
  padding: 4px var(--space-2);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-ink-muted);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.locale-switch__option:hover {
  color: var(--color-ink);
}

.locale-switch__option[aria-pressed="true"] {
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  color: var(--color-ink);
}

.auth {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 400px;
}

.auth__title {
  margin: 0;
}

.auth__intro {
  margin: 0;
  color: var(--color-ink-muted);
  line-height: 1.55;
}

.auth__form {
  max-width: none;
}

.auth__footer {
  margin: 0;
}

.auth .flash {
  margin: 0;
}

/* Narrow screens: the sidebar becomes a bar on top, the menu opens below */
@media (max-width: 64rem) {
  .app-shell {
    flex-direction: column;
  }

  .app-sidebar {
    z-index: 10;
    width: 100%;
    height: auto;
    max-height: 100vh;
    gap: var(--space-3);
    padding: 10px var(--page-gutter-mobile);
  }

  .app-sidebar__toggle {
    display: inline-flex;
    padding: 6px var(--space-3);
    border: 1px solid var(--color-menu-line);
    border-radius: var(--radius-sm);
    background: var(--color-menu-hover);
    color: var(--color-on-dark);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
  }

  .app-sidebar:not([data-open]) .app-sidebar__menu {
    display: none;
  }

  .app-nav__group--end {
    margin-top: 0;
  }

  .app-topbar {
    position: static;
    padding: 0 var(--page-gutter-mobile);
  }

  .app-main {
    padding: var(--space-5) var(--page-gutter-mobile) var(--space-7);
  }
}

@media (max-width: 48rem) {
  .auth-shell {
    flex-direction: column;
  }

  .auth-panel {
    flex: none;
    min-width: 0;
    gap: var(--space-4);
    padding: var(--space-5) var(--page-gutter-mobile);
  }

  .auth-panel__claim {
    font-size: var(--text-lg);
  }

  .auth-panel__footer {
    display: none;
  }

  .auth-main {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--space-4);
    padding: var(--space-6) var(--page-gutter-mobile);
  }

  .auth-main__locale {
    position: static;
    align-self: flex-end;
  }
}
