/* Email Marketing UI.
   Loaded BEFORE the dashboard's inline <style>, so shared classes (.status-pill, .panel,
   .small-button, ...) must NOT be redefined here - the dashboard's later rules would win.
   This file owns only the email-* components, and every size/colour comes from the dashboard
   tokens so both themes follow. Two scopes: #emailMarketing (the Broadcast -> Email page) and
   .email-sender-settings (the administrator block on the Settings page). */

#emailMarketing .email-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0;
  padding: 3px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
}

.email-modal .email-upload-status {
  color: var(--muted);
  font-size: var(--fs-xs);
  margin-top: 6px;
}
.email-modal .email-upload-status:empty {
  display: none;
}
.email-modal .ql-editor img {
  max-width: 100%;
  height: auto;
  cursor: pointer;
}
.email-modal .email-image-size {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 8px 0;
}
.email-modal .email-image-size[hidden],
.email-modal .email-image-selection[hidden] {
  display: none;
}
.email-modal .email-image-size label {
  display: grid;
  gap: 4px;
  font-size: var(--fs-xs);
}
.email-modal .email-image-size input {
  width: 110px;
  min-height: 32px;
}
.email-modal .email-image-selection {
  position: absolute;
  border: 2px solid #0078d4;
  pointer-events: none;
  z-index: 2;
}
.email-modal .email-image-selection .email-image-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 18px;
  height: 18px;
  min-height: 0;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 2px;
  background: #0078d4;
  pointer-events: auto;
  cursor: nwse-resize;
  touch-action: none;
}
.email-modal .ql-toolbar .email-image-url {
  color: #444;
}
.email-modal .ql-toolbar .email-image-url:hover {
  color: #06c;
}
/* The tab buttons are built with .small-button, so reset its border/fill here (id + class
   outranks the single class) and use the house tinted-surface active state. */
#emailMarketing .email-tabs button {
  min-height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0;
  transform: none;
}
#emailMarketing .email-tabs button:hover {
  background: #142438;
  color: var(--ink);
}
#emailMarketing .email-tabs button[aria-selected="true"] {
  background: #142438;
  color: var(--lime);
}
#emailMarketing .email-banner,
.email-sender-settings .email-banner {
  border: 1px solid var(--line);
  padding: 11px 14px;
  border-radius: 5px;
  background: var(--white);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
}
#emailMarketing .email-table,
.email-sender-settings .email-table,
.email-modal .email-table {
  width: 100%;
  border-collapse: collapse;
}
#emailMarketing .email-table td,
#emailMarketing .email-table th,
.email-sender-settings .email-table td,
.email-sender-settings .email-table th,
.email-modal .email-table td,
.email-modal .email-table th {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
/* Matches the dashboard's own table headers (mono, tracked, tinted). */
#emailMarketing .email-table th,
.email-sender-settings .email-table th,
.email-modal .email-table th {
  background: #152337;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  white-space: nowrap;
}
#emailMarketing .email-table td,
.email-sender-settings .email-table td,
.email-modal .email-table td {
  color: var(--ink);
  font-size: var(--fs-sm);
  vertical-align: middle;
}
#emailMarketing .email-table td:first-child,
.email-sender-settings .email-table td:first-child,
.email-modal .email-table td:first-child {
  max-width: 300px;
  overflow-wrap: anywhere;
}
/* The id column is a reference rather than content: muted, monospaced and never wrapped, so it
   stays a narrow fixed strip whatever the surrounding columns do. These are column helpers, so
   they have to cover the dialog tables too - those are appended to <body>, outside
   #emailMarketing, and a helper that stops at the panel edge is one the dialog silently loses. */
#emailMarketing .email-table td.email-id,
.email-modal .email-table td.email-id {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}
/* Columns that can hold arbitrarily long values get a cap and are allowed to break, so one long
   address or tag list cannot stretch the whole table. */
#emailMarketing .email-table td.email-clip,
.email-modal .email-table td.email-clip {
  max-width: 300px;
  overflow-wrap: anywhere;
}
/* The bulk-select column. A checkbox is not content: it keeps a narrow fixed width, and this
   block sits after the "first child" sizing above so it wins at equal specificity. */
#emailMarketing .email-table th.email-select,
#emailMarketing .email-table td.email-select {
  width: 1%;
  max-width: none;
  padding-inline: 10px;
  text-align: center;
  white-space: nowrap;
  overflow-wrap: normal;
}
#emailMarketing .email-table .email-select input {
  width: 15px;
  height: 15px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--green);
  cursor: pointer;
}
/* Appears only once something is ticked: how many, an option to widen the selection to every
   match, and the one destructive action - next to the table it affects. */
