/* Admin Console -> Email configuration (#smtpPane): outbound, de-dupe and intelligence, the delivery audit, the bench, the team roster
   and the team events dialog. Presentation only (events: TEAM_EMAIL_EVENTS, writes: admin_set_team_email(); behaviour in
   admin-email.js, admin-smtp-teams.js, admin-email-audit.js, admin-notification-intelligence.js, admin-bench-email.js).
   The shared parts come from alt-admin-components.css: `.a-stat`, `.a-notice`, `.a-record`, `.a-table`, `.a-code`. Everything here
   is token-only; the type sizes and the status colours are the control specification's, so a surface here cannot drift.
   Tests assert the exact opening tags of `.sec-stack` and `#emailAuditPanel`: add structure by selector, not classes. */

/* ================= The three sub-views =================
   The strip is the panel tab (DS-24, DS-A12): it replaces what the pane shows, so it spans the grid's full width and carries its
   own underline. `grid-column` picks the row; without it the strip lands in the first cell and pushes the stack beside it. */
#smtpPane.pane-grid.on > .ecfg-tabs{ grid-column: 1 / -1; }

/* Neither mount is a panel block: admin-paneling.test.js counts exactly four by name, and a fifth (even hidden) would break it.
   Both take the full row, and need no `order` below because a tab panel is only ever visible alone beneath the strip. */
#smtpPane.pane-grid.on > .ecfg-inbound-mount,
#smtpPane.pane-grid.on > .ecfg-intel-mount{ grid-column: 1 / -1; }

/* `.sec-stack` and `.sec-section` set their own `display` at higher specificity than a bare `[hidden]`, so the attribute alone
   would be overruled. Scoped to this pane. */
#smtpPane [hidden]{ display: none !important; }

/* Live editing is three full-width bands in one column at every width (system switch first). */
#liveEditPane.pane-grid.on{ grid-template-columns: minmax(0, 1fr); }

/* Desktop split, about two-thirds and one-third. The shared `.pane-grid` goes 2 equal columns at 900px and 3 at 1400px, so a 2:1
   split only appears above 1400px; narrowed here to 1181-1399 to avoid fighting Overview and Security's grid. */
@media (min-width: 1181px) and (max-width: 1399.98px){
  #smtpPane.pane-grid.on{ grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
}

/* Responsive order (<=1180px). The wireframe order (Application email, Teams, Email bench, audit) matches neither DOM nor desktop
   order. `display:contents` on the stack makes children direct grid items so `order` can place them. */
@media (max-width: 1180px){
  #smtpPane.pane-grid.on{ grid-template-columns: minmax(0, 1fr); }
  #smtpPane.pane-grid.on > .sec-stack{ display: contents; }
  #smtpPane .ecfg-tabs{ order: 0; }
  #smtpPane .ecfg-appemail-panel{ order: 1; }
  #smtpPane .ecfg-teams-panel{ order: 2; }
  #smtpPane .ecfg-bench-panel{ order: 3; }
  #smtpPane #emailAuditPanel{ order: 4; }
}

/* ================= The team roster =================
   One row per team: the switch, the name, a state, a count and the Events button. The row is the list row (`.a-record`, DS-A03);
   the fixed tracks keep the count and the button in line down the list however long the names run. */
