.mail-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin-top: 1rem;
}
.mail-filters label { flex: 1 1 10rem; min-width: 0; }
.mail-filters input, .mail-filters select, .mail-filing-panel select { width: 100%; }
.mail-address, .mail-attachment-actions, .mail-detail-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
}
.mail-address { margin-bottom: 1rem; }
.mail-address code { overflow-wrap: anywhere; }
.mail-table { min-width: 58rem; }
.mail-table td { overflow-wrap: anywhere; }
.mail-table time { white-space: nowrap; }
.mail-table .mail-actions-column { width: 1%; white-space: nowrap; }
.mail-row-actions { display: flex; flex-wrap: nowrap; gap: .5rem; }
.mail-table th:nth-child(2), .mail-table td:nth-child(2) { min-width: 12rem; }
.mail-subject-link { color: inherit; font-weight: 700; text-decoration: none; }
.mail-subject-link:hover { color: var(--bs-primary); text-decoration: underline; }
.mail-address-book { margin-top: 1rem; }
.mail-address-list { margin: 1rem 0 0; }
.mail-address-list > div { display: grid; grid-template-columns: minmax(8rem, 1fr) minmax(0, 3fr); gap: 1rem; padding: .65rem 0; border-top: 1px solid var(--app-border); }
.mail-address-list dt { overflow-wrap: anywhere; }
.mail-address-list dd { margin: 0; }
.mail-row-progress { display: flex; flex-direction: column; align-items: start; gap: .35rem; }
.mail-row-progress small { color: var(--app-muted); }
.mail-heading-content { width: 100%; min-width: 0; }
.mail-title-line { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.mail-title-line h1 { margin-bottom: 0; }
.mail-operation-indicator { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; flex-shrink: 0; cursor: help; border-radius: 50%; }
.mail-operation-indicator:hover, .mail-operation-indicator:focus-visible { outline: 2px solid var(--app-border-strong); outline-offset: 2px; }
.mail-operation-dot { width: .75rem; height: .75rem; border-radius: 50%; box-shadow: 0 0 0 .2rem var(--bs-tertiary-bg); }
.mail-operation-dot--success { background: #198754; }
.mail-operation-dot--warning { background: #d99a00; }
.mail-operation-dot--danger { background: #dc3545; }
.mail-operation-tooltip { pointer-events: none; }
.mail-operation-tooltip .tooltip-inner { max-width: min(28rem, calc(100vw - 2rem)); text-align: left; white-space: pre-line; }
.mail-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; margin: 0; }
.mail-message .mail-body { margin-bottom: 1rem; }
.mail-attachment {
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  padding: 1rem;
  margin: 1rem 0;
  min-width: 0;
}
.mail-attachment-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem; }
.mail-attachment-info { min-width: 0; flex: 1 1 12rem; }
.mail-attachment h3 { font-size: 1.1rem; overflow-wrap: anywhere; margin: 0 0 .25rem; }
.mail-filing-panel h4 { font-size: 1rem; margin: 0 0 .75rem; }
.mail-attachment-note { margin: .75rem 0 0; }
.mail-filing-panel { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--app-border); }
.mail-filing-panel > select { width: min(100%, 22rem); }
.mail-filing-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.mail-filing-panel label { display: block; margin: .5rem 0; }
.mail-detail .card { margin-bottom: 1rem; }
.mail-metadata { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: 0; }
.mail-metadata dd { margin: 0; }
.mail-page h1, .mail-page dd, .mail-page h2 { overflow-wrap: anywhere; }
.mail-detail-footer { justify-content: space-between; padding: .5rem 0; }
.mail-filed { color: var(--bs-success-text-emphasis); }
.mail-delete-confirm { border-color: var(--bs-danger); }
#entity-modal:has(.mail-page) .modal-title { min-width: 0; overflow-wrap: anywhere; }
#entity-modal:has(.mail-page) .flash-messages {
  position: static;
  flex-shrink: 0;
  width: auto;
  max-height: 30dvh;
  margin: .75rem 1rem 0;
}
#entity-modal:has(.mail-page) .flash-messages:empty { margin: 0; }
/* Keep hidden destination/confirmation panels hidden despite shared card styles. */
.mail-page [hidden] { display: none !important; }
@media (max-width: 700px) {
  .mail-page .stats-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mail-address-list > div { grid-template-columns: 1fr; gap: .35rem; }
  .mail-filters { flex-direction: column; align-items: stretch; }
  .mail-filters label { flex: auto; }
  .mail-attachment { padding: .75rem; }
  .mail-metadata { grid-template-columns: 1fr; gap: .2rem; }
  .mail-metadata dd { margin-bottom: .5rem; }
  #entity-modal:has(.mail-page) .modal-dialog { max-width: 100%; width: 100%; height: 100%; margin: 0; }
  #entity-modal:has(.mail-page) .modal-content { height: 100%; max-height: 100%; border-radius: 0; }
}
