/* Missionplane on the Sendplane design system: shell.
 * The AppShell, BrandMark, ContextSwitcher, ProfileMenu, ThemePicker,
 * PageHeader and AuthCard recipes from Sendplane's tenant console, with
 * Missionplane's search entry and account menu. Class names follow the
 * design system's components so its markup can be reused as is. */

/* ─── Brand mark ─────────────────────────────────────────────── */
.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 8px 22px;
  color: var(--ink);
  text-decoration: none;
  font-size: 16px;
  font-weight: 680;
  letter-spacing: -.02em;
  border-radius: var(--radius-control);
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: var(--brand-mark-size);
  height: var(--brand-mark-size);
  flex: 0 0 auto;
  border-radius: var(--radius-control);
  color: var(--fg-inverse);
  background: var(--interactive-primary);
  box-shadow: var(--brand-mark-inset);
}
.brand-mark svg { width: 16px; height: 16px; }

/* ─── Loading and sign-in (AuthCard) ─────────────────────────── */
.auth-loading {
  position: fixed;
  z-index: var(--z-skip-link);
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
  background: var(--canvas);
  font-size: 13px;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 30%, var(--surface-elevated) 0, var(--surface-canvas) 60%);
}
.auth-card {
  width: min(var(--auth-card-width), 100%);
  padding: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow-auth);
  text-align: center;
}
.auth-card > .brand-mark { margin: 0 auto 25px; }
.auth-card h1 { font-size: 28px; }
.auth-card > p:not(.eyebrow) { color: var(--muted); line-height: 1.55; }
.auth-entry-message { min-height: 1.55em; margin: 6px 0 0; }
.auth-entry-actions { display: grid; gap: 10px; margin-top: 24px; }
.auth-entry-actions .button { width: 100%; }
.auth-entry-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.auth-key-form { display: grid; gap: 8px; margin-top: 8px; text-align: left; }
.organization-picker { display: grid; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); text-align: left; }
.organization-picker .form-select { width: 100%; }
.organization-picker .button { justify-self: start; }
.auth-entry-secondary { display: flex; justify-content: center; gap: 6px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.auth-entry-secondary .quiet-button { width: auto; padding-inline: 12px; }

/* ─── App shell ──────────────────────────────────────────────── */
.app-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  overflow: hidden;
}
.sidebar {
  position: relative;
  z-index: 2;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-sidebar);
}
.main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  container-type: inline-size;
}
.page {
  width: min(var(--page-max), 100%);
  margin: 0 auto;
  padding: 56px 48px 80px;
}

/* ─── Context switcher (workspace) ───────────────────────────── */
.sidebar-context:empty { display: none; }
.context-switcher, .profile-menu { position: relative; width: 100%; }
.project-switcher {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: var(--avatar-size) minmax(0, 1fr) 16px;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-callout);
  color: var(--fg-primary);
  background: var(--surface-primary);
  text-align: left;
  box-shadow: var(--shadow-control);
  cursor: pointer;
  list-style: none;
  transition: border-color 140ms ease;
}
.project-switcher::-webkit-details-marker, .profile-trigger::-webkit-details-marker { display: none; }
.project-switcher > span:nth-child(2), .profile-trigger-identity { min-width: 0; display: grid; gap: 2px; }
.project-switcher strong, .profile-trigger strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.project-switcher small, .profile-trigger small { overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; white-space: nowrap; }
.project-avatar, .avatar {
  display: inline-grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: var(--radius-control);
  color: var(--accent-dark);
  background: var(--info-bg);
  font-size: 12px;
  font-weight: 700;
}
.context-chevron { width: 15px; height: 15px; color: var(--quiet); transition: transform 140ms var(--ease-out); }
.context-switcher[open] .context-chevron, .profile-menu[open] .profile-chevron { transform: rotate(90deg); }

