/* Gängeviertel Selfservice — operations screens (wave 2)
   Page-specific refinements over design-system.css for the email outbox,
   the job status page and the maintenance surface. One system, one accent,
   one radius family, one hairline. Everything here is scoped to these pages
   and uses the tokens only. */

/* ==========================================================================
   Outbox — an operations console, not a dump
   ========================================================================== */

/* The counts read as one compact console strip: label left, figure right, one
   hairline between the three segments. A failed queue is the one number an
   operator acts on, so only that segment takes the danger tint. */
.page-outbox .ops-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}
.page-outbox .stat-card {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 0;
  border-radius: 0;
  background: transparent;
}
.page-outbox .stat-card + .stat-card { border-inline-start: 1px solid var(--border); }
.page-outbox .stat-card.is-alert { background: var(--danger-soft); }
.page-outbox .stat-label { font-size: 0.8125rem; }
.page-outbox .stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.page-outbox .stat-card.is-alert .stat-value { color: var(--danger-text); }
/* Three segments would crush the German "Fehlgeschlagen" on a phone: stack the
   same strip into three full-width rows instead. */
@media (max-width: 560px) {
  .page-outbox .ops-stats { grid-template-columns: 1fr; }
  .page-outbox .stat-card + .stat-card {
    border-inline-start: 0;
    border-block-start: 1px solid var(--border);
  }
}

/* Filters and the test-send live in one surface so the whole toolbar reads as
   a single control group. The filter form is one flex row on a wide screen. */
.page-outbox .ops-console { padding: var(--s-4); }
/* Two zones side by side: the filter row and the quiet test-send column. A grid
   rather than flex-wrap keeps the divider vertical only while the two zones are
   actually beside each other. */
.page-outbox .ops-console-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  align-items: start;
  gap: var(--s-5);
}
.page-outbox .ops-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s-3) var(--s-4);
  min-width: 0;
}
.page-outbox .ops-filter .field {
  flex: 1 1 10rem;
  min-width: 0;
  margin-bottom: 0;
}
.page-outbox .ops-filter .field--search { flex-basis: 14rem; flex-grow: 2; }
.page-outbox .ops-filter-actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.page-outbox .ops-filter-actions .text-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* The test-send is a quiet diagnostics column beside the filters. */
.page-outbox .ops-test {
  min-width: 0;
  padding-inline-start: var(--s-5);
  border-inline-start: 1px solid var(--border);
}
.page-outbox .ops-test-title {
  margin: 0 0 var(--s-1);
  font-size: 0.9375rem;
  font-weight: 700;
}
.page-outbox .ops-test .form-note { margin: 0 0 var(--s-3); }
.page-outbox .ops-test .btn { margin-top: 0; }

/* Six columns fit the console container at 1440 without starving the subject.
   The date, status, error and action columns have fixed widths so the subject
   and the error summary get the remaining room. Below 861px the system's card
   layout owns the width, so a lingering min-width would overflow the page. */
@media (min-width: 861px) {
  .page-outbox .data-table { min-width: 960px; table-layout: fixed; }
  .page-outbox .data-table th:nth-child(1),
  .page-outbox .data-table td:nth-child(1) { width: 104px; }
  .page-outbox .data-table th:nth-child(2),
  .page-outbox .data-table td:nth-child(2) { width: 168px; }
  .page-outbox .data-table th:nth-child(3),
  .page-outbox .data-table td:nth-child(3) { width: auto; }
  .page-outbox .data-table th:nth-child(4),
  .page-outbox .data-table td:nth-child(4) { width: 168px; }
  .page-outbox .data-table th:nth-child(5),
  .page-outbox .data-table td:nth-child(5) { width: 232px; }
  .page-outbox .data-table th:nth-child(6),
  .page-outbox .data-table td:nth-child(6) { width: 140px; }
  /* The date breaks between day and time; it never splits inside the date. */
  .page-outbox .outbox-created .ops-num { white-space: normal; overflow-wrap: normal; }
}