.alt-app .smtp-team{ margin-bottom: var(--a-gap-row); min-width: 0; }
.alt-app .smtp-team-head{ display: flex; align-items: center; gap: var(--a-sp-12); min-width: 0; }
.alt-app .smtp-team-name{
  min-width: 0; font-size: var(--a-fs-13); font-weight: 600; line-height: var(--a-lh-tight); color: var(--a-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.alt-app .smtp-team-flag{ flex: 0 0 auto; }
.alt-app .smtp-team-count{
  margin-left: auto; font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint);
  text-transform: none; letter-spacing: 0; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.alt-app .smtp-team.is-on .smtp-team-count{ color: var(--a-dim); }

/* ================= The team events dialog =================
   The shared dialog shell (`.a-scrim` > `.a-modal`, DS-40). teamEventsDialogMount() builds the event rows from `.email-event`
   (CSS/components.css); the only seam is the roster-row border-top `.smtp-team-events` carries, a stray line in a dialog body. */
.alt-app .a-modal.ecfg-events-modal{ width: min(560px, 94vw); height: auto; max-height: min(700px, 88vh); }
.ecfg-events-modal > .a-drawer-h{ display: flex; align-items: center; justify-content: space-between; gap: var(--a-sp-12); }
.ecfg-events-modal > .a-drawer-b{ display: flex; flex-direction: column; gap: var(--a-sp-8); min-height: 0; overflow: auto; }
.ecfg-events-modal .smtp-team-events{ padding: 0; border-top: none; }

/* ================= Email bench =================
   Two questions, side by side when the section has the room (container query: the viewport cannot know how wide this block is).
   The verdict is `.a-notice`; the gates are a list of results whose state is the status chip. */
.alt-app .bench-row{ display: flex; gap: var(--a-sp-12); align-items: center; flex-wrap: wrap; margin: var(--a-sp-12) 0; }
.alt-app .bench-row label:not(.switch-check){
  font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-dim); white-space: nowrap;
}
/* A flex item's `min-width` is `auto`, which for a select is its longest option, and min-width beats max-width: that is how one
   long team name pushed the bench past its panel. Both halves are the fix; the option text is also shortened in admin-bench-email.js. */
.alt-app .bench-row select{ max-width: 100%; min-width: 0; flex: 1 1 auto; }
.alt-app .bench-actions{ display: flex; gap: var(--a-sp-8); align-items: center; flex-wrap: wrap; margin: var(--a-sp-12) 0 var(--a-sp-4); }
.alt-app .bench-questions{ container-type: inline-size; container-name: bench; }
.alt-app .bench-split{ display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--a-sp-8) var(--a-sp-24); align-items: start; }
@container bench (min-width: 880px){
  .alt-app .bench-split{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.alt-app .bench-col{ min-width: 0; }
.alt-app .bench-col > .sec-sub:first-child{ margin-top: 0; }
.alt-app .bench-subject{
  margin: var(--a-sp-12) 0 var(--a-sp-6); font-size: var(--a-fs-13); font-weight: 600; line-height: var(--a-lh-ui);
  color: var(--a-text); word-break: break-word;
}
/* The preview is the email as an email client draws it, in a sandboxed frame: its white ground is the client's, not the console's. */
.alt-app .bench-frame{
  display: block; width: 100%; height: 360px; border: 1px solid var(--a-line); border-radius: var(--a-r-sm);
  background: var(--a-on-fill);
}
.alt-app .bench-verdict{ margin: var(--a-sp-12) 0 var(--a-sp-8); }
.alt-app .bench-gates{ list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--a-sp-6); }
.alt-app .bench-gate{
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: var(--a-sp-4) var(--a-sp-8); align-items: center;
  padding: var(--a-sp-8) var(--a-sp-12); background: var(--a-panel); border: 1px solid var(--a-line-soft); border-radius: var(--a-r-sm);
  font-size: var(--a-fs-13); line-height: var(--a-lh-ui);
}
.alt-app .bench-gate .bg-mark{ font-weight: 700; color: var(--a-faint); text-align: center; }
.alt-app .bench-gate.is-pass .bg-mark{ color: var(--a-green); }
.alt-app .bench-gate.is-stop .bg-mark{ color: var(--a-amber); }
.alt-app .bench-gate .bg-label{ color: var(--a-text); min-width: 0; overflow-wrap: anywhere; }
.alt-app .bench-gate .bg-detail{ grid-column: 2 / -1; font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-dim); }
.alt-app .bench-gate.is-skip{ opacity: .72; }
/* The folded-preview switch is unavailable for events that never fold. */
#benchFoldRow:has(input:disabled){ opacity: .55; cursor: default; }

/* ================= Email health and the delivery audit ================= */
.alt-app .aea-controls{ margin: 0 0 var(--a-sp-16); }
.alt-app .aea-verdict{ margin: 0 0 var(--a-sp-12); }

/* The figures are `.a-stat`; failed and sent take `.warn` and `.good` from the tile. A suppression is a rule being obeyed, so its
   figure is the quiet one. */
.alt-app .a-stat.aea-stat-suppressed b{ color: var(--a-faint); }

