/* Admin Layout */
.admin-layout {
  --admin-header-height: 56px;

  /* One rhythm for every panel: a page is blocks (header, stats, filters, a list) a
     block-gap apart; a titled section opens a section-gap above; cards in a grid or a
     column sit a gap apart; a card and a filter bar pad by card-padding; every list,
     table and timeline row pads by row-padding. Reach for these before a literal. */
  --admin-gap: 0.625rem;
  --admin-block-gap: 1rem;
  --admin-section-gap: 1.25rem;
  --admin-card-padding: 0.875rem;
  --admin-row-padding: 0.5rem 0.875rem;
  --admin-radius: var(--radius-sm);

  /* The admin is a dense tool read on a desk: its type scale runs a step under the app's,
     so the same tokens land smaller everywhere in the layout. */
  --text-xs: 0.6875rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.125rem;
  --text-xl: 1.3125rem;
  --text-2xl: 1.5rem;

  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-light);
}

/* Admin Header / Nav */
.admin-header {
  background: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 0.5rem 1.25rem;
  max-width: var(--main-width);
  margin: 0 auto;
}

.admin-nav-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* The admin lockup, at the height the app's sidebar gives its own. */
.admin-nav-logo {
  display: flex;
  align-items: center;

  .brand_logo {
    height: 22px;
  }
}

.admin-nav-links {
  display: flex;
  list-style: none;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.admin-nav-link {
  color: var(--color-text-light);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: var(--text-sm);
  transition: background 0.15s, color 0.15s;

  &:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
  }

  &.active {
    background: var(--color-bg-secondary);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
  }
}

/* A group of panels: its label opens the panels beneath it. */
.admin-nav-group {
  position: relative;
}

.admin-nav-group-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;

  svg {
    width: 14px;
    height: 14px;
  }
}

.admin-nav-group-panel {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  min-width: 200px;
  padding: 0.375rem;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  z-index: var(--z-popup);
}

.admin-nav-group-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  color: var(--color-text);
  text-decoration: none;
  font-size: var(--text-sm);
  white-space: nowrap;

  svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-light);
  }

  &:hover {
    background: var(--color-bg-secondary);
  }

  &.active {
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);

    svg {
      color: var(--color-primary);
    }
  }
}

.admin-nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: var(--text-sm);
  color: var(--color-text-light);
  flex-shrink: 0;
}

/* The header's icon-only destinations (alerts), sized like its text links. */
.admin-nav-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: var(--color-text-light);

  svg {
    width: 20px;
    height: 20px;
  }

  &:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
  }

  &.active {
    color: var(--color-primary);
  }
}

/* Phone only: desktop has the browser's own reload. Spins while Turbo marks the page busy. */
.admin-nav-refresh {
  display: none;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-inline-end: -12px;
  color: var(--color-text-light);

  svg {
    width: 20px;
    height: 20px;
  }

  &:active {
    color: var(--color-text);
  }

  html[aria-busy] & svg {
    animation: admin-nav-refresh-spin 0.8s linear infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    html[aria-busy] & svg {
      animation: none;
    }
  }

  @keyframes admin-nav-refresh-spin {
    to {
      rotate: 360deg;
    }
  }
}

.admin-nav-logout {
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: var(--text-sm);

  &:hover {
    background: var(--color-bg-secondary);
    border-color: var(--color-border-hover);
  }
}

/* Admin Main */
.admin-main {
  flex: 1;
  max-width: var(--main-width);
  margin: 0 auto;
  width: 100%;
  padding: var(--admin-block-gap);
}

/* Admin Dashboard */
.admin-dashboard {
  h1 {
    margin: 0 0 var(--admin-block-gap);
    font-size: var(--text-xl);
  }
}

/* Stat cards: a fixed column rhythm shared by every section, so the numbers in one
   section sit over the numbers in the next. auto-fill keeps the column width stable
   instead of stretching a short row of cards into billboards. */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: var(--admin-gap);
  margin-bottom: var(--admin-block-gap);
}

/* One metric. The value takes the first row so every card's number shares a baseline,
   the label sits beneath it, and whatever follows (a breakdown, a change) is pushed to the
   bottom edge by the label's auto margin. */
.admin-stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  padding: 0.625rem 0.75rem 0.5rem;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
}

/* A card that is a link (the open-errors count opens the list behind it). */
.admin-stat-card-link {
  color: inherit;
  text-decoration: none;

  &:hover {
    border-color: var(--color-border-hover);
  }
}

/* A value that is words, not a number: sized to fit the tile. */
.admin-stat-value-text {
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
}

.admin-stat-card-table {
  grid-column: 1 / span 2;
  gap: 0;
  padding: 0;
  text-align: left;
}

.admin-stat-table-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    border-bottom: none;
  }
}

.admin-stat-table-label {
  color: var(--color-text-light);
}

.admin-stat-table-value {
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.admin-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.admin-stat-label {
  margin-bottom: auto;
  color: var(--color-text-light);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.3;
  text-wrap: pretty;
}

.admin-section {
  margin-top: var(--admin-section-gap);

  h2 {
    font-size: var(--text-lg);
    margin: 0 0 0.75rem;
  }

  .admin-section-link {
    margin-left: 0.5rem;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-normal);
  }
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-list-item {
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    border-bottom: none;
  }
}

.admin-list-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  text-decoration: none;
  color: var(--color-text);

  &:hover {
    background: var(--color-bg-light);
  }
}

.admin-list-primary {
  font-weight: var(--font-weight-medium);
}

.admin-list-secondary {
  color: var(--color-text-light);
  font-size: var(--text-sm);
}

.admin-list-meta {
  margin-left: auto;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.admin-lifecycle-reasons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* WhatsApp Admin Panel */
.admin-whatsapp {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 120px);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

/* Sidebar */
.admin-whatsapp-sidebar {
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-light);
}

.admin-whatsapp-sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-primary);

  h2 {
    margin: 0;
    font-size: var(--text-lg);
  }
}

.admin-whatsapp-contacts {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.admin-whatsapp-contact {
  border-bottom: 1px solid var(--color-border);

  &.selected {
    background: var(--color-bg-secondary);
  }

  &:hover {
    background: var(--color-bg-secondary);
  }
}

.admin-whatsapp-contact-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--color-text);
}

.admin-whatsapp-contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-whatsapp);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-base);
  flex-shrink: 0;
}

.admin-whatsapp-contact-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.admin-whatsapp-contact-name {
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-whatsapp-contact-phone {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.admin-whatsapp-contact-time {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-whatsapp-window-badge {
  color: var(--color-whatsapp);
  flex-shrink: 0;
}

.admin-whatsapp-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--color-text-light);
}

/* Chat Main Area */
.admin-whatsapp-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.admin-whatsapp-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
}

.admin-whatsapp-chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.admin-whatsapp-chat-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-whatsapp-chat-back {
  display: none;
  align-items: center;
  justify-content: center;
  flex: none;
  width: var(--back-tap-size);
  height: var(--back-tap-size);
  margin-left: calc(-1 * var(--back-ink-inset));
  color: var(--color-text);

  svg {
    width: var(--back-icon-size);
    height: var(--back-icon-size);
  }
}

.admin-whatsapp-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-whatsapp);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.admin-whatsapp-chat-info {
  flex: 1;

  h3 {
    margin: 0;
    font-size: var(--text-base);
  }
}

.admin-whatsapp-chat-phone {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-whatsapp-chat-type {
  display: inline-block;
  margin-left: 0.5rem;
  background: var(--color-bg-secondary);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.admin-whatsapp-businesses {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-whatsapp-business {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
}

.admin-whatsapp-business-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-whatsapp-business-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
}

.admin-whatsapp-business-owner,
.admin-whatsapp-business-stats {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

/* Não quer for this number, per business: the state and the one action beside it. */
.admin-whatsapp-proposals {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-whatsapp-proposals-title {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-light);
}

.admin-whatsapp-proposal {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.admin-whatsapp-proposal-action {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.admin-whatsapp-proposals-other {
  font-size: var(--text-xs);
  color: var(--color-text-light);

  .admin-whatsapp-proposals-other-toggle { cursor: pointer; }
}

.admin-whatsapp-proposals-search {
  display: flex;
  gap: 0.5rem;
  padding-top: 0.5rem;

  .admin-whatsapp-proposals-query { flex: 1; }
}

.admin-whatsapp-window-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-xs);
  color: var(--color-whatsapp);
  background: rgba(37, 211, 102, 0.1);
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
}

.admin-whatsapp-optout-info {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-xs);
  color: var(--color-danger);
  background: rgba(220, 53, 69, 0.1);
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
}

.admin-whatsapp-optout-badge {
  color: var(--color-danger);
  flex-shrink: 0;
}

.admin-whatsapp-contact.opted-out {
  opacity: 0.6;
}

.admin-whatsapp-opted-out {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-danger);
  background: rgba(220, 53, 69, 0.1);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: var(--text-sm);
}

/* Messages Area */
.admin-whatsapp-messages {
  flex: 1;
  /* Without it the flex item grows to fit every message and pushes the composer off-screen. */
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--color-bg-secondary);
}

.admin-whatsapp-messages-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
}

/* Message Bubbles */
.admin-whatsapp-message {
  display: flex;
  max-width: 70%;

  &.inbound {
    align-self: flex-start;
  }

  &.outbound {
    align-self: flex-end;
  }
}

.admin-whatsapp-message-bubble {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  max-width: 100%;

  .inbound & {
    background: var(--color-bg-primary);
    border-top-left-radius: 2px;
  }

  .outbound & {
    background: var(--color-whatsapp-bubble);
    color: var(--color-on-whatsapp-bubble);
    border-top-right-radius: 2px;
  }
}

.admin-whatsapp-message-template {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--text-xs);
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

.admin-whatsapp-message-media {
  margin-bottom: 0.25rem;
}

.admin-whatsapp-message-image,
.admin-whatsapp-message-video {
  display: block;
  max-width: 100%;
  max-height: 20rem;
  border-radius: 6px;
}

.admin-whatsapp-message-audio {
  max-width: 100%;
}

.admin-whatsapp-message-file {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: inherit;
}

.admin-whatsapp-message-placeholder {
  font-size: var(--text-sm);
  font-style: italic;
  opacity: 0.7;
}

.admin-whatsapp-message-content {
  word-wrap: break-word;

  p {
    margin: 0;
  }
}

.admin-whatsapp-message-meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}

.admin-whatsapp-message-time {
  font-size: var(--text-xs);
  opacity: 0.7;
}

.admin-whatsapp-message-status {
  display: flex;

  &.read {
    color: var(--color-whatsapp-read);
  }

  &.failed {
    color: var(--color-danger);
  }
}