#emailMarketing .email-bulk {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  font-size: var(--fs-xs);
}
#emailMarketing .email-bulk[hidden] {
  display: none;
}
/* `.small-button` sets display:inline-flex, which out-ranks the UA rule for [hidden], so a
   hidden button would stay on screen. Say it explicitly, as the bar above does. */
#emailMarketing .email-bulk .small-button[hidden] {
  display: none;
}
#emailMarketing .email-bulk-count {
  color: var(--ink);
  font-weight: 600;
}
#emailMarketing .email-bulk .small-button.danger {
  color: var(--coral);
}
/* Sortable headings: the whole cell is the control. Every sortable column shows a faint caret so
   the affordance is discoverable, and the active one is solid and points the way it is ordered. */
#emailMarketing .email-table th.email-sortable {
  cursor: pointer;
  user-select: none;
}
#emailMarketing .email-table th.email-sortable:hover {
  color: var(--ink);
}
#emailMarketing .email-table th.email-sortable::after {
  margin-left: 5px;
  opacity: .35;
  content: "↕";
}
#emailMarketing .email-table th.email-sortable.asc::after {
  opacity: 1;
  content: "↑";
}
#emailMarketing .email-table th.email-sortable.desc::after {
  opacity: 1;
  content: "↓";
}
#emailMarketing .email-table th.email-sortable:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}
/* Every control in the table toolbar shares one height, so the icon buttons line up with the
   search box instead of sitting proud of it. The row actions keep their own 30px sizing: they
   live in a table cell, not this toolbar. */
#emailMarketing .panel-heading .email-actions {
  --control: 34px;
}
#emailMarketing .panel-heading .email-actions .icon-button {
  width: var(--control);
  height: var(--control);
  min-height: var(--control);
}
/* The table's search box sits in the toolbar, beside the buttons rather than on its own row. */
#emailMarketing .email-actions .email-search {
  width: 210px;
  height: var(--control, 34px);
  min-height: var(--control, 34px);
  padding: 0 10px;
}
/* The status filter sits next to the search box, so it is sized like one. The base field styling
   in the host document already covers a select (it is listed with input/textarea/.search), so
   only the toolbar's own height and width are missing here. */
#emailMarketing .email-actions .email-status-filter {
  width: 152px;
  height: var(--control, 34px);
  min-height: var(--control, 34px);
  padding: 0 8px;
}
/* The toolbar's primary action is filled, so the main thing to do stands out from the icons
   beside it. The table's own accent (Send / schedule) stays outlined - it lives in a row. */
#emailMarketing .panel-heading .email-actions .icon-button.accent {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}
#emailMarketing .panel-heading .email-actions .icon-button.accent:hover {
  border-color: var(--blue);
  background: #3d86ff;
}
/* The export control is an anchor styled as an icon button, so it needs the link decoration
   removing and a pointer to match a button. */
#emailMarketing .email-actions a.icon-button {
  text-decoration: none;
  cursor: pointer;
}
#emailMarketing .email-actions,
.email-sender-settings .email-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Row actions are icons, so they have to be compact: the dashboard's .icon-button is 38px,
   sized for a toolbar, and a row can offer a dozen of them. */
#emailMarketing .email-table .email-actions .icon-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
}
/* The one action that changes delivery state, so it keeps a visible accent. */
#emailMarketing .email-table .email-actions .icon-button.accent {
  border-color: var(--blue);
  color: var(--blue);
}
/* Row actions beyond the first three live in this menu. It is positioned against the viewport
   by JS because it has to escape the table's scrolling wrapper, which would clip it. */