/* The reason breakdown: Failures and Suppressions are two groups, because one ranked list would put a team using its own switch
   above a provider refusal. An empty breakdown draws nothing. */
.alt-app .aea-reasons{ margin: var(--a-sp-12) 0 0; display: flex; flex-direction: column; gap: var(--a-sp-12); }
.alt-app .aea-reasons:empty{ display: none; }
.alt-app .aea-reason-group{
  border: 1px solid var(--a-line-soft); border-radius: var(--a-r-sm); padding: var(--a-sp-8) var(--a-sp-12); background: var(--a-raised);
}
.alt-app .aea-reason-group.is-failed{ border-left: 3px solid var(--a-red); }
.alt-app .aea-reason-group.is-suppressed{ border-left: 3px solid var(--a-line-strong); }
.alt-app .aea-reason-h{
  font-family: var(--a-body); font-size: var(--a-fs-11); font-weight: 700; line-height: var(--a-lh-tight);
  letter-spacing: .08em; text-transform: uppercase; color: var(--a-dim);
}
.alt-app .aea-reason-group.is-failed .aea-reason-h{ color: var(--a-red); }
.alt-app .aea-reason-note{ margin: var(--a-sp-4) 0 var(--a-sp-8); font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); }

/* One reason per line: a grid, not flex, because the counts must line up (the fixed-track rule). */
.alt-app .aea-reason{
  display: grid; grid-template-columns: 38px minmax(0, 170px) minmax(0, 1fr); gap: var(--a-sp-4) var(--a-sp-12);
  align-items: baseline; padding: var(--a-sp-4) 0;
}
.alt-app .aea-reason + .aea-reason{ border-top: 1px solid var(--a-line-soft); }
.alt-app .aea-reason-n{
  font-size: var(--a-fs-13); font-weight: 700; line-height: var(--a-lh-ui); font-variant-numeric: tabular-nums; text-align: right;
  color: var(--a-text);
}
.alt-app .aea-reason.is-failed .aea-reason-n{ color: var(--a-red); }
.alt-app .aea-reason.is-suppressed .aea-reason-n{ color: var(--a-faint); }
.alt-app .aea-reason-code{ min-width: 0; overflow-wrap: anywhere; }
.alt-app .aea-reason-why{ font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); }

/* The delivery list. A row is `.a-record`; its inner layout is a wrapping flex whose address column takes the room and whose
   state, age and id sit after it. The reserved checkbox track keeps rows that cannot be retried aligned with those that can. */
.alt-app .aea-row{ display: flex; align-items: center; flex-wrap: wrap; gap: var(--a-sp-8) var(--a-sp-12); margin-bottom: var(--a-gap-row); min-width: 0; }
.alt-app .aea-row .pick{ width: var(--a-check); height: var(--a-check); flex: 0 0 auto; margin: 0; accent-color: var(--a-blue); }
.alt-app .aea-row .pick-gap{ width: var(--a-check); height: var(--a-check); flex: 0 0 auto; display: inline-block; }
.alt-app .aea-row .expand,
.alt-app .ni-row .expand{ flex: 0 0 auto; }
.alt-app .aea-row .expand.open,
.alt-app .ni-row .expand.open{ transform: rotate(90deg); color: var(--a-blue-text); }
.alt-app .aea-row .who-col{ flex: 1 1 220px; min-width: 0; }
.alt-app .aea-row .name{
  font-size: var(--a-fs-13); font-weight: 600; line-height: var(--a-lh-tight); color: var(--a-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* An email address is one unbreakable word; `anywhere` lets this line break mid-string. */
.alt-app .aea-row .sub{ margin-top: var(--a-sp-2); font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); overflow-wrap: anywhere; }
.alt-app .aea-row .meta{ font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); white-space: nowrap; }
.alt-app .aea-row .aea-provider{ flex: 0 1 auto; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* A delivery state is the status chip; the chips line up down the list, and the "what the record still holds" badge steps back. */
.alt-app .aea-badge{ text-transform: capitalize; flex: 0 0 auto; }
.alt-app .aea-badge.is-outranked{ opacity: .55; }
.alt-app .aea-attempt .aea-badge{ min-width: 76px; justify-content: center; }

/* Per-delivery attempt history: `.detail`, `.drow`, `.dname` and `.dmeta` are the console's own definition rows; only the heading
   and the fixed status column are new. */
.alt-app .aea-attempts-h{
  margin-bottom: var(--a-sp-4); font-size: var(--a-fs-11); font-weight: 700; line-height: var(--a-lh-tight);
  letter-spacing: .08em; text-transform: uppercase; color: var(--a-dim);
}
.alt-app .aea-attempt .dname{ flex: 0 0 auto; min-width: 0; }
.alt-app .aea-attempt .dmeta{ flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }

/* The count of loaded rows sits beside the selection count; `.bulk-count` takes `margin-right:auto` to push the buttons right, and a
   second one would push them twice. */
.alt-app .aea-count{ margin-right: 0; }

/* The drain sends what is already marked rather than acting on the selection, so it is set apart from the bulk bar. */
.alt-app .aea-drain{ margin: var(--a-sp-12) 0 0; padding-top: var(--a-sp-12); border-top: 1px solid var(--a-line-soft); gap: var(--a-sp-12); flex-wrap: wrap; }
.alt-app .aea-uncertain{ font-size: var(--a-fs-12); line-height: var(--a-lh-ui); gap: var(--a-sp-8); color: var(--a-dim); }
.alt-app .aea-uncertain input[type="checkbox"]{ width: var(--a-check); height: var(--a-check); flex: 0 0 auto; margin: 0; accent-color: var(--a-blue); }
.alt-app .aea-uncertain b{ color: var(--a-red); font-weight: 600; }

/* Three different silences drawn the same way, so the words carry the difference. */
.alt-app .aea-empty-h{ font-size: var(--a-fs-13); font-weight: 600; line-height: var(--a-lh-ui); color: var(--a-dim); }
.alt-app .aea-empty-p{ margin: var(--a-sp-4) auto 0; max-width: 46ch; font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); }