/* Chat Footer / Input */
.admin-whatsapp-chat-footer {
  padding: 1rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-whatsapp-form {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
}

.admin-whatsapp-input {
  flex: 1;
  border: 1px solid var(--color-border);
  padding: 0.625rem 1rem;
  /* Three lines at rest, growing with the text where the browser can. */
  min-height: calc(3lh + 1.25rem);
  max-height: calc(10lh + 1.25rem);
  field-sizing: content;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  resize: none;
  font-family: inherit;
  background: var(--color-bg-primary);
  color: var(--color-text);

  &:focus {
    outline: none;
    border-color: var(--color-whatsapp);
  }
}

.admin-whatsapp-send {
  background: var(--color-whatsapp);
  color: var(--color-on-whatsapp);
  border: none;
  border-radius: 20px;
  padding: 0.625rem 1.25rem;
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background 0.15s;

  &:hover {
    background: var(--color-whatsapp-hover);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }
}

.admin-whatsapp-window-closed {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-warning-text);
  background: var(--color-warning-wash);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: var(--text-sm);
}

/* The template modal, opened from the chat header. */
.admin-whatsapp-template-picker {
  margin-left: auto;
  flex: none;
}

.admin-whatsapp-template-open {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;

  svg {
    width: 1rem;
    height: 1rem;
  }
}

.admin-whatsapp-template-modal {
  width: min(64rem, calc(100vw - 2rem));
  max-height: calc(100dvh - 4rem);
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  background: var(--color-bg-primary);
  color: var(--color-text);
  font-size: var(--text-base);

  &::backdrop {
    background: rgba(0, 0, 0, 0.4);
  }
}

.admin-whatsapp-template-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem 0.25rem 1.25rem;
  border-bottom: 1px solid var(--color-border);

  h2 {
    margin: 0;
    font-size: var(--text-lg);
  }
}

.admin-whatsapp-template-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--back-tap-size);
  height: var(--back-tap-size);
  border: none;
  background: none;
  color: var(--color-text);
  cursor: pointer;

  svg {
    width: 1.5rem;
    height: 1.5rem;
  }
}

/* A frame with a size, so the lazy load sees it come into view when the modal opens. */
.admin-whatsapp-template-frame {
  display: block;
  min-height: 24rem;
}

/* Templates, variables, preview: three columns on desktop, stacked on the phone. */
.admin-whatsapp-composer {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) minmax(0, 1fr);
  min-height: 24rem;
}

.admin-whatsapp-composer-templates {
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  border-right: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-whatsapp-composer-template {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;

  &.selected {
    background: var(--color-bg-secondary);
  }

  @media (hover: hover) {
    &:hover {
      background: var(--color-bg-secondary);
    }
  }
}

.admin-whatsapp-composer-template-title {
  font-weight: var(--font-weight-medium);
}

.admin-whatsapp-composer-template-kind {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.admin-whatsapp-composer-form {
  display: contents;
}

.admin-whatsapp-composer-fields,
.admin-whatsapp-composer-preview {
  padding: 1rem 1.25rem;
}

.admin-whatsapp-composer-preview {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-left: 1px solid var(--color-border);
  background: var(--color-whatsapp-chat);
}

.admin-whatsapp-composer-heading {
  margin: 0 0 0.75rem;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;

  .admin-whatsapp-composer-preview & {
    margin: 0;
  }
}

/* Drawn as the bubble it will be in the chat. */
.admin-whatsapp-template-preview {
  align-self: flex-end;
  max-width: 100%;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border-top-right-radius: 2px;
  background: var(--color-whatsapp-bubble);
  color: var(--color-on-whatsapp-bubble);
  line-height: 1.5;
  overflow-wrap: anywhere;

  mark {
    background: none;
    color: inherit;
    font-weight: var(--font-weight-semibold);

    &.blank {
      padding: 0 0.25rem;
      border-radius: 4px;
      background: var(--color-brand-wash);
      color: var(--color-primary);
      font-weight: inherit;
    }
  }
}

.admin-whatsapp-composer-confirm {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg-primary);

  p {
    margin: 0;
  }
}

/* The chat runs a step denser on desktop, where the root font-size is bumped. */
@media (min-width: 1024px) {
  .admin-whatsapp,
  .admin-whatsapp-template {
    --text-xs: 0.6875rem;
    --text-sm: 0.75rem;
    --text-base: 0.8125rem;
    --text-lg: 1rem;
    font-size: var(--text-base);
  }
}

/* Page Headers */
.admin-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--admin-block-gap);

  h1 {
    margin: 0;
    font-size: var(--text-xl);
  }
}

.admin-page-actions {
  display: flex;
  gap: 0.5rem;
}

.admin-breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  margin-bottom: 0.5rem;

  a {
    color: var(--color-primary);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
    }
  }
}

/* Search Form */
.admin-search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: var(--admin-block-gap);
}

.admin-search-input-wrapper {
  position: relative;
  flex: 1;
}

.admin-search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  width: 18px;
  height: 18px;
}

.admin-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-base);
  background: var(--color-bg-primary);
  color: var(--color-text);

  &:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
  }
}

/* Stat Change Indicator */
.admin-stat-change {
  display: block;
  font-size: var(--text-xs);
  padding-top: 0.5rem;
  font-variant-numeric: tabular-nums;

  &.positive {
    color: var(--color-success);
  }

  &.negative {
    color: var(--color-danger);
  }
}

/* List Enhancements */
.admin-list-content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
  flex: 1;
}

.admin-list-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-list-tag {
  background: var(--color-bg-secondary);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  margin-left: 0.5rem;
}

.admin-list-static {
  padding: var(--admin-row-padding);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-search-clear {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  padding: 0.5rem;
  color: var(--color-muted);

  svg {
    width: 18px;
    height: 18px;
  }
}

/* Clientes: one line a business on desktop, columns lined up across rows; two lines on the phone. */
.admin-customers {
  .admin-page-header {
    justify-content: flex-start;
    align-items: baseline;
    gap: 0.75rem;
  }

  .admin-customers-summary {
    color: var(--color-text-light);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
  }

  .admin-search-input::-webkit-search-cancel-button {
    display: none;
  }

  .admin-customers-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 8rem 11rem 9rem 7rem;
    align-items: center;
    gap: 1rem;
    padding: var(--admin-row-padding);
    color: var(--color-text);
    text-decoration: none;

    &:hover {
      background: var(--color-bg-light);
    }

    .admin-usage-bars {
      margin-top: 0;
    }
  }

  .admin-customers-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-customers-phone,
  .admin-customers-age {
    color: var(--color-text-light);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .admin-customers-age {
    text-align: right;
  }
}

@media (max-width: 768px) {
  .admin-customers {
    .admin-page-header {
      flex-direction: row;
      flex-wrap: wrap;
    }

    .admin-customers-row {
      grid-template-columns: auto minmax(0, 1fr) auto;
      grid-template-areas:
        "name name age"
        "plan phone bars";
      row-gap: 0.25rem;
      column-gap: 0.5rem;
      padding-block: 0.625rem;

      .admin-usage-bars {
        grid-area: bars;
        width: 6rem;
      }
    }

    .admin-customers-name { grid-area: name; }
    .admin-customers-plan { grid-area: plan; }
    .admin-customers-phone { grid-area: phone; }
    .admin-customers-age { grid-area: age; }
  }
}

/* Code */
.admin-code {
  font-family: monospace;
  background: var(--color-bg-secondary);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: var(--text-sm);
}

/* Badges */
.admin-badge-success {
  background: rgba(var(--color-success-rgb), 0.1);
  color: var(--color-success);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
}

.admin-badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: rgb(180, 120, 10);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
}

.admin-badge-muted {
  background: var(--color-bg-secondary);
  color: var(--color-muted);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
}

.admin-badge-info {
  background: rgba(var(--color-primary-rgb), 0.1);
  color: var(--color-primary);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
}

/* Detail View */
.admin-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--admin-gap);
  margin-bottom: var(--admin-block-gap);
}

.admin-closing-card .admin-panel-caption {
  margin: -0.25rem 0 0.75rem;
}

.admin-detail-card {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  padding: var(--admin-card-padding);

  h3 {
    margin: 0 0 0.75rem;
    font-size: var(--text-base);
    color: var(--color-text);
  }
}

/* The subscription card stacks the state, the payments ledger and the links to change them. */
.admin-subscription-subtitle {
  margin: 1rem 0 0.5rem;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-subscription-empty {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.admin-subscription-stripe-link {
  color: var(--color-primary);
}

.admin-subscription-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* A card whose body is a list: the list runs edge to edge under the title. */
.admin-detail-card-list {
  .admin-list {
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 0;
    margin: 0 calc(-1 * var(--admin-card-padding)) calc(-1 * var(--admin-card-padding));
  }
}

.admin-detail-card-empty {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

/* Feedback: what people wrote to us, every source together or one alone. */
.admin-feedbacks-subtitle {
  margin: 0 0 var(--admin-block-gap);
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-feedbacks-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--admin-block-gap);
}

.admin-feedbacks-source {
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  color: var(--color-text-light);
  background: var(--color-bg-light);
  text-decoration: none;

  &.selected {
    color: var(--color-on-brand);
    background: var(--color-primary);
  }
}

.admin-feedback-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.admin-feedback-business {
  color: var(--color-primary);
}

/* Account deletions: the requests waiting to be carried out by hand, then the latest closed. */
.admin-account-deletions-subtitle {
  margin: 0 0 var(--admin-block-gap);
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-account-deletion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 0.875rem 0.75rem;
}

.admin-account-deletion-business {
  color: var(--color-primary);
}

/* Link addresses: the review list, and a link's page. */
.admin-link-addresses-subtitle {
  margin: 0 0 var(--admin-block-gap);
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* One link, in the business's workspace: its title over tabs, one concern each. */
.admin-booking-link {
  display: flex;
  flex-direction: column;
  gap: var(--admin-gap);

  .admin-page-header,
  .admin-tabs {
    margin-bottom: 0;
  }

  .admin-breadcrumb {
    margin-bottom: 0.125rem;
  }

  h2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;

    .admin-badge-success,
    .admin-badge-muted {
      font-weight: var(--font-weight-medium);
    }
  }

  /* A table sits flush in its card, under the card's title. */
  .admin-detail-card-list .admin-metrics-table-wrap {
    margin: 0 calc(-1 * var(--admin-card-padding)) calc(-1 * var(--admin-card-padding));
    border: none;
    border-top: 1px solid var(--color-border);
    border-radius: 0 0 var(--admin-radius) var(--admin-radius);
  }

  .admin-stats {
    margin-bottom: 0;
  }

  .admin-danger-zone {
    margin-top: 0;
  }

  .admin-booking-link-url {
    overflow-wrap: anywhere;
  }

  .admin-metrics-table {
    th, td {
      padding: 0.5rem 1rem;
    }

    td {
      vertical-align: top;
      white-space: nowrap;
    }
  }
}

.admin-customers-plans,
.admin-booking-link-tabs {
  overflow-x: auto;
  scrollbar-width: none;

  .admin-tab {
    padding-inline: 0.75rem;
    white-space: nowrap;
  }

  .admin-tab-count {
    color: var(--color-muted);
    font-variant-numeric: tabular-nums;
  }
}

.admin-booking-link-detail {
  display: block;
  color: var(--color-text-light);
  font-size: var(--text-xs);
}

.admin-booking-link-preview-frame {
  display: block;
  width: 390px;
  max-width: 100%;
  height: 760px;
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  background: var(--color-bg-secondary);
}

.admin-booking-link-services-scope {
  margin-left: 0.375rem;
  font-size: var(--text-xs);
  font-weight: normal;
  color: var(--color-text-light);
}

.admin-link-address-aliases,
.admin-link-address-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: var(--text-sm);
}

.admin-link-address-alias {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.admin-link-address-event {
  display: flex;
  gap: 0.75rem;

  .admin-link-address-event-time {
    flex-shrink: 0;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
  }
}

.admin-link-address-takedown {
  max-width: 28rem;
}

/* Customer page: who it is in a sidebar, what they do and pay in the content beside it. */
.admin-customer-badges {
  display: flex;
  align-items: center;
  gap: 0.375rem;

  .admin-lifecycle-stage,
  .admin-subscription-badge {
    margin-left: 0;
  }
}

.admin-customer-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: var(--admin-section-gap);
  align-items: start;
}

.admin-customer-profile {
  position: sticky;
  top: calc(var(--admin-header-height) + var(--admin-block-gap));
  display: flex;
  flex-direction: column;
  gap: var(--admin-block-gap);
  min-width: 0;
}

.admin-customer-profile-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  h1 {
    margin: 0;
    font-size: var(--text-xl);
    overflow-wrap: anywhere;
  }
}