.email-menu {
  position: fixed;
  z-index: 40;
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--white);
  box-shadow: 0 16px 40px #03091240;
}
.email-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.email-menu-item:hover {
  background: var(--paper);
}
.email-menu-item svg {
  flex: none;
  width: 14px;
  height: 14px;
}
.email-menu-item.danger {
  color: #f17570;
}
.email-menu-item:disabled {
  opacity: .5;
  cursor: not-allowed;
}
/* Column sizing. Details takes whatever is left over, and Actions shrinks to just its icons:
   width:1% on a table cell is the shorthand for "only as wide as the content". The icons must
   not wrap, or the browser would size the column to a single icon and stack the rest. */
#emailMarketing .email-table th:last-child,
#emailMarketing .email-table td:last-child {
  width: 1%;
  white-space: nowrap;
}
#emailMarketing .email-table .email-actions {
  flex-wrap: nowrap;
}
/* The page's own pagination sits straight under the table. The .email-controls rule further
   down is scoped to .email-modal, which never matches here (dialogs are appended to <body>),
   so the page row needs its own top spacing. */
#emailMarketing .email-controls {
  padding-top: 14px;
}
/* Sender accounts are one card row each instead of a table, so the identity, the sending
   limits and the actions sit together and the actions can be icons. Reuses the dashboard's
   .icon-button / .status-pill / .count-chip rather than restyling them here. */
.email-sender-settings .sender-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}
.email-sender-settings .sender-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.email-sender-settings .sender-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
}
.email-sender-settings .sender-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.email-sender-settings .sender-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48a27b;
}
.email-sender-settings .sender-dot.pending {
  background: #d8a13a;
}
.email-sender-settings .sender-dot.off {
  background: #b9c2bb;
}
.email-sender-settings .sender-copy {
  min-width: 0;
}
.email-sender-settings .sender-name {
  color: var(--ink);
  font-weight: 700;
}
.email-sender-settings .sender-meta {
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  overflow-wrap: anywhere;
}
.email-sender-settings .sender-side {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* The empty state and the prerequisite banner render outside .email-modal, so they need
   their own rules: .email-hint/.email-banner are only styled inside the modal above. */
.email-sender-settings .email-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: var(--lh-normal);
}
.email-sender-settings .email-banner {
  margin-top: 10px;
}
/* Matches the dashboard's .dry-notice tint, which is what this warns about: email cannot
   send until the encryption key and the public HTTPS URL are saved. */
.email-sender-settings .email-banner.warn {
  border-color: #66532d;
  background: #30291d;
  color: #f0c56a;
}
/* One shell for every email modal: a titled header, a scrollable body and a bordered footer.
   The dialog is a flex column so the body absorbs the leftover height and the header and
   footer stay put however long the form is. */
.email-modal {
  display: flex;
  flex-direction: column;
  width: min(880px, 95vw);
  max-height: 88vh;
  padding: 0;
  overflow: hidden;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px #03091247;
}
.email-modal::backdrop {
  background: #030912bd;
  backdrop-filter: blur(2px);
}
.email-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.email-modal-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: var(--track-heading);
  line-height: var(--lh-tight);
}
.email-modal-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 18px 20px 20px;
}
.email-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: var(--white);
}
/* Dialogs opened just to read something (reports, previews) have no actions. */
.email-modal-foot:empty {
  display: none;
}
.email-modal .email-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.email-modal label {
  display: block;
  color: var(--muted);
  margin: 0 0 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.email-modal input:not([type="checkbox"]),
.email-modal select,
.email-modal textarea {
  width: 100%;
  min-height: 38px;
  /* The surface colour, not the page colour. --paper is the page canvas (#f4f6f9 on the
     light theme), which against the white dialog reads as a greyed-out, disabled field. */
  background: var(--white);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 5px;
  padding: 9px 11px;
  font-size: var(--fs-sm);
}
/* A control that genuinely cannot be edited keeps the page colour, so "nothing to fill in
   here" is still distinguishable now that every fillable field is white. */
.email-modal input:not([type="checkbox"]):disabled,
.email-modal select:disabled,
.email-modal textarea:disabled {
  background: var(--paper);
  color: var(--muted);
  cursor: not-allowed;
}
.email-modal input:not([type="checkbox"]):focus,
.email-modal select:focus,
.email-modal textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 2px #4d8bff24;
}
/* A checkbox label is a control, not a field caption. */
.email-modal label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 400;
}
.email-modal label:has(input[type="checkbox"]) input {
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--blue);
}
.email-modal textarea {
  min-height: 90px;
}
/* The one piece of OS-drawn chrome in a dialog: without this the "Choose File" button
   renders as unstyled system grey next to the app's own buttons. The wrapper is already
   covered by the field rule above, so only the inner button needs matching. */