/* The filters that are narrowing the list are `.a-filter-chips` under the bar (DS-A10); each chip clears itself. The bar's own
   bottom margin gives way to the chips' top margin, so the two read as one control. */
.alt-app .aea-controls:has(+ .a-filter-chips:not(:empty)){ margin-bottom: 0; }
.alt-app .aea-active{ margin-bottom: var(--a-sp-12); }

/* ================= De-duplication and intelligence =================
   The batch rows are `.a-record` like the audit's; the clickable "Queued now" tile is a `button.a-stat`. */
.alt-app .ni-row{ display: flex; align-items: center; flex-wrap: wrap; gap: var(--a-sp-8) var(--a-sp-12); margin-bottom: var(--a-gap-row); min-width: 0; }
.alt-app .ni-row .pick-gap{ width: var(--a-check); height: var(--a-check); flex: 0 0 auto; display: inline-block; }
.alt-app .ni-row .who-col{ flex: 1 1 220px; min-width: 0; }
.alt-app .ni-row .name{
  font-size: var(--a-fs-13); font-weight: 600; line-height: var(--a-lh-tight); color: var(--a-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.alt-app .ni-row .sub{ margin-top: var(--a-sp-2); font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); overflow-wrap: anywhere; }
.alt-app .ni-row .meta{ font-size: var(--a-fs-12); line-height: var(--a-lh-ui); color: var(--a-faint); white-space: nowrap; }
.alt-app .ni-item .a-chip{ flex: 0 0 auto; }

@media (max-width: 880px){
  /* The history panel loses its indent on a narrow column. `.detail.aea-attempts` because admin.html's inline <style> sits after
     every <link>; a bare class would lose the tie. */
  .alt-app .detail.aea-attempts,
  .alt-app .detail.ni-items{ margin-left: 0; }
  .alt-app .aea-uncertain{ flex: 1 1 100%; }
  .alt-app .aea-attempt .dname{ flex: 1 1 100%; }
  .alt-app .aea-row .meta,
  .alt-app .ni-row .meta{ white-space: normal; }
  .alt-app .aea-row .aea-provider{ max-width: 100%; }
  /* The reason lines stack: a 38px numeral column beside two text columns has no room to be a grid at this width, and the count
     belongs with the word it counts. */
  .alt-app .aea-reason{ grid-template-columns: 38px minmax(0, 1fr); }
  .alt-app .aea-reason-why{ grid-column: 2; }
}