.admin-customer-actions {
  display: flex;
  gap: 0.5rem;

  > .btn {
    flex: 1;
  }
}

.admin-customer-profile-section {
  padding-top: var(--admin-block-gap);
  border-top: 1px solid var(--color-border);

  /* The column is narrow: each label sits over its value. */
  .admin-detail-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;

    dd + dt {
      margin-top: 0.5rem;
    }
  }

  h2 {
    margin: 0 0 0.5rem;
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}

.admin-customer-content {
  display: flex;
  flex-direction: column;
  gap: var(--admin-gap);
  min-width: 0;

  .admin-stats {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    margin-bottom: 0;
  }
}

/* A business's workspace (layouts/admin_customer): the name over its pages in a sidebar, the page
   beside it. */
.admin-workspace-layout {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  gap: var(--admin-section-gap);
  align-items: start;
}

.admin-workspace-sidebar {
  position: sticky;
  top: calc(var(--admin-header-height) + var(--admin-block-gap));
  display: flex;
  flex-direction: column;
  gap: var(--admin-block-gap);
  min-width: 0;
}

.admin-workspace-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding-inline: 0.625rem;

  .admin-breadcrumb {
    margin-bottom: 0;
  }

  h1 {
    margin: 0;
    font-size: var(--text-lg);
    overflow-wrap: anywhere;
  }
}

.admin-workspace-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-workspace-nav-group {
  list-style: none;
  margin: 0;
  padding: 0 0 0.5rem;
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    padding-bottom: 0;
    border-bottom: none;
  }
}

.admin-workspace-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.625rem;
  border-radius: 6px;
  color: var(--color-text-light);
  font-size: var(--text-sm);
  text-decoration: none;
  white-space: nowrap;

  svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
  }

  &.active {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    font-weight: var(--font-weight-medium);
  }
}

@media (hover: hover) {
  .admin-workspace-nav-item:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
  }
}

/* Every page stacks its blocks a gap apart, under a title quieter than the business's name. */
.admin-workspace-content {
  display: flex;
  flex-direction: column;
  gap: var(--admin-gap);
  min-width: 0;

  .admin-page-header {
    margin-bottom: var(--admin-gap);

    h2 {
      margin: 0;
      font-size: var(--text-base);
    }
  }

  /* The content's gap already spaces a page's own blocks. */
  > .admin-page-header {
    margin-bottom: 0;
  }

  .admin-page-header .btn svg,
  .admin-subscription-actions .btn svg {
    width: 14px;
    height: 14px;
  }

  .admin-stats {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    margin-bottom: 0;
  }

  .admin-stat-value {
    font-size: var(--text-xl);
  }

  .admin-stat-value-text {
    font-size: var(--text-base);
  }

  .admin-metrics-none {
    margin: 0;
    font-size: var(--text-sm);
  }
}

.admin-customer-settings {
  .admin-list-content {
    flex: 1;
  }

  form {
    margin: 0;
  }
}

.admin-customer-danger {
  margin-top: var(--admin-section-gap);
}

.admin-customer-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--admin-gap);
  align-items: start;
}

.admin-customer-identifiers {
  opacity: 0.8;
}

.admin-list-chevron {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--color-text-light);
}

.admin-adoption-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.admin-adoption-percentage {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-success);
  font-variant-numeric: tabular-nums;
}

.admin-adoption-bar {
  display: block;
  height: 6px;
  margin-bottom: 0.75rem;
  border-radius: 3px;
  background: var(--color-bg-secondary);
  overflow: hidden;
}

.admin-adoption-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--color-success);
}

.admin-detail-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.375rem 1rem;
  margin: 0;

  dt {
    font-size: var(--text-sm);
    color: var(--color-text-light);
  }

  dd {
    margin: 0;
    font-size: var(--text-sm);
    color: var(--color-text);
    word-break: break-word;
  }

  /* An identifier: smaller, and free to break anywhere in a narrow column. */
  .admin-code {
    font-size: var(--text-xs);
    overflow-wrap: anywhere;
  }
}

/* Danger Zone */
.admin-danger-zone {
  margin-top: var(--admin-section-gap);
  padding: var(--admin-card-padding);
  background: rgba(var(--color-danger-rgb), 0.05);
  border: 1px solid rgba(var(--color-danger-rgb), 0.2);
  border-radius: var(--admin-radius);

  h3 {
    margin: 0 0 0.5rem;
    font-size: var(--text-base);
    color: var(--color-danger);
  }

  p {
    margin: 0 0 1rem;
    font-size: var(--text-sm);
    color: var(--color-text-light);
  }
}

/* Form Styling */
.admin-form {
  max-width: 600px;
}

.admin-push-test-recipients {
  display: grid;
  gap: 0.75rem;

  .btn {
    width: 100%;
  }
}

.admin-form-section {
  margin-bottom: var(--admin-section-gap);

  h3 {
    margin: 0 0 0.75rem;
    font-size: var(--text-base);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
  }
}

.admin-form-field {
  margin-bottom: 0.75rem;

  label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    margin-bottom: 0.375rem;
    color: var(--color-text);
  }
}

.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.admin-form-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-base);
  background: var(--color-bg-primary);
  color: var(--color-text);

  &:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
  }
}

