/* Keep this content ancestor free of transforms and animated opacity so fixed
   modal overlays remain anchored to the viewport. */
.app-main {
  flex: 1;
  min-width: 0;
  padding: clamp(28px, 5vw, 44px) 0 clamp(44px, 8vw, 72px);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--page-gutter);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 26px;
}

.page-header h1 {
  margin-bottom: 8px;
}

.page-header p {
  font-size: 15px;
}

.record-header {
  align-items: center;
  margin-bottom: 20px;
  padding: clamp(20px, 3vw, 28px);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.record-header-copy {
  flex: 1 1 320px;
  min-width: 0;
}

.record-header .record-eyebrow {
  margin-bottom: 6px;
  color: var(--accent-dim);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.3;
  text-transform: uppercase;
}

.record-header h1 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.record-header--compact {
  padding: 0;
  background: transparent;
  border: none;
  gap: 12px;
}

.record-header--compact h1 {
  margin-bottom: 4px;
  font-size: 28px;
}

.record-header-context,
.record-header .record-header-description {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.record-header-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.record-header-context strong {
  color: var(--text-primary);
  font-weight: 500;
}

.record-header-context a {
  color: var(--text-secondary);
}

.record-header-context a:hover,
.record-header-context a:focus-visible {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.page-header > .header-actions {
  align-items: stretch;
  justify-content: flex-end;
  gap: 4px;
  padding: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.page-header > .header-actions > form,
.page-header > .header-actions > div {
  display: flex;
}

.page-header > .header-actions .btn {
  min-height: 32px;
  padding: 6px 11px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 12.5px;
  white-space: nowrap;
}

.page-header > .header-actions .btn--ghost {
  border-color: transparent;
}

.page-header > .header-actions .btn--danger {
  border-color: transparent;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}

.section-header h2 {
  margin-bottom: 0;
}

.section-description {
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 13px;
}

.section-header .form-help {
  margin: 4px 0 0;
}

.disclosure {
  overflow: hidden;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.disclosure + .disclosure {
  margin-top: 12px;
}

.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--text-primary);
  background: var(--bg-elevated);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
}

.disclosure > summary::-webkit-details-marker {
  display: none;
}

.disclosure > summary::after {
  flex: 0 0 auto;
  color: var(--text-muted);
  content: "+";
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.disclosure[open] > summary {
  border-bottom: 1px solid var(--border-subtle);
}

.disclosure[open] > summary::after {
  content: "−";
}

.disclosure > summary:hover,
.disclosure > summary:focus-visible {
  background: var(--bg-hover);
}

.disclosure-body {
  min-width: 0;
  padding: 14px;
}

.disclosure-body > :last-child {
  margin-bottom: 0;
}

.section-header .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  padding: 7px 14px;
}

.section-header .btn__icon {
  font-size: 20px;
}

.section-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-bottom: 22px;
  padding: 5px;
  overflow-x: auto;
  background: var(--nav-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
}

.section-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--text-secondary);
  border-radius: calc(var(--radius) - 2px);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 160ms var(--ease), background 160ms var(--ease);
}

.section-nav a:hover,
.section-nav a:focus-visible {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.summary {
  scroll-margin-top: 76px;
  margin-bottom: 28px;
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.details-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 4px 0 0;
}

.details-list > div {
  min-width: 0;
}

.details-list dt {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.details-list dd {
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.metric-grid--flush {
  margin-top: 0;
}

.section-stack {
  display: grid;
  gap: 32px;
}

.section-stack--compact {
  gap: 16px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 14px 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.metric-strip > div {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 0 12px;
}

.metric-strip > div + div {
  border-left: 1px solid var(--border-subtle);
}

.metric-strip dt {
  color: var(--text-secondary);
  font-size: 12px;
}

.metric-strip dd {
  order: -1;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.record-list {
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.record-row {
  border: 0;
  border-radius: 0;
  scroll-margin-top: 20px;
}

.record-row + .record-row {
  margin-top: 0;
  border-top: 1px solid var(--border-subtle);
}

.record-row > summary {
  min-height: 68px;
  padding: 12px 16px;
}

.record-row[open] > summary {
  background: var(--accent-soft);
}

.record-row > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.record-row-copy {
  display: grid;
  flex: 1;
  gap: 4px;
  min-width: 0;
}

.record-row-title {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.record-row-meta,
.record-row-hint {
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.record-row-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.record-row-hint {
  color: var(--success);
}

.record-row-hint--warning {
  color: var(--warning);
}

.record-row > .disclosure-body {
  padding: 18px;
}

.details-list--compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 20px;
  margin: 0;
}

.details-list--compact dd {
  font-size: 13px;
}

.action-bar,
.action-bar-buttons {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.action-bar {
  justify-content: space-between;
  gap: 12px;
}

.action-bar > p {
  flex: 1 1 240px;
}

.action-bar-buttons > form {
  display: flex;
}

.action-bar--separated {
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.collection-caption {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 12px;
}

.disclosure--plain {
  background: transparent;
  border-color: var(--border-subtle);
}

.disclosure--plain > summary {
  min-height: 36px;
  padding: 8px 12px;
  color: var(--text-secondary);
  background: transparent;
  font-size: 12px;
}

.disclosure--warning {
  border-color: var(--warning-border);
}

.disclosure--warning > summary {
  color: var(--warning);
  background: var(--warning-soft);
}

.message-list {
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.section-stack > .disclosure + .disclosure {
  margin-top: 0;
}

@media (max-width: 600px) {
  .metric-strip > div {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    text-align: center;
  }

  .metric-strip dt {
    font-size: 10px;
  }

  .record-row-state {
    flex-direction: column;
    align-items: flex-end;
    flex: 0 0 auto;
    gap: 4px;
  }

  .record-row > summary,
  .record-row > .disclosure-body {
    padding: 12px;
  }

  .record-row > summary {
    gap: 10px;
  }

  .details-list--compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.content-section,
.content-section [id] {
  min-width: 0;
  scroll-margin-top: 76px;
}

.content-section > .section-header {
  align-items: flex-start;
  margin-bottom: 14px;
}

.content-section > .section-header h2 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 0;
}

.content-section > .section-header .section-description {
  max-width: 70ch;
}

.app-footer {
  border-top: 1px solid var(--footer-border);
  padding: 18px 0;
  background: var(--footer-bg);
  color: var(--footer-text);
}

.footer-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--footer-brand);
}

.footer-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.footer-powered {
  font-size: 11px;
  color: var(--footer-text-muted);
  letter-spacing: 0.02em;
}

.footer-powered a {
  color: var(--accent);
  text-decoration: none;
  transition: color 160ms var(--ease);
}
.footer-powered a:hover { color: var(--accent-dim); }

@media (max-width: 760px) {
  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .record-header-copy {
    flex-basis: auto;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header > .header-actions {
    align-self: stretch;
    justify-content: flex-start;
  }

  .page-header > .header-actions > * {
    flex: 1 1 max-content;
  }

  .page-header > .header-actions > form > *,
  .page-header > .header-actions > div > *,
  .page-header > .header-actions .action-menu-trigger {
    width: 100%;
  }

  .footer-stack {
    align-items: flex-start;
    width: 100%;
  }

  .section-nav {
    margin-right: calc(var(--page-gutter) * -1);
    margin-left: calc(var(--page-gutter) * -1);
    padding-right: var(--page-gutter);
    padding-left: var(--page-gutter);
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .summary,
  .content-section,
  .content-section [id] {
    scroll-margin-top: 64px;
  }
}

@media (max-width: 1280px) {
  .section-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