.email-modal input[type="file"] {
  padding: 6px 8px;
}
.email-modal input[type="file"]::file-selector-button {
  min-height: 26px;
  margin-right: 10px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.email-modal input[type="file"]::file-selector-button:hover {
  border-color: var(--muted);
}
.email-modal .email-full {
  grid-column: 1/-1;
}
/* Named block inside a long form, e.g. the sender editor. */
.email-modal .email-section {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.email-modal .email-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.email-modal .email-section-title {
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}
.email-modal .email-section-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: var(--fs-xs);
}
/* Audience preview: restates the four audience controls in words, because "all contacts"
   overrides the list and the IDs while a segment narrows whatever they select. */
.email-modal .email-audience {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--paper);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}
.email-modal .email-audience.warn {
  color: var(--coral);
}
.email-modal .email-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px 0;
}
/* Contact picker: a filterable checkbox list, used when adding contacts to a list. The extra
   class in the selector is needed to outrank the shared checkbox-label rule above it. */
.email-modal .email-pick-list {
  max-height: 320px;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
}
.email-modal .email-pick-list .email-pick {
  margin: 0;
  padding: 8px 9px;
  border-radius: 4px;
  cursor: pointer;
}
.email-modal .email-pick-list .email-pick:hover {
  background: var(--paper);
}
.email-modal .email-pick-list .email-pick input {
  flex: none;
  width: auto;
  min-height: 0;
  margin: 0;
  accent-color: var(--blue);
}
.email-modal .email-pick-list .email-pick.is-member {
  opacity: .6;
  cursor: default;
}
.email-modal .email-pick-list .email-pick.is-member:hover {
  background: transparent;
}
.email-modal .email-pick-name {
  font-weight: 600;
}
.email-modal .email-pick-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--fs-2xs);
  text-align: right;
}

/* Campaign results: what was sent, how it landed, then the per-recipient detail. */
.email-modal .email-report-overview {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.email-modal .email-report-name {
  color: var(--ink);
  font-size: var(--fs-lg);
  font-weight: 700;
}
.email-modal .email-report-subject {
  width: 100%;
  color: var(--muted);
  font-size: var(--fs-xs);
}
/* The headline numbers, one tile each, so the eye can compare them instead of reading a
   sentence of "KEY: n · KEY: n". */
.email-modal .email-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
  margin: 16px 0 20px;
}
.email-modal .email-stat {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.email-modal .email-stat-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}
.email-modal .email-stat-value {
  margin-top: 5px;
  color: var(--ink);
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
}
.email-modal .email-stat.good .email-stat-value {
  color: #35ce91;
}
.email-modal .email-stat.bad .email-stat-value {
  color: #ff6964;
}
.email-modal .email-stat-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: var(--fs-2xs);
}
.email-modal .email-report-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.email-modal .email-report-title {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.email-modal .email-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.email-modal .email-report-error {
  max-width: 240px;
  color: var(--muted);
  font-size: var(--fs-xs);
  overflow-wrap: anywhere;
}
/* Attempts is a single digit, so it sizes to its content. Without this the empty Error column
   claims an equal share of the width and the table reads as mostly whitespace. */
.email-modal .email-report-table th:nth-child(3),
.email-modal .email-report-table td:nth-child(3) {
  width: 1%;
  white-space: nowrap;
}
.email-modal .email-report-note {
  margin: 12px 0 0;
}
/* Campaign log: the timeline of what was done, then the delivery status it came to. */
.email-modal .email-log-title {
  margin: 18px 0 10px;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}
/* The time and the actor size to their content so the action takes the slack. */
.email-modal .email-log-table th:first-child,
.email-modal .email-log-table td:first-child,
.email-modal .email-log-table th:last-child,
.email-modal .email-log-table td:last-child {
  width: 1%;
  white-space: nowrap;
}
.email-modal .email-log-table td:first-child {
  color: var(--muted);
}
.email-modal .email-log-failures {
  margin: 12px 0 0;
  padding-left: 18px;
  color: #f17570;
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}
/* List members: the dialog's one table that carries row actions, so the id and the actions size to
   their content and the contact's own columns take the slack. The actions cell gets what the
   page's tables give theirs - a flex row that does not wrap, with the icons at row size rather
   than at the dashboard's toolbar size. */
.email-modal .email-member-table th:first-child,
.email-modal .email-member-table td:first-child,
.email-modal .email-member-table th:last-child,
.email-modal .email-member-table td:last-child {
  width: 1%;
  white-space: nowrap;
}
.email-modal .email-member-table .email-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
}
.email-modal .email-member-table .email-actions .icon-button {
  width: 30px;
  height: 30px;
  min-height: 30px;
}
/* Full email content. The envelope, then the message in a device frame, then the plain-text
   half: one reading column, so it looks like a message to review rather than a form to fill in. */