.admin-form-hint {
  margin: 0.375rem 0 0;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-form-errors {
  background: rgba(var(--color-danger-rgb), 0.1);
  border: 1px solid rgba(var(--color-danger-rgb), 0.2);
  border-radius: var(--admin-radius);
  padding: var(--admin-card-padding);
  margin-bottom: var(--admin-block-gap);

  h4 {
    margin: 0 0 0.5rem;
    font-size: var(--text-sm);
    color: var(--color-danger);
  }

  ul {
    margin: 0;
    padding-left: 1.25rem;
  }

  li {
    font-size: var(--text-sm);
    color: var(--color-danger);
  }
}

.admin-form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: var(--admin-section-gap);
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

/* Audit Filters */
.admin-audit-filters {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  padding: var(--admin-card-padding);
  margin-bottom: var(--admin-block-gap);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.admin-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-filter-label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.admin-filter-options {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-filter-option {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
}

.admin-filter-radio,
.admin-filter-checkbox {
  cursor: pointer;
}

.admin-filter-text {
  font-size: var(--text-sm);
  color: var(--color-text);
}

.admin-filter-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-sm);
  background: var(--color-bg-primary);
  color: var(--color-text);
  width: 120px;

  &:focus {
    outline: none;
    border-color: var(--color-primary);
  }
}

.admin-filter-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* Audit List */
.admin-audit-list {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-audit-row {
  display: grid;
  grid-template-columns: 80px 1fr 1fr 120px 100px;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  font-size: var(--text-sm);

  &:last-child {
    border-bottom: none;
  }

  &:hover {
    background: var(--color-bg-light);
  }
}

.admin-audit-col {
  min-width: 0;
}

.admin-audit-col-badge {
  display: flex;
}

.admin-audit-col-event {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.admin-audit-col-user {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.admin-audit-col-meta {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.admin-audit-col-time {
  text-align: right;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.admin-audit-event {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.admin-audit-method,
.admin-audit-target {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.admin-audit-user-name {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.admin-audit-user-id,
.admin-audit-user-email,
.admin-audit-user-phone,
.admin-audit-attempts {
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

.admin-audit-ip,
.admin-audit-delivery-status {
  font-family: monospace;
}

/* Audit Badges */
.admin-audit-badge {
  display: inline-flex;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
}

.admin-audit-badge-auth {
  background: rgba(59, 130, 246, 0.1);
  color: rgb(59, 130, 246);
}

.admin-audit-badge-phone {
  background: rgba(16, 185, 129, 0.1);
  color: rgb(16, 185, 129);
}

.admin-audit-badge-admin {
  background: rgba(139, 92, 246, 0.1);
  color: rgb(139, 92, 246);
}

.admin-audit-badge-billing {
  background: rgba(245, 158, 11, 0.1);
  color: rgb(180, 120, 10);
}

.admin-audit-badge-link {
  background: rgba(236, 72, 153, 0.1);
  color: rgb(190, 40, 110);
}

.admin-audit-particulars {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  overflow-wrap: anywhere;
}

/* Pagination */
.admin-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: var(--admin-block-gap);
  padding: 0;
}

.admin-pagination-link {
  color: var(--color-primary);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;

  &:hover {
    background: var(--color-bg-secondary);
  }
}

.admin-pagination-disabled {
  color: var(--color-muted);
  font-size: var(--text-sm);
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg-secondary);
}

.admin-pagination-info {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* Empty State */
.admin-empty-state {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);

  p {
    margin: 0;
    color: var(--color-text-light);
  }
}

/* Summary Page */
.admin-summary {
  h3 {
    font-size: var(--text-lg);
    margin: 0 0 0.75rem;
    color: var(--color-text);
  }
}

.admin-summary-period-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-sm);
  background: var(--color-bg-primary);
  color: var(--color-text);
  cursor: pointer;

  &:focus {
    outline: none;
    border-color: var(--color-primary);
  }
}

/* Summary dashboard: a 12-column panel grid, Grafana-style. A tile is two columns; the
   sections widen theirs (w3, w6) so each row fills. */
.admin-panels {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: var(--admin-block-gap);
}

.admin-panel {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
}

.admin-panel-w3 {
  grid-column: span 3;
}

.admin-panel-w4 {
  grid-column: span 4;
}

.admin-panel-w6 {
  grid-column: span 6;
}

.admin-panel-w9 {
  grid-column: span 9;
}

.admin-panel-w12 {
  grid-column: span 12;
}

/* A panel holding a table or a list: the content owns its own padding and borders. */
.admin-panel-table .admin-metrics-table-wrap {
  margin: 0.25rem 0 0;
}

.admin-top-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: top;
}

.admin-top-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: var(--text-sm);
  counter-increment: top;

  &::before {
    content: counter(top);
    min-width: 2ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: var(--font-weight-semibold);
    color: var(--color-muted);
  }

  &:last-child {
    border-bottom: none;
  }
}

.admin-top-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
  text-decoration: none;
}

.admin-top-count {
  font-size: var(--text-xs);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Cohort retention: the cell wash deepens with the share kept. */
.admin-cohort-cell-1 { background: color-mix(in srgb, var(--color-primary) 12%, transparent); }
.admin-cohort-cell-2 { background: color-mix(in srgb, var(--color-primary) 28%, transparent); }
.admin-cohort-cell-3 { background: color-mix(in srgb, var(--color-primary) 46%, transparent); color: var(--color-on-brand); }
.admin-cohort-cell-4 { background: color-mix(in srgb, var(--color-primary) 70%, transparent); color: var(--color-on-brand); }

.admin-metrics-row-total th,
.admin-metrics-row-total td {
  font-weight: var(--font-weight-semibold);
  background: var(--color-bg-secondary);
}

/* Threshold colours: the tile itself turns, not just the number, so it reads across the room. */
.admin-panel-warn {
  background: var(--color-warning-wash);
  border-color: var(--color-warning);

  .admin-panel-value {
    color: var(--color-warning-text);
  }
}

.admin-panel-bad {
  background: var(--color-danger-wash);
  border-color: var(--color-danger);

  .admin-panel-value {
    color: var(--color-danger-text);
  }
}

/* The title is also the positioning box for the help bubble, so it can outgrow the tile. */
.admin-summary .admin-panel-title {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-light);
}

.admin-panel-title-text {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-panel-icon {
  flex: none;
  width: 14px;
  height: 14px;
  color: var(--color-muted);
}

/* The icon doubles as the help trigger: a bare button, with the bubble hanging under the
   title's right edge. */
.admin-panel-help {
  display: inline-flex;
  flex: none;
  padding: 4px;
  margin: -4px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: inherit;
  cursor: help;

  &:focus-visible {
    outline: 2px solid var(--color-primary);
  }
}

.admin-panel-help-text {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-tooltip);
  width: max-content;
  max-width: min(280px, 80vw);
  padding: 0.5rem 0.625rem;
  border-radius: 6px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-normal);
  letter-spacing: 0;
  line-height: 1.4;
  text-transform: none;
  white-space: normal;
}

.admin-panel-value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.05;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.admin-metric-delta {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;

  &.positive {
    color: var(--color-success-text);
  }

  &.negative {
    color: var(--color-danger-text);
  }

  &.flat {
    color: var(--color-muted);
  }
}

.admin-panel-note,
.admin-panel-caption {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-panel-caption-centered {
  text-align: center;
}

/* Métricas de produto: the reading beside the value, and a tile that reads bad wears the
   warning wash, since bad there means act, still in band. */
.admin-reading {
  align-self: center;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  line-height: 1.4;
  white-space: nowrap;

  &.good {
    background: var(--color-success-wash);
    color: var(--color-success-text);
  }

  &.bad {
    background: var(--color-warning-wash);
    color: var(--color-warning-text);
  }

  &.neutral,
  &.thin {
    background: var(--color-bg-secondary);
    color: var(--color-muted);
  }
}

.admin-product-metric {
  &.bad {
    background: var(--color-warning-wash);
    border-color: var(--color-warning);
  }
}

.admin-product-trend {
  &.moved {
    color: var(--color-text-light);
  }
}

/* Period picker: a button naming the period over a panel of named periods beside a calendar. */
.admin-period-picker {
  position: relative;
}

.admin-period-picker-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-sm);
  background: var(--color-bg-primary);
  color: var(--color-text);
  cursor: pointer;

  .admin-period-picker-icon {
    width: 1rem;
    height: 1rem;
    color: var(--color-muted);
  }

  &[aria-expanded="true"] {
    border-color: var(--color-primary);
  }
}

.admin-period-picker-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-popup);
  display: grid;
  grid-template-columns: minmax(10rem, auto) 18rem;
  grid-template-rows: minmax(0, 1fr);
  height: min(30rem, 80vh);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-primary);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;

  @media (max-width: 640px) {
    right: auto;
    left: 0;
    width: calc(100vw - 2 * var(--content-padding));
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 8rem) minmax(0, 1fr);
    height: min(34rem, 55vh);
  }
}

.admin-period-picker-presets {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
  border-right: 1px solid var(--color-border);
  overflow-y: auto;

  @media (max-width: 640px) {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}

.admin-period-picker-preset {
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;

  &.active {
    background: var(--color-brand-wash);
    font-weight: var(--font-weight-semibold);
  }

  @media (hover: hover) {
    &:hover {
      background: var(--color-bg-secondary);
    }
  }
}

.admin-period-picker-custom {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  padding: 0.75rem;
}

.admin-period-picker-heading {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-period-picker-dates {
  display: flex;
  align-items: center;
  gap: 0.375rem;

  .admin-form-input {
    padding: 0.375rem 0.5rem;
    font-size: var(--text-sm);
  }
}

.admin-period-picker-calendar {
  position: relative;
  flex: 1;
  min-height: 12rem;
  overflow-y: auto;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.admin-period-picker-weekdays,
.admin-period-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
}

.admin-period-picker-weekdays {
  position: sticky;
  top: 0;
  padding: 0.25rem 0;
  background: var(--color-bg-primary);
  color: var(--color-muted);
}

.admin-period-picker-month {
  margin: 0.5rem 0 0.25rem;
  font-weight: var(--font-weight-semibold);
  text-transform: capitalize;
}

.admin-period-picker-day {
  height: 2rem;
  border: none;
  background: none;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;

  &.future {
    display: grid;
    place-items: center;
    color: var(--color-border-strong);
    cursor: default;
  }

  &.today {
    font-weight: var(--font-weight-semibold);
  }

  &.within {
    background: var(--color-brand-wash);
  }

  &.edge {
    border-radius: var(--radius-pill);
    background: var(--color-primary);
    color: var(--color-on-brand);
  }
}

.admin-period-picker-apply {
  align-self: flex-end;
}

.admin-sparkline-wrap {
  position: relative;
  margin-top: auto;
}

.admin-sparkline {
  display: block;
  width: 100%;
  height: 34px;
}

/* The hit column has to paint (transparently) to receive the pointer; the marker only shows
   while its day is hovered. */
.admin-sparkline-hit {
  fill: transparent;
}

.admin-sparkline-marker {
  stroke: var(--color-text);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  opacity: 0;
}

@media (hover: hover) {
  .admin-sparkline-day:hover .admin-sparkline-marker {
    opacity: 1;
  }
}

.admin-chart-tooltip {
  position: absolute;
  bottom: calc(100% + 4px);
  translate: -50% 0;
  z-index: var(--z-tooltip);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}

.admin-sparkline-area {
  fill: var(--color-brand-wash);
}

.admin-sparkline-line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

/* Uso do app (AppUsageQuery): a heat grid of areas or businesses by day, shaded like the cohort
   table, and a business's bars on the customer list. A cell's bubble shows over its own row. */
.admin-usage-grid {
  display: grid;
  grid-template-columns: fit-content(10rem) 1fr;
  gap: 3px 0.75rem;
}

/* Each row has its own bubble, so it is a box of its own; subgrid keeps the labels one column. */
.admin-usage-grid-row {
  position: relative;
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
}

.admin-usage-grid-label {
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--color-text-light);
  text-overflow: ellipsis;
  white-space: nowrap;

  a {
    color: inherit;
  }
}

.admin-usage-grid-cells {
  display: flex;
  gap: 2px;
}

.admin-usage-cell {
  flex: 1 1 0;
  min-width: 0;
  height: 16px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--color-muted) 16%, transparent);
}

.admin-usage-cell-1 { background: color-mix(in srgb, var(--color-primary) 14%, transparent); }
.admin-usage-cell-2 { background: color-mix(in srgb, var(--color-primary) 36%, transparent); }
.admin-usage-cell-3 { background: color-mix(in srgb, var(--color-primary) 62%, transparent); }
.admin-usage-cell-4 { background: var(--color-primary); }

@media (hover: hover) {
  .admin-usage-cell:hover {
    outline: 1px solid var(--color-text);
  }
}