/* Numeric cells align their digits so attempts and times scan as columns. */
.page-outbox .ops-num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.page-outbox .data-table .ops-num { display: inline-block; }

/* Status carries the attempts and the next attempt as quiet meta under the
   pill: the two values stay legible without two extra columns. The wrapper is
   one block in table mode and one grid item in card mode. */
.page-outbox .outbox-status-cell { display: block; }
.page-outbox .outbox-status-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: var(--s-1);
}
.page-outbox .outbox-status-line {
  color: var(--text);
  font-size: 0.8125rem;
  line-height: 1.4;
}
.page-outbox .outbox-status-key { color: var(--muted); }

/* The short error is a summary, not the record: two lines in the table, three
   in the wider card rows, the full text in the disclosure and on the preview
   page. */
.page-outbox .outbox-error-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
@media (max-width: 860px) {
  .page-outbox .outbox-error-summary { -webkit-line-clamp: 3; }
  /* The error and the actions need the whole card width: they carry the most
     text and three actions, so their label sits above the content instead of
     sharing the row with it. */
  .page-outbox .data-table.responsive td:has(.outbox-error-summary),
  .page-outbox .data-table.responsive td:last-child {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-2);
  }
}

/* Status reads at a glance: a coloured dot inside each semantic pill. */
.page-outbox .badge::before,
.page-outbox-preview .badge::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-pill);
  background: currentColor;
}

/* The full error opens from a quiet disclosure link and renders as a code
   block so it reads as a diagnostic, not as prose. */
.page-outbox .detail-block { margin: var(--s-1) 0 0; }
.page-outbox .detail-block summary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--link);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.page-outbox .detail-block summary::-webkit-details-marker { display: none; }
.page-outbox .detail-block summary::before {
  content: "+";
  width: 0.75rem;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}
.page-outbox .detail-block[open] summary::before { content: "\2212"; }
.page-outbox .detail-block p {
  margin: var(--s-1) 0 0;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
/* In table mode the full error opens as a wide diagnostic sheet under the
   summary instead of a 160px letter column: it is the one floating layer in
   the table and stays inside the table wrap at every table width. */
@media (min-width: 861px) {
  .page-outbox .detail-block[open] p {
    width: 24rem;
    max-width: none;
    position: relative;
    z-index: 2;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-menu);
  }
}

/* Row actions are one verb-first link cluster: preview, retry, discard. The
   destructive action stays the quiet red one. In table mode the cluster stacks
   in a narrow column so the error summary keeps its room and the three labels
   never wrap mid-word; in card mode it is one row across the full card. */
.page-outbox .row-actions {
  gap: var(--s-1);
  align-items: center;
  flex-wrap: wrap;
  margin-inline-start: 0;
}
.page-outbox .ops-action {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  padding: 0 0.15rem;
  border: 0;
  background: none;
  color: var(--link);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
}
.page-outbox .ops-action:hover { color: var(--link-hover); text-decoration: underline; }
.page-outbox .ops-action-danger { color: var(--danger-text); }
.page-outbox .ops-action-danger:hover { color: var(--danger-text); }
/* Table mode: a vertical cluster aligned to the cell's start edge keeps the
   actions inside 140px, so the error column can hold the summary. */
@media (min-width: 861px) {
  .page-outbox .row-actions {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0;
  }
  .page-outbox .ops-action { min-height: 2rem; }
}
/* The discard confirmation unfolds under its own row instead of widening the
   table: it is a small surface inside the actions cell. */
.page-outbox .ops-action-disclosure[open] {
  width: 100%;
  margin-inline-start: 0;
  align-items: stretch;
}
.page-outbox .ops-action-disclosure > summary { list-style: none; }
.page-outbox .ops-action-disclosure > summary::-webkit-details-marker { display: none; }
.page-outbox .row-actions > .ops-action-disclosure[open] > summary { align-self: flex-start; }
.page-outbox .ops-action-disclosure > .disclosure-form { width: 100%; }
/* In table mode the actions column is deliberately narrow, so the discard
   confirmation opens as a small floating sheet beside the trigger instead of
   being squeezed into 140px. It stays inside the table wrap; in the last row
   it opens upwards so it is never clipped. */
