.page {
  width: 100%;
}

.page--narrow {
  max-width: 42rem;
}

.page-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header--end {
  justify-content: flex-end;
}

.page-title {
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 2rem;
  margin: 0;
}

.page > .page-title:first-child {
  margin-bottom: 1.5rem;
}

.page-description {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.page > .page-description {
  margin-bottom: 1.5rem;
}

.section-title {
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.75rem;
  margin: 0 0 1rem;
}

.section-title--small {
  font-size: 1rem;
  font-weight: 500;
}

.section-heading {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  margin: 0;
  text-transform: uppercase;
}

.cluster {
  --cluster-gap: 0.5rem;

  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--cluster-gap);
}

.cluster--large {
  --cluster-gap: 0.75rem;
}

.cluster--between {
  justify-content: space-between;
}

.cluster--end {
  justify-content: flex-end;
}

.cluster--wrap {
  flex-wrap: wrap;
}

.button-form {
  display: contents;
}

.destructive-actions {
  margin-top: 1rem;
}

.stack {
  --stack-gap: 1.5rem;

  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
}

.stack--small {
  --stack-gap: 1rem;
}

.stack--compact {
  --stack-gap: 0.75rem;
}

.stack--tiny {
  --stack-gap: 0.125rem;
}

.field-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
}

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

.filter-form,
.filter-row {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.filter-panel {
  margin-bottom: 1.5rem;
}

.filter-form--stacked {
  align-items: stretch;
  flex-direction: column;
  gap: 0.75rem;
}

.filter-label {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.filter-separator {
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 767px) {
  .filter-form,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
    gap: 0.75rem;
  }

  .filter-label,
  .filter-separator {
    white-space: normal;
  }
}

.metric-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

.metric-row > * {
  font-size: 0.875rem;
}

.metric-label {
  color: var(--text-subtle);
}

.metric-value {
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 0.25rem;
}

.metric-value--positive {
  color: var(--lime-700);
}

.metric-value--negative {
  color: var(--red-600);
}

.approx-value {
  color: var(--text-subtle);
  font-weight: 400;
}

.section-group {
  margin-bottom: 2rem;
}

.split-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  justify-content: space-between;
}

.split-row--section {
  margin-bottom: 1rem;
}

.section-toolbar {
  margin-bottom: 0.5rem;
}

.detail-label,
label,
.label {
  color: var(--text-muted);
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.25rem;
}

:is(p, dt).label,
.detail-label {
  margin: 0 0 0.125rem;
}

.detail-value {
  color: var(--text);
  margin: 0;
}

.detail-title {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.75rem;
  margin: 0;
}

.empty-value {
  color: var(--text-subtle);
  font-style: italic;
  margin: 0;
}

.detail-list {
  color: var(--text);
  list-style: disc;
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

dd.detail-value {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-note {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 0.5rem 0 0;
}

.field-label-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.375rem;
}

.small-link {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: color 150ms;
}

.small-link:hover {
  color: var(--text);
}

.form-footer {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin: 1rem 0 0;
  text-align: center;
}

.strong-link {
  color: var(--text);
  font-weight: 500;
  transition: color 150ms;
}

.strong-link:hover {
  color: var(--black);
}

.error-text {
  color: var(--red-600);
  font-size: 0.875rem;
  margin: 0.25rem 0 0;
}

.error-panel {
  background: var(--red-50);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.error-panel-title {
  color: var(--red-800);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
}

.error-list {
  color: var(--red-700);
  font-size: 0.875rem;
  list-style: disc;
  list-style-position: inside;
  margin: 0.5rem 0 0;
}

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

.link:hover {
  color: var(--text);
}

.link--accent {
  color: var(--link);
}

.link--accent:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

.action-link {
  color: var(--link);
  font-size: inherit;
  font-weight: inherit;
  padding: 0;
}

.action-link:hover {
  color: var(--link-hover);
}

.action-link--danger {
  color: var(--red-600);
}

.action-link--danger:hover {
  color: var(--red-900);
}

.breakable {
  overflow-wrap: anywhere;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card--danger {
  border-color: var(--red-200);
}

.card + .card,
.card-spaced {
  margin-top: 1.5rem;
}

.card .card-body,
.card-body {
  padding: 1.25rem 1rem;
}

@media (min-width: 640px) {
  .card .card-body,
  .card-body {
    padding: 1.5rem;
  }
}

.card-body--divided {
  border-bottom: 1px solid var(--border);
}

.card-section {
  border-top: 1px solid var(--border);
}

.card-subheader {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.card-subheader .section-title {
  margin-bottom: 0;
}

.card-body--divided .section-title {
  margin-bottom: 0;
}

.block-spaced {
  margin-bottom: 1.5rem;
}

.btn {
  --btn-bg: var(--indigo-500);
  --btn-bg-hover: var(--indigo-600);
  --btn-border: transparent;
  --btn-color: var(--white);

  align-items: center;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  color: var(--btn-color);
  display: flex;
  font-size: 0.875rem;
  font-weight: 500;
  gap: 0.375rem;
  justify-content: center;
  line-height: 1.25rem;
  padding: 0.5rem 1rem;
  user-select: none;
  white-space: nowrap;
  transition: background 100ms ease-in-out, color 100ms ease-in-out, opacity 100ms ease-in-out;
}

.btn:hover {
  background: var(--btn-bg-hover);
}

.btn--secondary {
  --btn-bg: var(--white);
  --btn-bg-hover: var(--surface-subtle);
  --btn-border: var(--border-strong);
  --btn-color: var(--text);
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn--full {
  margin-top: 0.5rem;
  width: 100%;
}

.btn--danger {
  --btn-bg: var(--red-600);
  --btn-bg-hover: var(--red-500);
  --btn-border: transparent;
  --btn-color: var(--white);
}