.admin-usage-grid-axis {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-usage-grid-axis-ends {
  display: flex;
  justify-content: space-between;
}

.admin-app-usage-summary {
  margin: 0 0 0.75rem;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-app-usage-lead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
  font-size: var(--text-lg);
}

.admin-app-usage-totals {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-usage-bars {
  position: relative;
  display: flex;
  flex-shrink: 0;
  align-items: flex-end;
  gap: 1px;
  width: 8rem;
  height: 20px;
  margin-top: 0.375rem;
}

.admin-usage-bar {
  flex: 1 1 0;
  height: 1px;
  background: var(--color-border);

  &.visited {
    height: 3px;
    background: color-mix(in srgb, var(--color-primary) 36%, transparent);
  }

  &.acted {
    background: var(--color-primary);
  }
}

.admin-gauge {
  display: block;
  width: 100%;
  max-width: 150px;
  margin: 0.25rem auto 0;
}

.admin-gauge-track,
.admin-gauge-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.admin-gauge-track {
  stroke: var(--color-bg-tertiary);
}

.admin-gauge-fill {
  stroke: var(--color-success);
}

.admin-gauge-text {
  font-size: 15px;
  font-weight: var(--font-weight-bold);
  fill: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* Verifications by channel: one bar split by share, with a legend beneath. */
.admin-stack {
  display: flex;
  height: 10px;
  margin-top: auto;
  border-radius: 5px;
  background: var(--color-bg-tertiary);
  overflow: hidden;
}

.admin-stack-segment {
  display: block;
  height: 100%;
}

.admin-stack-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-stack-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.25rem;
  border-radius: 2px;
  vertical-align: middle;
}

.admin-stack-segment,
.admin-stack-swatch {
  background: var(--color-muted);

  &.admin-stack-sms,
  &.admin-stack-pwa {
    background: var(--color-primary);
  }

  &.admin-stack-whatsapp,
  &.admin-stack-browser {
    background: var(--color-success);
  }
}

/* A funnel as short bars: label, bar, count, and the drop from the step before. The bars tile
   (.admin-bars) shares the anatomy, with each row's share of one total in the last column. */
.admin-funnel,
.admin-bars {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.375rem 0.5rem;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-funnel-index {
  display: inline-block;
  min-width: 2ch;
  margin-right: 0.25rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
}

.admin-funnel-track,
.admin-bars-track {
  display: block;
  height: 10px;
  border-radius: 3px;
  background: var(--color-bg-tertiary);
  overflow: hidden;
}

.admin-funnel-fill,
.admin-bars-fill {
  display: block;
  height: 100%;
  background: var(--color-primary);
}

.admin-funnel-count,
.admin-bars-count {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.admin-funnel-drop,
.admin-bars-share {
  min-width: 3.5ch;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;

  &.admin-funnel-drop-steep {
    color: var(--color-danger-text);
  }
}

.admin-funnel-filter {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  color: var(--color-text-light);
  text-decoration: none;
  border-bottom: 1px dotted currentColor;

  &.active {
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
    border-bottom-style: solid;
  }
}

.admin-funnel-aside {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--color-border-light);
}

/* Summary data tab: one table per section. */
.admin-metrics-table-wrap {
  margin-bottom: var(--admin-block-gap);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  background: var(--color-bg-primary);
  overflow-x: auto;
}

.admin-metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);

  th, td {
    padding: 0.625rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
  }

  thead th {
    font-size: var(--text-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-light);
    background: var(--color-bg-secondary);
  }

  tbody th {
    font-weight: var(--font-weight-medium);
    color: var(--color-text);
  }

  tbody tr:last-child th,
  tbody tr:last-child td {
    border-bottom: none;
  }
}

.admin-metrics-row-sub th {
  padding-left: 2rem;
  font-weight: var(--font-weight-normal);
  color: var(--color-text-light);
}

/* Number columns hug their content at the right edge; the metric name takes the rest. */
.admin-metrics-table .admin-metrics-num {
  width: 1%;
  padding-left: 1.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.admin-metrics-none {
  color: var(--color-muted);
}

/* Personal data on a customer's page: masked, with an eye that reveals the one field. The eye
   keeps a touch-sized target but bleeds into the row's padding so the line stays text-height. */
.admin-personal-field {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.admin-personal-field-status {
  margin-inline-start: 0.5rem;
}

.admin-owner-whatsapp-form {
  margin-top: var(--admin-block-gap);
}

.admin-personal-field-form {
  display: inline-flex;
}

.admin-personal-field-reveal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: -0.5rem 0;
  padding: 0;
  color: var(--color-text-light);
  background: none;
  border: none;
  border-radius: var(--admin-radius);
  cursor: pointer;

  svg {
    width: 16px;
    height: 16px;
  }

  @media (hover: hover) {
    &:hover {
      color: var(--color-text);
    }
  }
}

/* A customer's appointments: every field of a row, its lines stacked inside the cell. */
.admin-appointments-table {
  td {
    vertical-align: top;
  }

  .admin-appointments-when {
    white-space: nowrap;
  }
}

.admin-appointments-service,
.admin-appointments-detail {
  display: block;
}

.admin-appointments-detail {
  font-size: var(--text-xs);
  white-space: nowrap;
  color: var(--color-text-light);
}

/* A Pedido's Análise do pedido, at the width of the phone the provider read it on. */
.admin-order-preview {
  max-width: 24rem;
}

/* A business's week: hour rows by day columns, each appointment a state chip by its number. */
.admin-agenda-grid {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--text-xs);

  th,
  td {
    border: 1px solid var(--color-border);
    padding: 0.25rem;
    vertical-align: top;
  }

  .admin-agenda-day {
    font-weight: 600;
    text-align: center;
  }

  .admin-agenda-working-hours {
    display: block;
    color: var(--color-text-light);
    font-weight: normal;
  }

  .admin-agenda-cell-closed {
    background: repeating-linear-gradient(-45deg, transparent 0 6px, var(--color-border-light) 6px 7px);
  }

  .admin-agenda-hour {
    width: 4.5rem;
    color: var(--color-text-light);
    font-weight: normal;
    text-align: right;
    white-space: nowrap;
  }
}

.admin-agenda-entry {
  display: block;
  margin-bottom: 0.25rem;
  padding: 0.25rem 0.375rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-state-pending-text);
  background: var(--color-state-pending-bg);
  box-shadow: inset 0 0 0 1.5px var(--color-state-pending-border);

  &:last-child {
    margin-bottom: 0;
  }

  .admin-agenda-entry-title,
  .admin-agenda-entry-time,
  .admin-agenda-entry-agenda {
    display: block;
  }

  .admin-agenda-entry-title {
    font-weight: 600;
  }

  &.admin-agenda-appointment-confirmed {
    color: var(--color-state-confirmed-text);
    background: var(--color-state-confirmed-bg);
    box-shadow: inset 0 0 0 1.5px var(--color-state-confirmed-border);
  }

  &.admin-agenda-appointment-in_progress {
    color: var(--color-state-in_progress-text);
    background: var(--color-state-in_progress-bg);
    box-shadow: inset 0 0 0 1.5px var(--color-state-in_progress-border);
  }

  &.admin-agenda-appointment-completed {
    color: var(--color-state-completed-text);
    background: var(--color-state-completed-bg);
    box-shadow: inset 0 0 0 1.5px var(--color-state-completed-border);
  }

  &.admin-agenda-appointment-cancelled,
  &.admin-agenda-appointment-rejected {
    color: var(--color-state-cancelled-text);
    background: var(--color-state-cancelled-bg);
    box-shadow: none;
    text-decoration: line-through;
  }

  &.admin-agenda-block {
    color: var(--color-muted);
    background: var(--color-bg-secondary);
    box-shadow: none;
  }
}

.admin-summary .admin-list {
  max-height: 400px;
  overflow-y: auto;
}

.admin-summary-lists {
  display: flex;
  gap: var(--admin-block-gap);

  > * {
    flex: 1;
    min-width: 0;
  }
}

.admin-summary-activity-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

/* Tabs */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--admin-block-gap);
}

.admin-tab {
  padding: 0.625rem 1rem;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;

  &:hover {
    color: var(--color-text);
  }

  &.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
  }
}

/* Adoption Checklist */
.admin-adoption-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-adoption-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-sm);
  color: var(--color-text-light);

  svg {
    width: 16px;
    height: 16px;
  }

  &.adopted {
    color: var(--color-success);
  }
}

/* Adoção, per person: the checklist is the business's, these are each person's. */
.admin-adoption-people {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--color-border);
  list-style: none;
}

.admin-adoption-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.5rem;
  font-size: var(--text-sm);
}

.admin-adoption-person-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

/* Mensagens: the heading links to the Jornada's Mensagem rows. */
.admin-messages-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.admin-messages-card-all {
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: normal;
}

/* Lifecycle Stage Badge */
.admin-lifecycle-stage {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  vertical-align: middle;
  margin-left: 0.5rem;
}

.admin-lifecycle-onboarding {
  background: rgba(245, 158, 11, 0.1);
  color: rgb(180, 120, 10);
}

.admin-lifecycle-setup {
  background: rgba(59, 130, 246, 0.1);
  color: rgb(59, 130, 246);
}

.admin-lifecycle-early_adopter {
  background: rgba(139, 92, 246, 0.1);
  color: rgb(139, 92, 246);
}

.admin-lifecycle-active {
  background: rgba(var(--color-success-rgb), 0.1);
  color: var(--color-success);
}

/* Subscription badge: the plan's situation on a business, in the list and on its page.
   Green is a plan being paid for, blue the free month, amber a plan on its way out,
   red a charge failing or the account read-only, gray a demo. */
.admin-subscription-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  vertical-align: middle;
  white-space: nowrap;

  .admin-page-header & {
    margin-left: 0.5rem;
  }

  &.subscribed,
  &.renewing {
    background: rgba(var(--color-success-rgb), 0.1);
    color: var(--color-success);
  }

  &.trialing,
  &.trialing_card {
    background: rgba(59, 130, 246, 0.1);
    color: rgb(59, 130, 246);
  }

  &.cancelling {
    background: rgba(245, 158, 11, 0.1);
    color: rgb(180, 120, 10);
  }

  &.past_due {
    background: rgba(var(--color-danger-rgb), 0.1);
    color: var(--color-danger);
  }

  &.free,
  &.demo {
    background: var(--color-bg-secondary);
    color: var(--color-muted);
  }
}

/* Error Tracking */
.admin-error-row {
  display: flex;
  align-items: center;
  padding: var(--admin-row-padding);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  gap: 0.75rem;

  &:last-child {
    border-bottom: none;
  }

  &:hover {
    background: var(--color-bg-light);
  }
}

.admin-error-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.admin-error-class {
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
}