@media (min-width: 861px) {
  .page-outbox .ops-action-disclosure { position: relative; }
  .page-outbox .ops-action-disclosure[open] { width: auto; }
  .page-outbox .row-actions > .ops-action-disclosure[open] > summary { align-self: auto; }
  .page-outbox .ops-action-disclosure[open] > .disclosure-form {
    position: absolute;
    top: calc(100% + 0.4rem);
    inset-inline-end: 0;
    inset-inline-start: auto;
    width: 20rem;
    max-width: calc(100vw - 2rem);
    margin-top: 0;
    z-index: 30;
    border-color: var(--border-strong);
    box-shadow: var(--shadow-menu);
  }
  .page-outbox .outbox-table tbody tr:last-child .ops-action-disclosure[open] > .disclosure-form {
    top: auto;
    bottom: calc(100% + 0.4rem);
  }
}
/* In card mode the actions already own the full content column. */
@media (max-width: 860px) {
  .page-outbox .row-actions { gap: var(--s-2); }
}

/* Below the two-zone width the console becomes one column and the test-send
   drops its vertical rule for a top rule. */
@media (max-width: 920px) {
  .page-outbox .ops-console-row {
    grid-template-columns: 1fr;
    gap: var(--s-4);
  }
  .page-outbox .ops-test {
    padding-inline-start: 0;
    border-inline-start: 0;
    border-block-start: 1px solid var(--border);
    padding-top: var(--s-4);
  }
}

/* In card mode the last-error disclosure and actions stay within their card. */
@media (max-width: 860px) {
  .page-outbox .detail-block p { max-width: 100%; }
}

/* ==========================================================================
   Outbox preview — a document, not a stray iframe
   ========================================================================== */

/* The metadata reads as a two-column key/value sheet on wide screens. */
.page-outbox-preview .meta-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3) var(--s-6);
  margin-top: var(--s-2);
}
.page-outbox-preview .meta-list > div {
  align-items: baseline;
  gap: 0.25rem var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--border);
}
.page-outbox-preview .meta-list > div:last-child {
  border-bottom: 0;
}
.page-outbox-preview .meta-list dt {
  min-width: 7.5rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.page-outbox-preview .meta-list dd {
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

/* The sandboxed mail body is framed as a document: a hairline frame on a paper
   ground, so the email reads as the thing being inspected. */
.page-outbox-preview .mail-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff; /* mail is authored for white paper, both grades */
  overflow: hidden;
}
.page-outbox-preview .mail-frame iframe {
  display: block;
  width: 100%;
  height: clamp(360px, 60vw, 560px);
  border: 0;
  background: #ffffff;
}
.page-outbox-preview .prose pre { white-space: pre-wrap; }

@media (max-width: 640px) {
  .page-outbox-preview .meta-list { grid-template-columns: 1fr; gap: var(--s-2); }
  .page-outbox-preview .meta-list > div:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--border);
  }
  .page-outbox-preview .meta-list > div:last-child { border-bottom: 0; }
}

/* ==========================================================================
   Jobs — health at a glance
   ========================================================================== */

/* Same table/scroll contract as the outbox: wide in table mode, the system's
   card layout owns the width below 861px. */