.context-menu {
  position: absolute;
  z-index: var(--z-menu);
  top: calc(100% + 8px);
  left: 0;
  width: min(var(--menu-width), calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 150px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-menu);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-menu);
}
.context-menu-header { padding: 14px 14px 11px; border-bottom: 1px solid var(--line); }
.context-menu-header span { min-width: 0; display: grid; gap: 2px; }
.context-menu-header strong { font-size: 13px; }
.context-menu-header small { color: var(--muted); font-size: 11px; }
.context-search { display: block; padding: 10px 10px 0; }
.context-search input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--canvas);
  font-size: 12px;
}
.context-search input::placeholder { color: var(--field-placeholder); }
.context-search input:focus { border-color: var(--accent); box-shadow: var(--focus-field); outline: 0; }
.context-options { min-height: 0; max-height: min(500px, calc(100vh - 250px)); overflow-y: auto; padding: 7px; overscroll-behavior: contain; }
.context-project, .tenant-switch-button {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.context-project > span:first-child, .tenant-switch-button > span:first-child { min-width: 0; display: grid; gap: 2px; }
.context-project strong, .tenant-switch-button strong { overflow: hidden; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.context-project small, .tenant-switch-button small { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.context-mark { color: var(--quiet); font-size: 13px; text-align: center; }
.context-project[aria-current="true"], .tenant-switch-button[aria-current="true"] { background: var(--interactive-selected); }
.context-project[aria-current="true"] .context-mark, .tenant-switch-button[aria-current="true"] .context-mark,
.context-project[aria-current="true"] small, .tenant-switch-button[aria-current="true"] small { color: var(--ink); }
.context-project:disabled, .tenant-switch-button:disabled { cursor: default; opacity: .65; }
.context-project[aria-current="true"]:disabled, .tenant-switch-button[aria-current="true"]:disabled { opacity: 1; }
.context-empty { margin: 0; padding: 10px 8px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.context-menu-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-elevated);
}
.context-menu-footer a, .context-menu-footer button {
  padding: 0;
  border: 0;
  border-radius: var(--radius-hairline);
  color: var(--muted);
  background: none;
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

/* ─── Search and navigation ──────────────────────────────────── */
.sidebar-search {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  color: var(--quiet);
  background: var(--surface-primary);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), border-color 140ms ease, color 140ms ease;
}
.sidebar-search svg { width: 15px; height: 15px; }
.sidebar-search span { flex: 1; }

.sidebar-navigation { min-height: 0; flex: 1 1 auto; margin: 16px -4px 0; padding: 0 4px; overflow-y: auto; overscroll-behavior: contain; }
.nav-list { display: grid; gap: 3px; margin: 0; padding: 0 0 12px; list-style: none; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--control-height);
  padding: 0 10px;
  border-radius: var(--radius-control);
  color: var(--fg-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 520;
  transition: transform 120ms var(--ease-out), color 120ms ease, background-color 120ms ease;
}
.nav-icon { display: inline-grid; place-items: center; }
.nav-link svg { width: 17px; height: 17px; }
.nav-link[aria-current="page"] { color: var(--fg-primary); background: var(--interactive-selected); font-weight: 650; }
.nav-count {
  min-width: 18px;
  margin-left: auto;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  color: var(--warning-fg);
  background: var(--warning-bg);
  font-size: 10px;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.sidebar-status { margin: 4px 0 12px; }

/* ─── Profile menu (account, theme, sign out) ────────────────── */
.sidebar-account { flex: 0 0 auto; }
.profile-menu { padding: 14px 7px 0; border-top: 1px solid var(--line); }
.sidebar > .profile-menu { margin-top: auto; }
.profile-trigger {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: var(--avatar-size) minmax(0, 1fr) 15px;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border-radius: var(--radius-button);
  cursor: pointer;
  list-style: none;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.profile-chevron { width: 14px; height: 14px; color: var(--quiet); transition: transform 140ms var(--ease-out); }
.profile-popover {
  position: absolute;
  z-index: var(--z-popover);
  bottom: calc(100% + 8px);
  left: 0;
  width: min(var(--popover-width), calc(100vw - 32px));
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-menu);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-menu);
}
.profile-popover-header { min-width: 0; display: grid; grid-template-columns: var(--avatar-size) minmax(0, 1fr); align-items: center; gap: 10px; padding: 13px; }
.profile-popover-header > span:last-child { min-width: 0; display: grid; gap: 3px; }
.profile-popover-header strong, .profile-popover-header small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-popover-header strong { font-size: 12px; }
.profile-popover-header small { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.tenant-switcher { border-top: 1px solid var(--line); }
.tenant-switcher > header { padding: 11px 14px 5px; color: var(--quiet); font-size: 10px; letter-spacing: .055em; text-transform: uppercase; }
.tenant-switcher > header strong { font-weight: 680; }
.tenant-switcher .context-search { padding: 4px 10px 2px; }
.tenant-options { max-height: min(240px, calc(100vh - 380px)); min-height: 44px; overflow-y: auto; padding: 4px 7px 7px; overscroll-behavior: contain; }
.profile-theme-picker { padding: 9px 7px; border-top: 1px solid var(--border-subtle); }
.profile-actions { display: grid; gap: 2px; padding: 7px; border-top: 1px solid var(--line); }
.profile-actions a {
  min-height: var(--control-height);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 9px;
  border-radius: var(--radius-control);
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 580;
  transition: transform 120ms var(--ease-out), color 120ms ease, background-color 120ms ease;
}
.profile-actions svg { width: 15px; height: 15px; }
.profile-sign-out { padding: 7px; border-top: 1px solid var(--line); }
.profile-sign-out button {
  width: 100%;
  min-height: var(--control-height);
  padding: 0 9px;
  border: 0;
  border-radius: var(--radius-control);
  color: var(--muted);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
  font-weight: 580;
  transition: transform 120ms var(--ease-out), color 120ms ease, background-color 120ms ease;
}

/* ─── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}
.page-header > div:first-child { min-width: 0; }
.page-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }
.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.lede { max-width: 580px; margin-bottom: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.section-stack { display: grid; gap: 18px; }
.loading-line { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* Imported full-height pages keep their canvas inside the shell. */
.page-canvas { position: relative; width: 100%; height: 100%; padding: var(--space-4); }
.connection-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: var(--radius-round); background: var(--success); }
.connection-dot.disconnected { background: var(--danger); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes dotPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* ─── Pressed, hover and focus ───────────────────────────────── */
.nav-link:active, .context-project:active, .tenant-switch-button:active, .profile-trigger:active,
.profile-actions a:active, .profile-sign-out button:active, .sidebar-search:active { transform: scale(.97); }
.project-switcher:focus-visible, .profile-trigger:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .nav-link:hover { color: var(--ink); background: var(--soft); }
  .nav-link[aria-current="page"]:hover { background: var(--interactive-selected); }
  .project-switcher:hover { border-color: var(--border-default); }
  .sidebar-search:hover { border-color: var(--border-default); color: var(--ink); }
  .profile-trigger:hover, .context-project:not(:disabled):hover, .tenant-switch-button:not(:disabled):hover { background: var(--soft); }
  .context-menu-footer a:hover, .context-menu-footer button:hover { color: var(--ink); }
  .profile-actions a:hover, .profile-sign-out button:hover { color: var(--ink); background: var(--soft); }
}

/* ─── Phones: the sidebar becomes a top bar ──────────────────── */
@media (max-width: 760px) {
  .app-shell { height: auto; display: block; overflow: visible; }
  .main { overflow: visible; }
  .sidebar { width: 100%; padding: 14px 14px 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 96px 13px 4px; }
  .sidebar-context { margin-bottom: 10px; }
  .context-menu { width: min(320px, calc(100vw - 28px)); }
  .sidebar-search { position: absolute; top: 14px; right: 58px; width: 32px; min-height: 32px; margin: 0; padding: 0; justify-content: center; }
  .sidebar-search span, .sidebar-search kbd { display: none; }
  .sidebar-account, .sidebar > .profile-menu { position: absolute; top: 14px; right: 14px; width: auto; margin: 0; }
  .profile-menu { padding: 0; border: 0; }
  .profile-trigger { grid-template-columns: var(--avatar-size); padding: 0; }
  .profile-trigger-identity, .profile-chevron { display: none; }
  .profile-popover { top: calc(100% + 8px); right: 0; bottom: auto; left: auto; width: min(320px, calc(100vw - 28px)); max-height: calc(100vh - 80px); }
  .sidebar-navigation { margin: 0 -14px; padding: 0 14px; overflow: visible; }
  .nav-list { grid-auto-flow: column; grid-auto-columns: minmax(66px, max-content); gap: 2px; padding: 0; overflow-x: auto; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-link { min-height: 52px; flex-direction: column; justify-content: center; gap: 4px; padding: 4px 10px; font-size: 10px; text-align: center; white-space: nowrap; }
  .nav-count { position: absolute; top: 3px; right: 6px; min-width: 16px; padding: 0 4px; }
  .sidebar-status { margin: 8px 0 0; }
  .page { padding: 34px 18px 60px; }
  .page-header { align-items: flex-start; flex-direction: column; margin-bottom: 24px; }
  .page-actions { width: 100%; flex-direction: column-reverse; align-items: stretch; }
  .page-header .button { width: 100%; }
  .auth-card { padding: 28px 22px; }
}

/* Native modal: available before sign-in and from the application sidebar. */
.analytics-privacy-link { margin: 8px; text-align: left; }
.analytics-privacy {
  width: min(36rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-dialog);
  background: var(--surface-elevated);
  color: var(--fg-primary);
  box-shadow: var(--shadow-dialog);
}
.analytics-privacy::backdrop { background: var(--scrim); }
.analytics-privacy h2 { margin: 0 0 16px; font-size: 20px; }
.analytics-privacy p { margin: 0 0 16px; font-size: 14px; line-height: 1.6; }