.admin-error-message {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-error-source {
  font-family: monospace;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-error-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

.admin-error-count {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  color: var(--color-primary);
}

.admin-error-time {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-badge-open {
  background: rgba(var(--color-danger-rgb), 0.1);
  color: var(--color-danger);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
}

.admin-badge-resolved {
  background: rgba(var(--color-success-rgb), 0.1);
  color: var(--color-success);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
}

/* Backtrace */
.admin-backtrace {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow-x: auto;
  padding: 0.75rem;
  font-family: monospace;
  font-size: var(--text-xs);
  line-height: var(--line-height-xl);
}

.admin-backtrace-line {
  padding: 0.125rem 0.5rem;
  border-radius: 3px;
  white-space: nowrap;
}

.admin-backtrace-app {
  background: rgba(var(--color-primary-rgb), 0.08);
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
}

.admin-backtrace-gem {
  color: var(--color-muted);
}

/* Error Occurrence */
.admin-error-occurrence {
  padding: var(--admin-row-padding);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);

  &:last-child {
    border-bottom: none;
  }
}

.admin-error-occurrence-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-error-occurrence-meta {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Analytics */
.admin-analytics-table {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-analytics-table-header {
  display: grid;
  grid-template-columns: 1fr 100px 100px;
  gap: 1rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-analytics-table-row {
  display: grid;
  grid-template-columns: 1fr 100px 100px;
  gap: 1rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    border-bottom: none;
  }

  &:hover {
    background: var(--color-bg-light);
  }
}

.admin-analytics-path {
  font-family: monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Analytics Chart */
.admin-analytics-chart {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  padding: var(--admin-card-padding);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-analytics-bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 50px;
  gap: 0.75rem;
  align-items: center;
}

.admin-analytics-bar-label {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  text-align: right;
}

.admin-analytics-bar-track {
  height: 20px;
  background: var(--color-bg-secondary);
  border-radius: 4px;
  overflow: hidden;
}

.admin-analytics-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 4px;
  min-width: 2px;
}

.admin-analytics-bar-value {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

/* Analytics Filters */
.admin-analytics-filters {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Click to filter: every value on the page is a link, the active ones sit under the header */
.admin-analytics-filter-link {
  color: inherit;
  text-decoration: none;

  @media (hover: hover) {
    &:hover {
      text-decoration: underline;
    }
  }
}

.admin-analytics-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: -0.5rem 0 var(--admin-block-gap);

  .admin-analytics-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-bg-primary);
    color: var(--color-text);
    font-size: var(--text-sm);
    text-decoration: none;

    .admin-analytics-chip-label {
      color: var(--color-text-light);
    }

    .admin-analytics-chip-value {
      font-weight: var(--font-weight-medium);
    }

    .admin-analytics-chip-remove {
      width: 1rem;
      height: 1rem;
      color: var(--color-text-light);
    }

    &:active {
      background: var(--color-bg-light);
    }
  }

  .admin-analytics-chip-clear {
    font-size: var(--text-sm);
    color: var(--color-text-light);
  }
}

/* Daily Charts Grid */
.admin-daily-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--admin-block-gap);
}

/* Daily Traffic Vertical Bar Chart */
.admin-daily-traffic-section {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.admin-daily-chart {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  padding: var(--admin-card-padding);
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 180px;
  overflow-x: auto;
}

.admin-daily-column {
  flex: 1;
  min-width: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.admin-daily-count {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin-bottom: 0.25rem;
}

.admin-daily-bar {
  width: 100%;
  max-width: 32px;
  background: var(--color-primary);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.admin-daily-bar-latency {
  background: var(--color-warning-dark);
}

.admin-daily-date {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-top: 0.375rem;
  white-space: nowrap;
  min-height: 1em;
}

/* Analytics Columns */
.admin-analytics-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--admin-block-gap);
}

/* Visitor Locations */
.admin-locations {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-locations-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-locations-tab {
  flex: 1;
  padding: 0.625rem 1rem;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;

  &:hover {
    color: var(--color-text);
  }

  &.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
  }
}

.admin-locations-header {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 1rem;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  border-bottom: 1px solid var(--color-border);
}

.admin-locations-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);

  &:last-child {
    border-bottom: none;
  }
}

.admin-location-count {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* Scrollable Lists */
.admin-scrollable-list {
  overflow: hidden;
}

.admin-scrollable-content {
  max-height: 400px;
  overflow-y: auto;
}

/* Sessions Table */
.admin-sessions-table-header {
  display: grid;
  grid-template-columns: 1fr 110px 1fr 80px 80px 1fr 1fr 60px 70px;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-light);
}

.admin-sessions-table-row {
  display: grid;
  grid-template-columns: 1fr 110px 1fr 80px 80px 1fr 1fr 60px 70px;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);

  &:last-child {
    border-bottom: none;
  }

  &:hover {
    background: var(--color-bg-light);
  }
}

.admin-session-has-errors {
  border-left: 3px solid var(--color-danger);
}

/* Scanners */
.admin-section-help {
  margin: -0.5rem 0 1rem;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.admin-ai-traffic {
  h3 {
    margin: 1rem 0 0.5rem;
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-light);
  }
}

.admin-ai-referrals-table-header,
.admin-ai-referrals-table-row,
.admin-ai-agents-table-header,
.admin-ai-agents-table-row,
.admin-ai-pages-table-header,
.admin-ai-pages-table-row {
  display: grid;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
}

.admin-ai-referrals-table-header,
.admin-ai-referrals-table-row {
  grid-template-columns: 1fr 70px 70px 1.2fr;
}

.admin-ai-agents-table-header,
.admin-ai-agents-table-row {
  grid-template-columns: minmax(130px, 1.2fr) 80px 70px 1.2fr 1.5fr;
}

.admin-ai-pages-table-header,
.admin-ai-pages-table-row {
  grid-template-columns: 1fr 100px;
}

.admin-ai-referrals-table-header,
.admin-ai-agents-table-header,
.admin-ai-pages-table-header {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  background: var(--color-bg-light);
}

.admin-ai-referrals-table-row,
.admin-ai-agents-table-row,
.admin-ai-pages-table-row {
  &:last-child {
    border-bottom: none;
  }
}

.admin-ai-agent-answers {
  border-left: 3px solid var(--color-primary);
}

.admin-scanners-table-header,
.admin-scanners-table-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) 50px 1fr 1fr 80px 1.5fr 70px 1.4fr;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
}

.admin-scanners-table-header {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-light);
  background: var(--color-bg-light);
}

.admin-scanners-table-row {
  &:last-child {
    border-bottom: none;
  }
}

.admin-scanners-legitimate-row {
  border-left: 3px solid var(--color-success);
}

.admin-session-visitor,
.admin-scanners-ip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
}

