/* Hyrax Operator Console - shadcn-styled component classes (one block per
   component factory in static/js/components/). Hand-authored CSS (NOT Tailwind
   utilities) matching shadcn anatomy, driven by the tokens. Served same-origin
   (style-src 'self'); no CDN. ASCII-only. */

/* --- button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  white-space: nowrap;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  user-select: none;
}
.btn:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* An in-flight button (createButton/table.js disable + "Working..." during an
   async mutation): progress cursor to reinforce the busy state. */
.btn-working {
  cursor: progress;
}
.btn-default {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-default:hover {
  background: hsl(var(--primary) / 0.9);
}
.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover {
  background: hsl(var(--secondary) / 0.8);
}
.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover {
  background: hsl(var(--destructive) / 0.85);
}
.btn-outline {
  background: transparent;
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-outline:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}
.btn-ghost:hover {
  background: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}
.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
}

/* --- card --- */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.3);
}
.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem 1.25rem 0.75rem 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0;
}
.card-description {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  margin: 0;
}
.card-content {
  padding: 0.75rem 1.25rem 1.25rem 1.25rem;
}
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem 1.25rem;
}

/* --- table --- */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}
.table thead tr {
  border-bottom: 1px solid hsl(var(--border));
}
.table th {
  text-align: left;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  padding: 0.6rem 0.75rem;
  white-space: nowrap;
}
.table td {
  padding: 0.55rem 0.75rem;
  border-top: 1px solid hsl(var(--border));
  vertical-align: middle;
  white-space: nowrap;
}
.table tbody tr:hover {
  background: hsl(var(--accent) / 0.4);
}
.table .note {
  display: inline-block;
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  margin-left: 0.3rem;
}
.table td .btn {
  margin-right: 0.3rem;
}

/* --- badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 0.1rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-default {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.badge-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.badge-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.badge-outline {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}
.badge-success {
  background: hsl(var(--success));
  color: hsl(var(--success-foreground));
}

/* --- input + label + select --- */
.input,
.select {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid hsl(var(--input));
  border-radius: calc(var(--radius) - 2px);
  color: hsl(var(--foreground));
  font-size: 0.8125rem;
  padding: 0.45rem 0.6rem;
  line-height: 1.4;
}
.input::placeholder {
  color: hsl(var(--muted-foreground));
}
.input:focus-visible,
.select:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
  border-color: hsl(var(--ring));
}
.select {
  cursor: pointer;
}
.label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  margin-bottom: 0.25rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.35rem 0;
}
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin: 0.5rem 0;
}

/* A horizontal control row (label + input + button). Shares the .field-row shape.
   .form-row: the consumer-detail grant/set-cap forms, the operators enroll form,
   the consumers disable/revoke controls. .filter-row: the usage/spend/audit filter
   bars (previously undefined, so those filters stacked vertically full-width). */
.form-row,
.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.6rem;
  margin: 0.5rem 0;
}

/* Cost-provenance cell grouping in the wide Usage table (cost_tag /
   backstop_source / backstop_finalized_at): a subtle tint so the forensic trio
   reads as one band across the 15-column row. */
.cost-provenance {
  background: hsl(var(--secondary) / 0.4);
}

/* The response-shape affordance slot (an Alert mounted above the result box). */
.affordance-slot {
  margin: 0.5rem 0;
}

/* The dashboard disabled-consumers attention badge. */
.dashboard-flag {
  margin-left: 0.5rem;
}

/* --- sheet (right-side panel) --- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: hsl(0 0% 0% / 0.6);
  z-index: 50;
}
.sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 100%);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border-left: 1px solid hsl(var(--border));
  box-shadow: -2px 0 12px hsl(0 0% 0% / 0.4);
  z-index: 51;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}
.sheet-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.sheet-content {
  padding: 1.25rem;
}

/* --- alert --- */
.alert {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  margin: 0.5rem 0;
}
.alert-destructive {
  border-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
  background: hsl(var(--destructive) / 0.2);
}
.alert-success {
  border-color: hsl(var(--success-border));
  color: hsl(var(--success-foreground));
  background: hsl(var(--success) / 0.2);
}
.alert-title {
  font-weight: 600;
}

/* --- toast (sonner-style region) --- */
.toast-region {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
  max-width: 360px;
}
.toast {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: 0 4px 12px hsl(0 0% 0% / 0.4);
  padding: 0.65rem 0.85rem;
  font-size: 0.8125rem;
}
.toast-destructive {
  border-color: hsl(var(--destructive));
}

/* --- result block (verbatim JSON / one-shot reveal) --- */
.result {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 0.75rem;
  overflow-x: auto;
  min-height: 1.2em;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: hsl(var(--foreground));
  margin: 0.5rem 0;
}

/* --- persistent error banner (status.js setError/clearError) --- */
.shell-error {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 1.25rem 0;
  padding: 0.65rem 0.9rem;
  border: 1px solid hsl(var(--destructive));
  background: hsl(var(--destructive) / 0.2);
  color: hsl(var(--destructive-foreground));
  border-radius: var(--radius);
  font-size: 0.8125rem;
}
.shell-error-text {
  flex: 1;
}

/* --- one-shot enrollment-token reveal (result.js) --- */
.token-reveal {
  border: 1px solid hsl(var(--success-border));
  background: hsl(var(--success) / 0.15);
  border-radius: var(--radius);
  padding: 0.85rem;
  margin: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.token-reveal-heading {
  font-weight: 600;
  font-size: 0.8125rem;
}
.token-reveal-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 2px);
  padding: 0.5rem 0.65rem;
  word-break: break-all;
  user-select: all;
}
.token-reveal-actions {
  display: flex;
  gap: 0.5rem;
}
.token-reveal-warning {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}
.result-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0.4rem 0 0;
}

/* --- table loading / empty / error message rows (table.js renderMessage) --- */
.table-message {
  text-align: center;
  color: hsl(var(--muted-foreground));
  padding: 1rem;
  font-size: 0.8125rem;
}
.table-message-error {
  color: hsl(var(--destructive-foreground));
}

/* --- skeleton / separator --- */
.skeleton {
  background: hsl(var(--muted));
  border-radius: calc(var(--radius) - 2px);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  min-height: 1rem;
}
@keyframes skeleton-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
.separator {
  height: 1px;
  width: 100%;
  background: hsl(var(--border));
  margin: 1rem 0;
}

/* --- avatar (monogram) --- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

/* --- shared notes / muted text --- */
.note,
.muted {
  color: hsl(var(--muted-foreground));
  font-size: 0.75rem;
  margin: 0.25rem 0;
}
.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}