.email-modal .email-preview-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.email-modal .email-preview-field {
  display: grid;
  gap: 5px;
  flex: 1 1 240px;
  min-width: 220px;
  margin: 0;
}
.email-modal .email-preview-label {
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}
/* Desktop and Mobile are two states of one setting, so they read as one control. */
.email-modal .email-segmented {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.email-modal .email-segment {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}
.email-modal .email-segment[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 1px 2px #0b1a2b24;
}
.email-modal .email-envelope {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px 16px;
  margin: 0 0 14px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.email-modal .email-envelope dt {
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
  line-height: 1.8;
}
.email-modal .email-envelope dd {
  margin: 0;
  color: var(--ink);
  font-size: var(--fs-sm);
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.email-modal .email-envelope-subject {
  font-weight: 700;
}
/* The stage is the recessed surface the "device" sits on, so the email reads as a rendering
   of the message rather than as another panel of the dashboard. */
.email-modal .email-preview-stage {
  display: flex;
  justify-content: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}
.email-modal .email-preview-device {
  width: 100%;
  transition: width .2s ease;
}
.email-modal .email-preview-device.mobile {
  width: 375px;
  max-width: 100%;
}
.email-modal .email-preview-text {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
/* What each placeholder became for this recipient. Sits under the envelope so it is read with
   the message rather than hunted for, and wraps so a long token list stays legible. */
.email-modal .email-resolved {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 10px;
  margin: 0 0 14px;
}
.email-modal .email-resolved-title {
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}
.email-modal .email-resolved-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: var(--fs-2xs);
}
.email-modal .email-resolved-token {
  color: var(--muted);
}
.email-modal .email-resolved-arrow {
  color: var(--muted);
}
.email-modal .email-resolved-value {
  color: var(--ink);
  font-weight: 600;
}
/* A fallback is the same for everybody, which is what makes it look like nothing switched. */
.email-modal .email-resolved-value.fallback {
  color: #e3b341;
}
.email-modal .email-resolved-none,
.email-modal .email-resolved-note {
  color: var(--muted);
  font-size: var(--fs-2xs);
  line-height: var(--lh-snug);
}
.email-modal .email-preview-heading {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--track-micro);
  text-transform: uppercase;
}
/* No height cap and no inner scrollbar: the dialog body is the only scroll container, so the
   page does not end up with one scrollbar nested inside another. */
.email-modal .email-preview-pre {
  margin: 0;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* Import dialog. The mapping selectors stay folded away because the file this imports needs no
   changes; the preview then reports what would be created and what would be rejected. */
.email-modal .email-map > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: var(--fs-xs);
}
.email-modal .email-map[open] > summary {
  margin-bottom: 10px;
}
.email-modal .email-import-summary {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.email-modal .email-import-summary.good {
  color: #35ce91;
}
/* A partly-valid file is neither a success nor a failure, so it gets its own tone. */
.email-modal .email-import-summary.warn {
  color: #e3b341;
}
.email-modal .email-import-summary.bad {
  color: #f17570;
}
.email-modal .email-import-errors {
  margin: 0 0 10px;
  padding-left: 18px;
  color: #f17570;
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
}
/* A failed save is a boxed alert, not a coloured line of text. */
.email-modal .email-error:not(:empty) {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid #5a3941;
  border-radius: 5px;
  background: #241d27;
  color: #ff8a83;
  white-space: pre-wrap;
}
.email-modal .email-hint {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: var(--lh-normal);
  margin: 8px 0;
}
/* The preview frame and the Quill editor stay a LIGHT island in both themes on purpose:
   they represent the email itself, which is authored for a white mail-client canvas.
   Only the surrounding chrome (borders, radius) follows the theme. */
.email-modal iframe {
  background: white;
  width: 100%;
  height: 350px;
  border: 1px solid var(--line);
  border-radius: 5px;
}
.email-modal .ql-container {
  height: 250px;
  background: white;
  color: #17212b;
}
/* quill.snow.css sets its own Helvetica stack; keep the app font inside the editor. */
.email-modal .ql-editor {
  font-family: var(--sans);
}
.email-modal .ql-toolbar {
  background: #f3f5f8;
}
.email-modal .email-step {
  border: 1px solid var(--line);
  padding: 14px;
  margin: 10px 0;
  border-radius: 5px;
}
.email-modal pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.email-modal summary {
  cursor: pointer;
  margin: 10px 0;
}
.email-modal .email-rule {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.email-modal .email-rule > * {
  flex: 1;
  min-width: 100px;
}
@media (max-width: 650px) {
  .email-modal .email-fields {
    grid-template-columns: 1fr;
  }
  #emailMarketing .email-table td,
  .email-sender-settings .email-table td,
  .email-modal .email-table td {
    padding: 8px;
  }
  .email-sender-settings .sender-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .email-sender-settings .sender-side {
    flex-wrap: wrap;
    justify-content: space-between;
  }
}

/* ============================================================================
   Light theme - ADDITIVE ONLY, and LAST so it wins within this file.
   Everything above already follows the dashboard colour tokens, so most surfaces
   flip for free; only the deliberately hard-coded values need a counterpart.
   ============================================================================ */
html[data-theme="light"] #emailMarketing .email-tabs button:hover {
  background: #eef2f7;
  color: #16202b;
}
html[data-theme="light"] #emailMarketing .email-tabs button[aria-selected="true"] {
  background: #e2edfb;
  color: #0b5fb0;
}
html[data-theme="light"] #emailMarketing .email-table th,
html[data-theme="light"] .email-sender-settings .email-table th,
html[data-theme="light"] .email-modal .email-table th {
  background: #f2f5f8;
  color: #5d6b7a;
}
html[data-theme="light"] .email-modal::backdrop {
  background: #1018284d;
}
html[data-theme="light"] .email-modal {
  box-shadow: 0 24px 80px #1018282e;
}
html[data-theme="light"] .email-modal .email-error:not(:empty) {
  border-color: #e6c3c5;
  background: #fdecec;
  color: #b3281f;
}
html[data-theme="light"] .email-modal input:focus,
html[data-theme="light"] .email-modal select:focus,
html[data-theme="light"] .email-modal textarea:focus {
  border-color: #0b74e0;
  box-shadow: 0 0 0 2px #0b74e029;
}
/* Status dots carry meaning by colour, so they need the light-theme greens/ambers. */
html[data-theme="light"] .email-sender-settings .sender-dot {
  background: #12a06a;
}
html[data-theme="light"] .email-sender-settings .sender-dot.pending {
  background: #a86f12;
}
html[data-theme="light"] .email-sender-settings .sender-dot.off {
  background: #b0b8c0;
}
html[data-theme="light"] .email-sender-settings .email-banner.warn {
  border-color: #f0dcae;
  background: #fdf3d9;
  color: #8a5a12;
}