.admin-session-scanner-ip,
.admin-session-scanner-probes,
.admin-session-bot-tells {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* The kind column: a badge for a scanner, an AI agent or a bot, plain muted text for a person. */
.admin-session-kind {
  white-space: nowrap;
}

.admin-session-kind-person {
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.admin-session-hash,
.admin-session-user-agent {
  word-break: break-all;
}

/* Session Detail */
.admin-session-timeline {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-session-entry {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: var(--admin-row-padding);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);

  &:last-child {
    border-bottom: none;
  }
}

.admin-session-entry-error {
  background: rgba(var(--color-danger-rgb), 0.05);
}

.admin-session-entry-time {
  color: var(--color-muted);
  font-size: var(--text-xs);
  flex-shrink: 0;
  min-width: 100px;
}

.admin-session-entry-method {
  font-weight: var(--font-weight-medium);
  flex-shrink: 0;
  min-width: 40px;
}

.admin-session-entry-path {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-session-entry-referrer,
.admin-session-entry-accept,
.admin-session-entry-message {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-text-light);
  font-size: var(--text-xs);
}

.admin-session-entry-status {
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

.admin-session-entry-response {
  flex-shrink: 0;
  min-width: 50px;
  text-align: right;
  color: var(--color-text-light);
}

.admin-session-error-link,
.admin-error-session-link {
  color: var(--color-primary);
  text-decoration: none;
  flex-shrink: 0;

  &:hover {
    text-decoration: underline;
  }
}

/* The phone rules sit last on purpose: they override the desktop declarations above, which
   share their specificity. */
/* Phone chrome — below the app's own desktop line the header keeps only the lockup and the
   floating tab bar (mobile.css) takes over navigation, with the Menu tab opening a drawer. */
@media (max-width: 1023px) {
  .admin-header {
    height: var(--admin-header-height);
  }

  .admin-nav {
    height: 100%;
    padding: 0 var(--content-padding);
    gap: 1rem;
  }

  .admin-nav-links,
  .admin-nav-user {
    display: none;
  }

  .admin-nav-refresh {
    display: flex;
  }

  .admin-main {
    padding: var(--content-padding);
    padding-bottom: calc(var(--content-padding) + var(--nav-bar-height));
  }

  /* One column: the name and actions on top, the content, then the profile facts. */
  .admin-customer-layout {
    grid-template-columns: 1fr;
  }

  .admin-customer-profile {
    display: contents;
  }

  .admin-customer-profile-section {
    order: 1;
  }

  .admin-customer-pair {
    grid-template-columns: 1fr;
  }

  /* A screen that manages its own edges and scrolling (the WhatsApp list and chat). */
  .admin-main--flush {
    padding: 0;
  }

  /* WhatsApp is two screens here: the list, or the chat alone once one is opened. Each
     fills the viewport under the header and scrolls inside itself, so the page never does. */
  .admin-whatsapp {
    display: block;
    /* keyboard-fit sets --visual-viewport-height while the keyboard is up, so the chat and its
       composer shrink to the visible area instead of sliding under the keyboard. */
    height: calc(var(--visual-viewport-height, 100dvh) - var(--admin-header-height));
    border: none;
    border-radius: 0;
  }

  .admin-whatsapp-sidebar {
    height: 100%;
    border-right: none;
  }

  .admin-whatsapp-contacts {
    padding-bottom: var(--nav-bar-height);
  }

  .admin-whatsapp-main {
    display: none;
    height: 100%;
  }

  .admin-whatsapp--opened {
    .admin-whatsapp-sidebar {
      display: none;
    }

    .admin-whatsapp-main {
      display: flex;
    }
  }

  .admin-whatsapp-chat-back {
    display: flex;
  }

  .admin-whatsapp-chat-header {
    gap: 0.625rem;
    padding: 0.375rem var(--content-padding) 0.375rem;
  }

  .admin-whatsapp-chat-avatar {
    width: 40px;
    height: 40px;
    font-size: var(--text-base);
  }

  .admin-whatsapp-chat-info {
    min-width: 0;

    h3 {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  /* The pill hides its label on the phone: the clock or bell alone says it. */
  .admin-whatsapp-window-info,
  .admin-whatsapp-optout-info {
    padding: 0.375rem;

    span {
      display: none;
    }
  }

  .admin-whatsapp-message {
    max-width: 85%;
  }

  /* The header button keeps its icon; the modal fills the screen and its columns stack. */
  .admin-whatsapp-template-open span {
    display: none;
  }

  .admin-whatsapp-template-modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: none;
    border-radius: 0;
  }

  .admin-whatsapp-composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-whatsapp-composer-templates {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .admin-whatsapp-composer-template {
    flex: none;
  }

  .admin-whatsapp-composer-preview {
    border-left: none;
    padding-bottom: calc(1rem + var(--safe-bottom));
  }

  .admin-whatsapp-chat-footer {
    padding: 0.5rem var(--content-padding) calc(0.5rem + var(--safe-bottom));
  }
}

/* Phone screens — every panel's first pass at a narrow viewport. */
@media (max-width: 768px) {
  .admin-page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: var(--admin-block-gap);

    h1 {
      font-size: var(--text-lg);
    }
  }

  .admin-page-actions {
    flex-wrap: wrap;
  }

  /* Period and audience pickers stretch across the row instead of dangling after the title. */
  .admin-analytics-filters {
    flex-wrap: wrap;
    gap: 0.5rem;

    .admin-summary-period-select {
      flex: 1;
      min-height: 44px;
    }
  }

  .admin-breadcrumb {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Stat cards: two to a row, always filling the width; an odd last card stretches across
     the row instead of leaving a hole beside it. */
  .admin-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: var(--admin-block-gap);
  }

  .admin-stat-card {
    padding: 0.75rem 0.75rem 0.625rem;

    &:last-child:nth-child(odd) {
      grid-column: 1 / -1;
    }
  }

  .admin-stat-card-table {
    grid-column: 1 / -1;
  }

  .admin-section {
    margin-top: var(--admin-section-gap);

    h2 {
      font-size: var(--text-base);
    }
  }

  /* Panels: two to a row; the wide ones take the whole row. */
  .admin-panel {
    grid-column: span 6;
  }

  .admin-panel-w6,
  .admin-panel-w12,
  .admin-panel-funnel,
  .admin-panel-bars {
    grid-column: span 12;
  }

  .admin-metrics-table {
    th, td {
      padding: 0.625rem 0.75rem;
    }

    .admin-metrics-num {
      padding-left: 0.5rem;
    }

    thead th {
      letter-spacing: 0;
    }
  }

  .admin-metrics-row-sub th {
    padding-left: 1.5rem;
  }

  .admin-summary-lists {
    flex-direction: column;
  }

  .admin-summary .admin-list {
    max-height: none;
  }

  /* List rows: name and detail on the first line with the time at the right, the extra
     info (phone, date) on a line of its own beneath. */
  .admin-list-link,
  .admin-list-static {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.75rem;
    align-items: start;
    padding: 0.75rem var(--content-padding);
  }

  .admin-list-info {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    font-size: var(--text-xs);
  }

  .admin-list-meta,
  .admin-list-static > .admin-list-tag {
    grid-column: 2;
    grid-row: 1;
    margin-left: 0;
    white-space: nowrap;
  }

  .admin-list-secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;

    .admin-list-tag {
      margin-left: 0;
    }
  }

  .admin-tabs {
    margin-bottom: var(--admin-block-gap);
  }

  .admin-tab {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
  }

  /* Search: the field takes the row, its buttons share the next one. */
  .admin-search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    margin-bottom: var(--admin-block-gap);
  }

  .admin-search-input-wrapper {
    grid-column: 1 / -1;
  }

  .admin-form-row {
    grid-template-columns: 1fr;
  }

  .admin-form-actions {
    flex-direction: column;

    .btn {
      width: 100%;
    }
  }

  .admin-audit-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    padding: var(--admin-card-padding);
  }

  .admin-filter-input {
    width: 100%;
  }

  .admin-filter-actions {
    margin-left: 0;

    > * {
      flex: 1;
    }
  }

  /* Audit rows fold from five columns to two lines: badge beside event and time, then the
     actor and its address beneath. */
  .admin-audit-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "badge event time"
      "badge user meta";
    gap: 0.25rem 0.75rem;
    align-items: start;
  }

  .admin-audit-col-badge {
    grid-area: badge;
  }

  .admin-audit-col-event {
    grid-area: event;
  }

  .admin-audit-col-user {
    grid-area: user;
  }

  .admin-audit-col-meta {
    grid-area: meta;
    text-align: right;
  }

  .admin-audit-col-time {
    grid-area: time;
  }

  .admin-detail-grid {
    grid-template-columns: 1fr;
    gap: var(--admin-gap);
    margin-bottom: var(--admin-block-gap);
  }

  .admin-detail-card {
    padding: var(--admin-card-padding);

    h3 {
      font-size: var(--text-base);
      margin-bottom: 0.75rem;
    }
  }

  /* Definition lists stack label over value — a long label beside a UUID had neither room. */
  .admin-detail-list {
    grid-template-columns: 1fr;
    gap: 0.125rem;

    dt {
      margin-top: 0.625rem;
      font-size: var(--text-xs);

      &:first-child {
        margin-top: 0;
      }
    }
  }

  .admin-danger-zone {
    margin-top: var(--admin-section-gap);
    padding: var(--admin-card-padding);

    .btn {
      width: 100%;
    }
  }


  .admin-analytics-columns,
  .admin-daily-charts-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .admin-analytics-table-header,
  .admin-analytics-table-row {
    grid-template-columns: 1fr auto auto;
  }

  .admin-analytics-bar-row {
    grid-template-columns: 72px 1fr 40px;
  }

  .admin-daily-chart {
    padding: 0.75rem 0.5rem;
  }

  .admin-daily-count,
  .admin-daily-date {
    font-size: 10px;
  }

  .admin-sessions-table-header,
  .admin-sessions-table-row {
    grid-template-columns: 1fr 90px 1fr 60px 60px;
  }

  .admin-sessions-table-header span:nth-child(3),
  .admin-sessions-table-header span:nth-child(4),
  .admin-sessions-table-header span:nth-child(5),
  .admin-sessions-table-header span:nth-child(7),
  .admin-sessions-table-row > span:nth-child(3),
  .admin-sessions-table-row > span:nth-child(4),
  .admin-sessions-table-row > span:nth-child(5),
  .admin-sessions-table-row > span:nth-child(7) {
    display: none;
  }

  .admin-scanners-table-header,
  .admin-scanners-table-row {
    grid-template-columns: 1fr 1fr 60px 1fr;
  }

  .admin-ai-referrals-table-header,
  .admin-ai-referrals-table-row {
    grid-template-columns: 1fr 60px 60px;
  }

  .admin-ai-agents-table-header,
  .admin-ai-agents-table-row {
    grid-template-columns: 1fr 80px 60px;
  }

  .admin-ai-referrals-table-header span:nth-child(4),
  .admin-ai-referrals-table-row span:nth-child(4),
  .admin-ai-agents-table-header span:nth-child(4),
  .admin-ai-agents-table-header span:nth-child(5),
  .admin-ai-agents-table-row span:nth-child(4),
  .admin-ai-agents-table-row span:nth-child(5) {
    display: none;
  }

  .admin-scanners-table-header span:nth-child(2),
  .admin-scanners-table-header span:nth-child(3),
  .admin-scanners-table-header span:nth-child(5),
  .admin-scanners-table-header span:nth-child(6),
  .admin-scanners-table-row > span:nth-child(2),
  .admin-scanners-table-row > span:nth-child(3),
  .admin-scanners-table-row > span:nth-child(5),
  .admin-scanners-table-row > span:nth-child(6) {
    display: none;
  }

  .admin-session-entry {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }

  .admin-session-entry-time {
    min-width: 0;
    flex-basis: 100%;
  }

  .admin-error-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .admin-error-message {
    white-space: normal;
  }

  .admin-error-meta {
    margin-left: 0;
    justify-content: space-between;
  }

  .admin-error-count {
    font-size: var(--text-base);
  }
}

/* Menu drawer — the panels behind the Menu tab, then alerts, theme and, past the fold,
   signing out. Rows drop their dividers: the single rule above the device rows groups enough. */
.admin-menu {
  padding: var(--section-label-gap) 0 calc(var(--content-padding) + var(--safe-bottom));

  .list-row {
    border-bottom: none;
  }

  .page-section-divider {
    margin: 8px var(--content-padding);
  }

  .settings-logout-section {
    margin-top: 32px;
  }
}

.admin-menu-row.active {
  color: var(--color-primary);

  .row-icon {
    color: var(--color-primary);
  }
}

/* Alerts settings — one card holding the toggle row. */
.admin-notifications-card {
  padding: 0;
  max-width: 600px;

  .list-row {
    border-bottom: none;
  }
}

/* Mensageria — a channel's heading opens its page. */
.admin-messaging-channel-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: inherit;
  text-decoration: none;
}

.admin-messaging-channel-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-muted);
}

.admin-in-app-message-versions {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Mensagens no app: a goal's heading carries its sums. */
.admin-in-app-goal-counts {
  margin-inline-start: 0.5rem;
  font-size: var(--text-sm);
  font-weight: normal;
  color: var(--color-muted);
}

/* Aquisição: the drill-down trail and the step tables. */
.admin-acquisition-trail {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* Compact: a row per line, each step's rate beside its count. */
.admin-acquisition-steps,
.admin-acquisition-changes {
  th, td {
    padding: 0.375rem 0.75rem;
  }

  thead th {
    padding-block: 0.5rem;
  }

  .admin-metrics-num {
    padding-left: 1rem;
  }
}

.admin-acquisition-steps {
  /* A fixed width keeps the counts in a column whatever their rates read. */
  .admin-acquisition-rate {
    display: inline-block;
    min-width: 3.25em;
    margin-left: 0.375rem;
    text-align: left;
    font-size: var(--text-xs);
    color: var(--color-text-light);
  }

  .admin-acquisition-total {
    th, td {
      font-weight: var(--font-weight-semibold);
      border-top: 1px solid var(--color-border);
    }
  }
}

/* A section title with an info icon that opens its explanation; the bubble hangs under the
   title's start. */
.admin-acquisition-title {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;

  &.admin-acquisition-subtitle {
    margin: 1.25rem 0 0.75rem;
    font-size: var(--text-base);
  }

  .admin-acquisition-title-icon {
    width: 1rem;
    height: 1rem;
    color: var(--color-muted);
  }

  .admin-panel-help-text {
    right: auto;
    left: 0;
  }
}

/* The funnel: a column per step, the step before faded behind it. */
.admin-acquisition-funnel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.5rem;
  font-size: var(--text-sm);
}

.admin-acquisition-funnel-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  text-align: center;
}

.admin-acquisition-funnel-rate {
  min-height: 1.25em;
  font-size: var(--text-xs);
  color: var(--color-text-light);
  font-variant-numeric: tabular-nums;
}

.admin-acquisition-funnel-plot {
  position: relative;
  width: 100%;
  height: 9rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-acquisition-funnel-before,
.admin-acquisition-funnel-bar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  border-radius: 3px 3px 0 0;
}

.admin-acquisition-funnel-before {
  background: var(--color-bg-tertiary);
}

.admin-acquisition-funnel-bar {
  min-height: 1px;
  background: var(--color-primary);
}

.admin-acquisition-funnel-count {
  font-weight: var(--font-weight-semibold);
  font-variant-numeric: tabular-nums;
}

.admin-acquisition-funnel-label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  overflow-wrap: anywhere;
}

/* A count by the last touch, beside the first's where they differ. */
.admin-acquisition-last {
  margin-left: 0.25rem;
  font-size: var(--text-xs);
  color: var(--color-text-light);
}

/* A section title with actions beside it. */
.admin-acquisition-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;

  h2 {
    margin: 0;
  }
}

.admin-acquisition-tree-actions {
  display: flex;
  gap: 0.5rem;
}

