/* Superadmin layout */

.superadmin-sidebar {
  --color-sidebar-bg: oklch(0.25 0.022 165);
  --color-sidebar-hover: oklch(0.32 0.022 165);
  --color-sidebar-text: oklch(0.85 0.012 165);
  --color-sidebar-muted: oklch(0.55 0.018 165);
  --color-sidebar-subtle: oklch(0.68 0.014 165);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: var(--space-8) var(--space-5);
  position: sticky;
  top: 0;
}

.superadmin-brand__row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.superadmin-close {
  display: none;
}

.superadmin-brand {
  margin-bottom: var(--space-10);
  padding: 0 var(--space-2);
}

.superadmin-brand__logo {
  color: var(--color-honey);
  display: block;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: var(--space-1);
  text-decoration: none;
}

.superadmin-brand__badge {
  background: var(--color-accent);
  border-radius: var(--radius-round);
  color: var(--color-inverse-text);
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.6rem;
  text-transform: uppercase;
}

.superadmin-nav {
  display: grid;
  gap: var(--space-8);
}

.superadmin-nav__group {
  display: grid;
  gap: var(--space-2);
}

.superadmin-nav__link {
  align-items: center;
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  display: flex;
  font-size: 0.9375rem;
  font-weight: 600;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}

.superadmin-nav__link:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-sidebar-text);
}

.superadmin-nav__link--active {
  background: var(--color-accent);
  color: var(--color-sidebar-text);
}

.superadmin-nav__link--active:hover {
  background: var(--color-accent-hover);
}

.superadmin-footer {
  border-top: 1px solid var(--color-sidebar-hover);
  margin-top: auto;
  padding-top: var(--space-6);
}

.superadmin-logout {
  background: transparent;
  border: 0;
  color: var(--color-sidebar-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: var(--space-1) var(--space-3);
  text-align: left;
  transition: color 150ms ease;
}

.superadmin-logout:hover {
  color: var(--color-danger);
}

/* Stat cards */

.stat-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  margin-bottom: var(--space-8);
}

.stat-card {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.stat-card__label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  margin-bottom: var(--space-2);
  text-transform: uppercase;
}

.stat-card__value {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card__value--accent {
  color: var(--color-accent);
}

.stat-card__value--muted {
  color: var(--color-text-muted);
}

/* Dashboard observability sections (funnel, health list, activity feed) */

.dashboard-section {
  margin-bottom: var(--space-8);
}

.dashboard-section__head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.dashboard-section__head h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.dashboard-empty {
  background: var(--color-surface-raised);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text-muted);
  padding: var(--space-5);
  text-align: center;
}

/* Query-string toggle/filter groups — shared shape, touch-target sized */

.funnel-toggle,
.status-filter {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.funnel-toggle__link,
.status-filter__link {
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-round);
  color: var(--color-text-muted);
  display: inline-flex;
  font-size: 0.8125rem;
  font-weight: 600;
  min-height: var(--touch-target);
  padding: var(--space-1) var(--space-4);
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.funnel-toggle__link:hover,
.status-filter__link:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.funnel-toggle__link--active,
.status-filter__link--active {
  background: var(--color-accent-light);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.funnel-toggle__link:focus-visible,
.status-filter__link:focus-visible,
.sort-header:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Funnel — proportional bars make the drop-off visible at a glance */

.funnel {
  display: grid;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.funnel-step {
  align-items: center;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 12rem 1fr 4rem;
}

.funnel-step__label {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

.funnel-step__track {
  align-items: center;
  background: var(--color-surface-deep);
  border-radius: var(--radius-round);
  display: flex;
  min-height: 1.75rem;
  position: relative;
}

.funnel-step__bar {
  background: var(--color-honey);
  border-radius: var(--radius-round);
  height: 1.75rem;
  min-width: 0.5rem;
  transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.funnel-step__count {
  font-weight: 700;
  left: var(--space-3);
  position: absolute;
}

.funnel-step__conversion {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: right;
}

/* Health list — table-ish grid that collapses to label/value cards on mobile */

.health-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.health-list__head,
.health-list__row {
  align-items: center;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 2fr 1fr 1fr 1.5fr 1.5fr;
  padding: var(--space-3) var(--space-5);
}

.health-list__head {
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.health-list__row {
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.health-list__row--muted {
  opacity: 0.6;
}

.health-list__name {
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
}

.health-list__name:hover {
  color: var(--color-accent);
}

.sort-header {
  color: inherit;
  text-decoration: none;
}

.sort-header--active {
  color: var(--color-text);
}

/* Staleness — tri-state pills, distinct enough to scan in a long list */

.staleness {
  border-radius: var(--radius-round);
  display: inline-block;
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
}

.staleness--ok {
  color: var(--color-text-muted);
}

.staleness--warning {
  background: var(--color-honey-light);
  color: oklch(0.42 0.09 70);
}

.staleness--critical {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.staleness--cleared {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Activity feed — two-line rows, event type as eyebrow */

.activity-feed {
  display: grid;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-feed__item {
  border-left: 3px solid var(--color-border);
  padding: var(--space-2) var(--space-4);
}

.activity-feed__item--restaurant_suspended,
.activity-feed__item--admin_impersonated {
  border-left-color: var(--color-danger);
}

.activity-feed__item--restaurant_reactivated,
.activity-feed__item--first_menu_published {
  border-left-color: var(--color-secondary);
}

.activity-feed__item--signed_up,
.activity-feed__item--restaurant_created {
  border-left-color: var(--color-honey);
}

.activity-feed__line {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.activity-feed__type {
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.activity-feed__actor {
  font-weight: 600;
}

.activity-feed__target {
  color: var(--color-text-muted);
}

.activity-feed__time {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

@media (max-width: 980px) {
  .superadmin-sidebar {
    height: 100vh;
    left: 0;
    overflow-y: auto;
    position: fixed;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    width: min(80vw, 22rem);
    z-index: var(--z-overlay);
  }

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

  .superadmin-close {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--color-sidebar-muted);
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    height: var(--touch-target);
    justify-content: center;
    padding: 0;
    transition: color 150ms ease;
    width: var(--touch-target);
  }

  .superadmin-close:hover {
    color: var(--color-sidebar-text);
  }
}

/* Mobile: funnel stacks its conversion label, health list becomes
   label/value cards instead of a cramped 5-column grid */

@media (max-width: 640px) {
  .funnel-step {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .funnel-step__conversion {
    text-align: left;
  }

  .health-list__head {
    display: none;
  }

  .health-list__row {
    grid-template-columns: 1fr;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
  }

  .health-list__row [role="cell"] {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
  }

  .health-list__row [role="cell"]::before {
    color: var(--color-text-muted);
    content: attr(data-label);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}
