/* --------------------------------------------------------------------------
   Attachments / mail
   -------------------------------------------------------------------------- */
.fixed-mail-template-picker > h2 { margin-bottom: 3px; }
.send-mail-picker-category { flex: 0 1 320px; max-width: 320px; }
.send-mail-picker-category select { width: 100%; }
.send-mail-template-table { min-width: 900px; table-layout: fixed; }
.send-mail-template-table th:first-child,
.send-mail-template-table td:first-child { width: 18%; }
.send-mail-template-table th.send-mail-template-table__category,
.send-mail-template-table td.send-mail-template-table__category { width: 8%; }
.send-mail-template-table__category .badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.send-mail-template-table th:nth-child(3),
.send-mail-template-table td:nth-child(3),
.send-mail-template-table th:nth-child(4),
.send-mail-template-table td:nth-child(4) { width: 23%; }
.send-mail-template-table th:nth-child(5),
.send-mail-template-table td:nth-child(5) { width: 10%; text-align: center; }
.send-mail-template-table th:nth-child(6),
.send-mail-template-table td:nth-child(6) { width: 8%; text-align: center; }
.send-mail-template-table th:last-child,
.send-mail-template-table td:last-child { width: 10%; }
.send-mail-template-table__long-value { overflow-wrap: anywhere; white-space: normal; }
.category-catalog-picker > h2 { margin-bottom: 3px; }
.category-catalog-picker__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.category-catalog-picker__button { min-width: 150px; text-align: left; }
.attachment-portcall-actions { justify-content: flex-end; margin-bottom: 5px; }
.send-portcall-actions { justify-content: flex-end; margin-bottom: 5px; }
.document-generation-actions { margin-bottom: 10px; }
.document-preview-actions { margin-top: 10px; margin-bottom: 6px; }
.document-preview-actions form { margin: 0; }
.attachment-checklist { display: grid; gap: 4px; }
.attachment-checklist__item {
    min-height: 31px;
    padding: 5px 7px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    background: #fafbfd;
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius-sm);
    font-size: .78rem;
}
.attachment-checklist__item label { margin: 0; display: inline; }
.attachment-checklist__item--missing { background: #fff7f7; border-color: #e5bcbc; }
.send-mail-form { min-width: 0; }
.mail-model-reference, .document-generation-reference { margin: 0 0 5px; color: var(--sb-text-soft); font-size: .78rem; font-weight: 650; }
.mail-composer-header-fields { row-gap: 3px; }
.mail-composer-header-fields > .field { margin-bottom: 0; }
.mail-send-action {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
}
.mail-send-action__warning { margin: 0; }
.mail-composer-alternate { margin-left: auto; }
.mail-representation-tabs {
    margin: 7px 0 9px;
    overflow: visible;
    background: var(--sb-surface);
    border: 1px solid var(--sb-border);
    border-radius: var(--sb-radius);
    box-shadow: var(--sb-shadow);
}
.mail-representation-panel { margin: 0; padding: 8px 10px; background: var(--sb-surface); }
.mail-representation-panel[hidden] { display: none !important; }
.mail-representation-panel > .field:last-child { margin-bottom: 0; }
.mail-composer-inline-field {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    align-items: center;
    gap: 3px 7px;
}
.mail-composer-inline-field > label { margin: 0; }
.mail-composer-inline-field > :is(input, .subject-field, .mail-header-highlight-editor) { width: 100%; min-width: 0; }
.mail-composer-inline-field > .field-help { grid-column: 2; }
.subject-field > .mail-header-highlight-editor { flex: 1 1 auto; min-width: 0; }
.mail-header-highlight-editor {
    height: var(--sb-control-h);
    min-height: var(--sb-control-h);
    padding: 2px 4px;
    overflow: auto hidden;
    background: var(--sb-input-bg);
    border: 1px solid var(--sb-border-strong);
    border-radius: var(--sb-radius-sm);
    color: var(--sb-text);
    font-size: var(--sb-font-sm);
    line-height: 1.1;
    white-space: pre;
    outline: none;
}
.mail-header-highlight-editor:focus { border-color: var(--sb-primary); box-shadow: var(--sb-focus); }
.mail-header-highlight-editor .template-error-x {
    color: #c40000;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}
.mail-body {
    width: 100%;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}
.mail-html-preview {
    width: 100%;
    height: 192px;
    min-height: 192px;
    border: 1px solid var(--sb-border);
    background: #fff;
}
.mail-body-html {
    height: 192px;
    min-height: 0;
    max-height: 33vh;
    overflow: auto;
    overflow-wrap: normal;
    resize: vertical;
    white-space: pre;
}
.mail-preview-editor textarea.mail-body-html {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.mail-preview-editor textarea.mail-body { height: 192px; min-height: 0; }
.selection-dependent { transition: opacity .15s ease; }


/* Saving is intentionally invisible while the request is in flight.  The
   occupied space remains stable so the action buttons never jump. */
.portcall-live-status.is-saving { background: #fff8db; border-color: #e8cf78; visibility: hidden; }

/* Mail preview: readable light-grey surface, preserve newlines and highlight missing fields. */
.mail-preview-editor { background: #BBBBBB; }
.mail-body,
.mail-body-highlight-editor {
    width: 100%;
    padding: 9px 10px;
    background: #BBBBBB;
    color: #1f2933;
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .8rem;
    line-height: 1.42;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
    tab-size: 4;
}
.mail-body-highlight-editor { height: 192px; min-height: 0; outline: none; overflow: auto; }
.mail-body-highlight-editor:focus { box-shadow: inset 0 0 0 2px #3d83b5; }

.sent-mail-history { margin-top: 8px; }
.sent-mail-history__grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.sent-mail-history__group { padding: 6px 7px; border: 1px solid var(--sb-border); border-radius: var(--sb-radius-sm); background: #f7f9fb; }
.sent-mail-history__group h3 { margin: 0 0 4px; font-size: .78rem; color: #40566d; }
.sent-mail-history__group ul { margin: 0; padding-left: 17px; font-size: .78rem; }