@media (min-width: 861px) {
  .page-admin-jobs .data-table { min-width: 780px; }
}
.page-admin-jobs .ops-job-id {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.page-admin-jobs .cell-sub { font-size: 0.8125rem; }

.page-admin-jobs .ops-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Outcome pills carry a status dot, matching the outbox console. */
.page-admin-jobs .badge::before {
  content: "";
  width: 0.375rem;
  height: 0.375rem;
  border-radius: var(--radius-pill);
  background: currentColor;
}

/* Error details: the same quiet disclosure + code-block recipe as the outbox. */
.page-admin-jobs .detail-block { margin: var(--s-2) 0 0; }
.page-admin-jobs .detail-block summary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--link);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
.page-admin-jobs .detail-block summary::-webkit-details-marker { display: none; }
.page-admin-jobs .detail-block summary::before {
  content: "+";
  width: 0.75rem;
  color: var(--muted);
  font-weight: 700;
  text-align: center;
}
.page-admin-jobs .detail-block[open] summary::before { content: "\2212"; }
.page-admin-jobs .detail-block pre {
  margin: var(--s-1) 0 0;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* The schedule column renders the cron expression in mono, nowrap so it never
   folds mid-token. */
.page-admin-jobs .data-table code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .page-admin-jobs .detail-block pre { max-width: 100%; }
  /* Card mode: the outcome cell is label + content. Once the error opens, give
     the explanation the whole card width instead of a 34%-wide column. */
  .page-admin-jobs .jobs-outcome-cell:has(.detail-block[open]) {
    grid-template-columns: 1fr;
  }
}

/* A failed job opens the same wide diagnostic sheet as the outbox: the outcome
   column is too narrow for a stack trace, and the sheet stays inside the
   table wrap at every table width. */
@media (min-width: 861px) {
  .page-admin-jobs .detail-block[open] pre {
    width: 22rem;
    max-width: none;
    position: relative;
    z-index: 2;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-menu);
  }
}

/* ==========================================================================
   Maintenance page — calm, one message, no branding
   ========================================================================== */

/* The page has no header or footer; the card is centred in the viewport. */
.page-maintenance .page-main {
  display: flex;
  flex: 1 0 auto;
  align-items: center;
  justify-content: center;
}
.page-maintenance .maint-card {
  width: 100%;
  max-width: 32rem;
  margin-inline: auto;
  padding: clamp(1.5rem, 5vw, 2.5rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  text-align: center;
}
.page-maintenance .maint-mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin: 0 auto var(--s-4);
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--muted);
}
.page-maintenance .maint-mark svg { width: 20px; height: 20px; }
.page-maintenance .maint-code {
  margin: 0 0 var(--s-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.page-maintenance .maint-card h1 {
  margin: 0 0 var(--s-3);
  font-size: clamp(1.5rem, 3vw, 1.9rem);
}
.page-maintenance .maint-card .lede {
  margin: 0 auto;
  max-width: 34ch;
  color: var(--text);
  font-size: 1rem;
}
.page-maintenance .maint-hint {
  max-width: 34ch;
  margin: var(--s-5) auto 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ==========================================================================
   Maintenance banner — calm, one line, doesn't fight the header
   ========================================================================== */

/* A slim, full-width strip above the sticky header. It scrolls away with the
   page rather than pushing every section down once the header sticks. */
.maint-banner {
  border-bottom: 1px solid var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning-text);
}
.maint-banner--down {
  border-bottom-color: var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-text);
}
.maint-banner-inner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding-block: var(--s-2);
}
.maint-banner-inner svg {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 1px;
}
.maint-banner-inner p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.maint-banner-msg { opacity: 0.85; }

/* On a phone the two-part notice is the tallest thing above the fold. Tighten
   the type and the padding so it stays a strip, not a paragraph block. */
@media (max-width: 560px) {
  .maint-banner-inner {
    gap: var(--s-2);
    padding-block: var(--s-1);
  }
  .maint-banner-inner svg { margin-top: 0.15rem; }
  .maint-banner-inner p { font-size: 0.8125rem; line-height: 1.45; }
}
/* On the narrowest phones the icon would cost a line of its own: the strip's
   ground and wording already carry the state. */
@media (max-width: 360px) {
  .maint-banner-inner svg { display: none; }
}