/* The channel tree: each level indented under its parent, a chevron that folds it. */
.admin-acquisition-tree {
  tr > :first-child {
    padding-left: 2rem;
  }

  .admin-acquisition-depth-1 > th {
    padding-left: 3.25rem;
  }

  .admin-acquisition-depth-2 > th {
    padding-left: 4.5rem;
  }

  .admin-acquisition-depth-1,
  .admin-acquisition-depth-2 {
    th, td {
      color: var(--color-text-light);
    }
  }
}

.admin-acquisition-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: -1.25rem;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;

  &[aria-expanded="false"] .admin-acquisition-toggle-icon {
    rotate: -90deg;
  }
}

.admin-acquisition-toggle-icon {
  width: 1rem;
  height: 1rem;
  color: var(--color-muted);
  transition: rotate 150ms;

  @media (prefers-reduced-motion: reduce) {
    transition: none;
  }
}

.admin-acquisition-open {
  width: 2.5rem;
  text-align: center;
}

.admin-acquisition-open-link {
  display: inline-flex;
  color: var(--color-muted);
}

@media (hover: hover) {
  .admin-acquisition-open-link:hover {
    color: var(--color-link);
  }
}

.admin-acquisition-open-icon {
  width: 1rem;
  height: 1rem;
}

/* Channel shades: the brand mixed toward the ink and toward the ground, neighbours in the stack
   order far apart on that ramp; Direto and Desconhecido are chrome gray. */
.admin-acquisition-channel-campaign { --channel-color: var(--color-primary); }
.admin-acquisition-channel-booking_link { --channel-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-bg)); }
.admin-acquisition-channel-ai { --channel-color: color-mix(in srgb, var(--color-primary) 55%, var(--color-text)); }
.admin-acquisition-channel-search { --channel-color: color-mix(in srgb, var(--color-primary) 25%, var(--color-bg)); }
.admin-acquisition-channel-social { --channel-color: color-mix(in srgb, var(--color-primary) 78%, var(--color-text)); }
.admin-acquisition-channel-partners { --channel-color: color-mix(in srgb, var(--color-primary) 72%, var(--color-bg)); }
.admin-acquisition-channel-other_sites { --channel-color: color-mix(in srgb, var(--color-primary) 38%, var(--color-bg)); }
.admin-acquisition-channel-direct { --channel-color: var(--color-muted); }
.admin-acquisition-channel-unknown { --channel-color: var(--color-border-strong); }

/* Two charts side by side on a wide screen, stacked on a narrow one. */
.admin-acquisition-charts {
  display: grid;
  gap: 0 var(--admin-section-gap);

  @media (min-width: 1024px) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.admin-acquisition-conversion {
  grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr);
  column-gap: 1rem;
  font-size: var(--text-sm);
}

.admin-acquisition-conversion-head {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-acquisition-conversion-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.5rem;
}

/* Line chart: a line per measure over a row of hover columns, a bucket each. */
.admin-line-chart {
  position: relative;
  font-size: var(--text-sm);
}

.admin-line-chart-plot {
  position: relative;
  height: 8rem;
  border-bottom: 1px solid var(--color-border);
}

.admin-line-chart-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.admin-line-chart-line {
  fill: none;
  stroke: var(--channel-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.admin-line-chart-visitors { --channel-color: var(--color-muted); }
.admin-line-chart-accounts { --channel-color: var(--color-primary); }

/* Qualidade dos endereços: green for a pin on the house, amber as it gets coarser, gray where the
   pin's precision was never recorded. */
.admin-address-quality-pins-house { --channel-color: var(--color-success); }
.admin-address-quality-pins-street { --channel-color: var(--color-warning); }
.admin-address-quality-pins-area { --channel-color: var(--color-warning-text); }
.admin-address-quality-pins-unknown { --channel-color: var(--color-border-strong); }
.admin-address-quality-pins-none { --channel-color: var(--color-muted); }
.admin-address-quality-entries-suggestion { --channel-color: var(--color-primary); }
.admin-address-quality-entries-cep { --channel-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-bg)); }
.admin-address-quality-entries-typed { --channel-color: var(--color-muted); }

/* Dependências: a line per service with failures, told apart by position. */
.admin-dependencies-line-0 { --channel-color: var(--color-primary); }
.admin-dependencies-line-1 { --channel-color: var(--color-warning); }
.admin-dependencies-line-2 { --channel-color: var(--color-success); }
.admin-dependencies-line-3 { --channel-color: var(--color-muted); }
.admin-dependencies-line-4 { --channel-color: color-mix(in srgb, var(--color-primary) 50%, var(--color-bg)); }

/* The score's tile spans the row, so the page reads by one number first. */
.admin-address-quality-score .admin-product-metric {
  grid-column: 1 / -1;
}

.admin-address-quality-area-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-line-chart-columns {
  position: absolute;
  inset: 0;
  display: flex;
}

.admin-line-chart-column {
  display: flex;
  flex: 1;
  justify-content: center;
}

.admin-line-chart-marker {
  width: 1px;
  background: var(--color-text);
  opacity: 0;
}

@media (hover: hover) {
  .admin-line-chart-column:hover .admin-line-chart-marker {
    opacity: 0.3;
  }
}

/* The channel filter: a button over a menu of ticked channels. */
.admin-acquisition-channel-filter {
  position: relative;
}

.admin-acquisition-channel-filter-count {
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}

.admin-acquisition-channel-filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: var(--z-popup);
  display: flex;
  flex-direction: column;
  min-width: 12rem;
  padding: 0.25rem 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-primary);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.25);
}

.admin-acquisition-channel-filter-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.75rem;
  font-size: var(--text-sm);
  cursor: pointer;
}

.admin-line-chart-axis {
  display: flex;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-acquisition-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--color-text-light);

  li {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
  }
}

.admin-acquisition-swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  background: var(--channel-color);
}

.admin-acquisition-legend-count {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}

/* First-to-last flow: labels either side of a canvas the bands stretch across. */
.admin-acquisition-flow {
  position: relative;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  gap: 0.5rem 0.75rem;
  font-size: var(--text-sm);
}

.admin-acquisition-flow-head {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-acquisition-flow-last {
  text-align: right;
}

.admin-acquisition-flow-labels {
  position: relative;
  min-width: 12rem;
  height: var(--flow-height, 16rem);
}

.admin-acquisition-flow-label {
  position: absolute;
  inset-inline: 0;
  translate: 0 -50%;
  white-space: nowrap;
  line-height: 1.2;
}

.admin-acquisition-flow-chart {
  display: block;
  width: 100%;
  height: var(--flow-height, 16rem);
}

.admin-acquisition-flow-node {
  fill: var(--channel-color);
}

.admin-acquisition-flow-band path {
  fill: var(--channel-color);
  opacity: 0.45;
}

@media (hover: hover) {
  .admin-acquisition-flow-band:hover path {
    opacity: 0.8;
  }
}

/* Spend rows: campaign, the amount and dates' form, removal; a head row names the fields and
   the last row adds one. */
.admin-acquisition-spends {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 960px;
}

.admin-acquisition-spend {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 3fr) 6rem;
  gap: 0.5rem;
  align-items: center;
  font-size: var(--text-sm);

  .admin-form-input {
    min-width: 0;
  }
}

.admin-acquisition-spend-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 6rem;
  gap: 0.5rem;
  align-items: center;
}

.admin-acquisition-spend-head {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.admin-acquisition-spend-new {
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.admin-acquisition-campaigns-period {
  margin-bottom: 0.5rem;
}

@media (max-width: 640px) {
  .admin-acquisition-spend {
    grid-template-columns: 1fr;
  }

  .admin-acquisition-spend-head {
    display: none;
  }
}

/* Jornada: a business's sessions, newest first, each a list of typed rows with the milestones
   between them. */
.admin-journey-origin {
  margin-bottom: var(--admin-block-gap);
}

.admin-journey-sessions {
  display: flex;
  flex-direction: column;
  gap: var(--admin-gap);
  margin-bottom: var(--admin-block-gap);
}

.admin-journey-session {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
}

.admin-journey-session-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: var(--admin-row-padding);
  background: var(--color-bg-secondary);
  font-size: var(--text-sm);
}

.admin-journey-session-day,
.admin-journey-session-person {
  font-weight: var(--font-weight-semibold);
}

.admin-journey-session-device,
.admin-journey-session-duration {
  color: var(--color-text-light);
  font-size: var(--text-xs);
}

.admin-journey-entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-journey-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: var(--admin-row-padding);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.admin-journey-row-time {
  flex-shrink: 0;
  min-width: 5rem;
  color: var(--color-muted);
  font-size: var(--text-xs);
}

.admin-journey-type {
  flex-shrink: 0;
  min-width: 6rem;
  color: var(--color-text-light);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Below its basis the body takes a line of its own under the time and the type. */
.admin-journey-row-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  flex: 1 1 16rem;
  min-width: 0;
}

.admin-journey-detail,
.admin-journey-actor {
  color: var(--color-text-light);
  font-size: var(--text-xs);
}

.admin-journey-milestone {
  padding: 0.5rem var(--admin-card-padding);
  border-top: 2px solid var(--color-success);
  color: var(--color-success);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-journey-milestone-tracking_started {
  border-top-color: var(--color-border);
  color: var(--color-muted);
}

.admin-journey-record,
.admin-journey-link {
  color: var(--color-primary);
  text-decoration: none;

  @media (hover: hover) {
    &:hover {
      text-decoration: underline;
    }
  }
}

.admin-whatsapp-availability {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.75rem;

  &.available .admin-whatsapp-availability-status::before {
    background: var(--color-success);
  }
}

.admin-whatsapp-availability-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);

  &::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-muted);
  }
}

.admin-whatsapp-availability-hint {
  width: 100%;
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* The workspace's sidebar becomes a row of tabs that scrolls sideways, edge to edge. */
@media (max-width: 1023px) {
  .admin-workspace-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-workspace-sidebar {
    position: static;
  }

  .admin-workspace-header {
    padding-inline: 0;
  }

  /* A page's title keeps its one action beside it. */
  .admin-workspace-content .admin-page-header {
    flex-direction: row;
    align-items: center;
  }

  .admin-workspace-nav {
    flex-direction: row;
    gap: 0;
    margin: 0 calc(-1 * var(--content-padding));
    padding: 0 var(--content-padding);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
    scrollbar-width: none;
  }

  .admin-workspace-nav-group {
    display: flex;
    padding: 0;
    border-bottom: none;
  }

  .admin-workspace-nav-item {
    min-height: 44px;
    padding: 0 0.75rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;

    svg {
      display: none;
    }

    &.active {
      background: none;
      color: var(--color-primary);
      border-bottom-color: var(--color-primary);
    }
  }
}
