/* Platform-admin surface (/admin). Semantic classes on the app's design
   tokens (base.css); deliberately simpler chrome than the workspace shell. */

body.admin-page {
  background: var(--agent-bg);
}

.admin-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-shell__topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.625rem 1.5rem;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-shell__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-shell__title {
  font-weight: 600;
  font-size: var(--text-ui-md);
  color: var(--foreground);
  text-decoration: none;
}

.admin-shell__env {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.4375rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.admin-shell__tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.admin-shell__tab {
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: var(--text-ui-base);
  color: var(--muted-foreground);
  text-decoration: none;
}

.admin-shell__tab:hover {
  background: var(--muted);
  color: var(--foreground);
}

.admin-shell__tab--active {
  background: var(--accent);
  color: var(--accent-foreground);
  font-weight: 500;
}

.admin-shell__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-shell__user-label {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
}

.admin-shell__sign-out {
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--agent-line);
  border-radius: 0.45rem;
  background: var(--agent-surface);
  color: var(--agent-body);
  font-size: var(--text-ui-sm);
  cursor: pointer;
}

.admin-shell__sign-out:hover {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.admin-shell__main {
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

.admin-security-section-header,
.admin-security-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem;
}

.admin-security-actions {
  justify-content: flex-start;
  margin-top: 1rem;
  padding: 0;
}

.admin-recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.5rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.admin-recovery-codes code {
  display: block;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--agent-line);
  border-radius: 0.5rem;
  background: var(--agent-sunken);
  color: var(--agent-text);
}

.admin-flash {
  padding: 0.625rem 0.875rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  font-size: var(--text-ui-base);
  background: var(--agent-green);
  color: var(--agent-green-text);
  border: 1px solid #bde5cd;
}

.admin-flash--alert {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.admin-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.admin-page-header__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.admin-page-header__subtitle {
  margin: 0.25rem 0 0;
  font-size: var(--text-ui-base);
  color: var(--muted-foreground);
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.admin-stat-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
}

.admin-stat-card__label {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
}

.admin-stat-card__value {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 0.125rem;
}

.admin-stat-card__hint {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
  margin-top: 0.125rem;
}

.admin-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
  margin-bottom: 1.25rem;
}

.admin-filters__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.admin-filters__label {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
}

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

.admin-input {
  font: inherit;
  font-size: var(--text-ui-base);
  padding: 0.375rem 0.625rem;
  border: 1px solid var(--input);
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--foreground);
  min-width: 9rem;
}

.admin-input:focus {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.admin-button {
  font: inherit;
  font-size: var(--text-ui-base);
  font-weight: 500;
  padding: 0.375rem 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.admin-button:hover {
  opacity: 0.9;
}

.admin-button--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--foreground);
}

.admin-button--ghost:hover {
  background: var(--muted);
  opacity: 1;
}

.admin-table-wrap {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-ui-base);
}

.admin-table th {
  text-align: left;
  font-weight: 500;
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--agent-soft);
  white-space: nowrap;
}

.admin-table td {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: var(--agent-soft);
}

.admin-table__nowrap {
  white-space: nowrap;
}

.admin-table__meta {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
}

.admin-table__reason {
  max-width: 18rem;
}

.admin-code {
  font-size: 0.8125rem;
  background: var(--muted);
  padding: 0.0625rem 0.375rem;
  border-radius: 0.375rem;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  border: 1px solid transparent;
  text-transform: capitalize;
}

.admin-badge--success {
  background: var(--agent-green);
  color: var(--agent-green-text);
  border-color: #bde5cd;
}

.admin-badge--warning {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

.admin-badge--danger {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.admin-badge--info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.admin-badge--neutral {
  background: var(--muted);
  color: var(--muted-foreground);
  border-color: var(--border);
}

.admin-empty {
  text-align: center;
  color: var(--muted-foreground);
  font-size: var(--text-ui-base);
  padding: 3rem 1rem;
  background: var(--background);
  border: 1px dashed var(--border);
  border-radius: 0.75rem;
}

.admin-detail summary {
  cursor: pointer;
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
}

.admin-detail__json {
  font-size: 0.75rem;
  background: var(--agent-soft);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.5rem;
  max-width: 24rem;
  max-height: 16rem;
  overflow: auto;
  margin: 0.375rem 0 0;
}

.admin-pagination {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.875rem;
}

.admin-page-header__badges {
  display: flex;
  gap: 0.375rem;
  align-items: center;
}

.admin-table__link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.admin-table__link:hover div:first-child {
  text-decoration: underline;
}

.admin-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(24rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.admin-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.admin-card--narrow {
  max-width: 34rem;
}

.admin-card__title {
  font-size: var(--text-ui-md);
  font-weight: 600;
  margin: 0.75rem 0 0.5rem;
}

.admin-card__title:first-child {
  margin-top: 0;
}

.admin-card__subtitle {
  font-size: var(--text-ui-sm);
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 1rem 0 0.375rem;
}

.admin-card__footer {
  margin: 0.75rem 0 0;
  font-size: var(--text-ui-sm);
}

.admin-link {
  color: var(--agent-blue);
  text-decoration: none;
}

.admin-link:hover {
  text-decoration: underline;
}

.admin-table--flush {
  border: none;
  border-radius: 0;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin: 0.5rem 0 1rem;
}

.admin-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

.admin-form__label {
  font-size: var(--text-ui-sm);
  font-weight: 500;
}

.admin-form__optional {
  color: var(--muted-foreground);
  font-weight: 400;
}

.admin-form__hint {
  font-size: var(--text-ui-sm);
  color: var(--muted-foreground);
  margin: 0.125rem 0 0;
}

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

.admin-form--inline {
  flex-direction: row;
  align-items: center;
  gap: 0.375rem;
  margin: 0;
}

.admin-form--inline .admin-input {
  min-width: 11rem;
}

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

.admin-button--danger {
  background: var(--destructive);
  border-color: var(--destructive);
  color: #ffffff;
}

.admin-form__hint--warning {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
}

.admin-detail--section {
  margin: 0.75rem 0;
}

.admin-detail--section > summary {
  font-weight: 500;
  color: var(--foreground);
}

/* Customer-facing Platform Services Agreement clickwrap. */
.agreement-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: var(--agent-bg);
  padding: 2rem 1rem;
}

.agreement-page__card {
  width: 100%;
  max-width: 44rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  height: fit-content;
}

.agreement-page__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.agreement-page__subtitle {
  color: var(--muted-foreground);
  font-size: var(--text-ui-base);
  margin: 0.25rem 0 1rem;
}

.agreement-page__terms {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: var(--text-ui-base);
  margin-bottom: 1rem;
}

.agreement-page__text {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  max-height: 24rem;
  overflow-y: auto;
  font-size: var(--text-ui-base);
  margin-bottom: 1rem;
}

.agreement-page__form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.agreement-page__confirm {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: var(--text-ui-base);
}

.agreement-page__pending {
  color: var(--muted-foreground);
  font-size: var(--text-ui-base);
}

/* Suspended-organization interstitial (rendered outside the admin shell). */
.suspended-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--agent-bg);
  padding: 1.5rem;
}

.suspended-page__card {
  max-width: 26rem;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2rem;
  text-align: center;
}

.suspended-page__title {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.suspended-page__body {
  font-size: var(--text-ui-base);
  color: var(--muted-foreground);
  margin: 0;
}
