/* ═══════════════════════════════════════════════════════════════════════════════════════════════════
   css/admin.css — the Karga Mailer admin, dark theme. The only stylesheet of the admin.

    1. Tokens            2. Base              3. Layout (sidebar, top bar, page)    4. Sign-in page
    5. Cards             6. Forms             7. Buttons                          8. Tables
    9. Badges and chips 10. Messages         11. Tabs, stepper, pagination        12. Dialogs
   13. Page blocks: dashboard, contacts, campaigns, results, codes, content, settings, mail viewer
   14. Tag picker and email editor           15. Small screens

   Markup conventions (partials/admin_form_helpers.php writes them):
     .form-card > h3                         a card with a title
     .field-row > .field                     fields side by side (wraps on small screens)
     .field > label + control + .field-hint  one labelled control
     label.check > input + text              a checkbox or radio with its text
     .form-actions                           the buttons under a form
   ═══════════════════════════════════════════════════════════════════════════════════════════════════ */

/* ── 1. Tokens ──────────────────────────────────────────────────────────────────────────────────── */
:root {
    color-scheme: dark;             /* native pickers, file buttons, scrollbars and dialogs in dark */

    --bg:             #14151a;      /* page and control background */
    --surface:        #1c1d23;      /* sidebar, cards */
    --surface2:       #24252c;      /* table heads, raised rows */
    --bd:             #34363f;      /* borders of controls and cards */
    --bd2:            #26272e;      /* subtle dividers */
    --bd-strong:      #4a4c57;      /* hovered borders */
    --hover:          rgba(255, 255, 255, .05);

    --accent:         #46aed0;      /* Karga blue: links, focus, active */
    --accent-strong:  #1f7fa0;      /* solid fills carrying white text (4.5:1) */
    --accent-strong-h:#196a86;      /* hover: darker, so white text stays readable (6:1) */
    --accent-soft:    rgba(70, 174, 208, .12);

    --text:           #e4e4e8;
    --text2:          #b0b0b8;
    --muted:          #8b8b98;      /* ≥ 4.5:1 on --surface */

    --danger:         #fb2c36;
    --danger-soft:    rgba(251, 44, 54, .12);
    --success:        #00c951;
    --success-strong: #1e8f4c;
    --success-soft:   rgba(0, 201, 81, .13);
    --warn:           #f0b100;
    --warn-soft:      rgba(240, 177, 0, .12);
    --info:           #00b8db;
    --info-soft:      rgba(0, 184, 219, .13);

    --radius-sm:      6px;
    --radius:         8px;
    --radius-lg:      10px;
    --gap-sm:         8px;
    --gap:            16px;
    --gap-lg:         24px;
    --control-h:      38px;
    --control-h-sm:   30px;
    --ring:           0 0 0 3px rgba(70, 174, 208, .28);
    --shadow:         0 4px 20px rgba(0, 0, 0, .2);
    --font:           'Poppins', system-ui, sans-serif;
    --font-mono:      ui-monospace, SFMono-Regular, Consolas, monospace;
    --sidebar-w:      240px;
}

/* ── 2. Base ────────────────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
/* The hidden attribute always hides, whatever display a class sets (scripts toggle it). */
[hidden] { display: none !important; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}
h1 { font-size: 20px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--font-mono); }
code { font-size: .88em; background: rgba(255, 255, 255, .07); color: #d5e6f3; padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
strong { font-weight: 600; }
img { max-width: 100%; }
ul, ol { padding-left: 20px; }
::selection { background: rgba(70, 174, 208, .35); }

/* Keyboard focus is always visible; the mouse does not draw rings. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
main:focus { outline: none; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--accent-strong);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 600;
    transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* ── 3. Layout ──────────────────────────────────────────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--bd2);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    visibility: visible;
    transition: transform .25s ease, visibility 0s linear 0s;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 0 17px;
    border-bottom: 1px solid var(--bd2);
    flex-shrink: 0;
}
.sidebar-logo img { height: 28px; }
.logo-label { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.logo-label span { color: var(--accent); }
.sidebar-section-title { font-size: 12px; font-weight: 500; color: var(--muted); padding: 16px 22px 4px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px 0; }
.sidebar-nav:last-of-type { flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--text2);
    font-size: 14px;
    transition: background .15s, color .15s;
}
.sidebar-nav a i { width: 18px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar-nav a:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--bd2); flex-shrink: 0; }
.sidebar-footer .sidebar-nav { padding: 0 0 4px; }
.sidebar-user { display: flex; align-items: center; gap: 8px; padding: 2px 10px 8px; font-size: 13px; color: var(--text2); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.sidebar-user i { font-size: 15px; color: var(--muted); }
.sidebar-user span { color: var(--muted); }
.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--text2);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.logout-btn i { width: 18px; text-align: center; font-size: 16px; }
.logout-btn:hover { color: var(--danger); background: var(--danger-soft); }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 199; }

.main-content {
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    flex: 1;
    min-width: 0;
}
/* Phones only (see section 15): on desktop the sidebar is always visible, so there is no top bar. */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: none;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--bd2);
}
.topbar-title { font-size: 14px; font-weight: 700; color: var(--text); }
.topbar-title span { color: var(--accent); }
.sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text2);
    font-size: 18px;
    cursor: pointer;
}
.sidebar-toggle:hover { background: var(--bd); color: var(--text); }

.content-wrap { width: 100%; max-width: 1400px; margin: 0 auto; padding: 28px 24px 60px; flex: 1; }

.page-header { margin-bottom: var(--gap-lg); }
.page-header p { color: var(--text2); margin-top: 2px; }
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.section-header h2 { font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.section-header-actions { display: flex; gap: var(--gap-sm); align-items: center; flex-wrap: wrap; }
.back-row { margin-bottom: 20px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }

/* ── 4. Sign-in page ────────────────────────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--bd);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .45);
}
.login-card h2 { font-size: 18px; font-weight: 500; text-align: center; margin-bottom: 24px; }
.login-card label { display: block; font-size: 13px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.login-card input:not([type=checkbox]) { margin-bottom: 16px; }
.login-card button { width: 100%; height: 40px; margin-top: 4px; border: 0; border-radius: var(--radius); background: var(--accent-strong); color: #fff; font: 500 14px var(--font); cursor: pointer; }
.login-card button:hover { background: var(--accent-strong-h); }
.login-remember { display: flex !important; align-items: center; gap: 8px; color: var(--muted) !important; font-weight: 400 !important; margin-bottom: 16px !important; cursor: pointer; }
.login-error { background: var(--danger-soft); border: 1px solid rgba(251, 44, 54, .3); color: var(--danger); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 20px; font-size: 13px; }

/* ── 5. Cards ───────────────────────────────────────────────────────────────────────────────────── */
.form-card,
.card {
    background: var(--surface);
    border: 1px solid var(--bd2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    min-width: 0;
}
.form-card { padding: 22px 24px; }
.form-card > h2,
.form-card > h3,
.form-card > form > h3 { margin-bottom: 14px; }
.form-card > :last-child { margin-bottom: 0; }
details.form-card > summary { cursor: pointer; font-weight: 600; color: var(--text); list-style-position: inside; }
details.form-card > summary .hint { font-weight: 400; margin-left: 6px; }
details.form-card[open] > summary { margin-bottom: 16px; }
.narrow-card { max-width: 620px; }
.card-success { border-color: rgba(0, 201, 81, .45); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head > h3 { margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 20px; align-items: start; margin-bottom: 20px; }
.card-grid-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.card-grid > .form-card, .card-grid > .card, .card-grid > .card-stack { margin: 0; }
.card-stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card-stack > .form-card { margin: 0; }

.card-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--bd2); font-weight: 600; }
.card-header .hint { font-weight: 400; }
.card-title { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.card-body-scroll { position: relative; overflow-x: auto; }
.card-lg-gap { margin-bottom: 28px; }
.card-empty { color: var(--muted); padding: 8px 0; }

/* ── 6. Forms ───────────────────────────────────────────────────────────────────────────────────── */
/* One look for every text-like control, select and textarea. */
input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=color]):not([type=file]):not([type=range]):not(.tp-input):not(.jodit *),
select:not(.jodit *),
textarea:not(.jodit *) {
    width: 100%;
    min-height: var(--control-h);
    padding: 7px 12px;
    background-color: var(--bg);    /* colour only, so the select arrow and search icon below survive */
    color: var(--text);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    font: 14px/1.4 var(--font);
    transition: border-color .15s, box-shadow .15s;
}
textarea:not(.jodit *) { min-height: 96px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select:not([multiple]):not(.jodit *) {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8b98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    cursor: pointer;
}
select[multiple] { padding: 4px; }
select option, select optgroup { background: var(--surface); color: var(--text); }
input[type=search] {
    padding-left: 34px !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b8b98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 11px center;
    background-size: 15px;
}
::placeholder { color: var(--muted); opacity: 1; }
input:not(.tp-input):not(.jodit *):hover,
select:not(.jodit *):hover,
textarea:not(.jodit *):hover { border-color: var(--bd-strong); }
input:not(.tp-input):not(.jodit *):focus,
select:not(.jodit *):focus,
textarea:not(.jodit *):focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input:disabled, select:disabled, textarea:disabled, fieldset:disabled input { opacity: .55; cursor: not-allowed; }
input[readonly]:not(.tp-input), textarea[readonly] { background-color: var(--surface2) !important; color: var(--text2); }
input:user-invalid, select:user-invalid, textarea:user-invalid, [aria-invalid=true] { border-color: var(--danger) !important; }
input[type=date], input[type=datetime-local], input[type=number] { font-variant-numeric: tabular-nums; }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=datetime-local]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .75; }
input[type=file] {
    width: 100%;
    padding: 4px;
    background-color: var(--bg);
    border: 1px dashed var(--bd-strong);
    border-radius: var(--radius);
    color: var(--text2);
    font: 13px var(--font);
    cursor: pointer;
}
input[type=file]:hover { border-color: var(--accent); }
input[type=file]:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[type=file]::file-selector-button {
    margin-right: 10px;
    padding: 6px 12px;
    border: 1px solid var(--bd);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--text);
    font: 500 13px var(--font);
    cursor: pointer;
}
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--accent-strong); cursor: pointer; flex-shrink: 0; }
input[type=color].color-swatch { width: 44px; height: var(--control-h); padding: 3px; border: 1px solid var(--bd); border-radius: var(--radius); background: var(--bg); cursor: pointer; flex-shrink: 0; }

/* Small controls: toolbars, bulk bar, table rows. */
.input-sm,
.bulk-bar select, .bulk-bar input:not([type=checkbox]),
.data-table select, .sub-table select {
    min-height: var(--control-h-sm) !important;
    padding-top: 3px !important;
    padding-bottom: 3px !important;
    font-size: 13px !important;
    width: auto;
}
.input-mono { font-family: var(--font-mono) !important; font-size: 13px !important; }

/* One label, one hint. */
.field { margin-bottom: var(--gap); min-width: 0; }
.field > label:not(.check),
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
}
.field > input[type=number] { max-width: 220px; }   /* a number never needs the full width */
.field-hint { margin-top: 6px; font-size: 12px; line-height: 1.5; color: var(--muted); }
.field > .field-hint:first-of-type:not(:last-child) { margin: -2px 0 8px; }   /* a hint above the control */
.label-optional { font-weight: 400; color: var(--muted); }
.req { color: var(--danger); margin-left: 2px; }
.field-row,
.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: var(--gap);
    margin-bottom: var(--gap);
}
.field-row > .field, .field-grid > .field { margin-bottom: 0; }

/* Checkboxes and radios with their text. */
label.check {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin: 6px 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
}
label.check input { margin-top: 1px; }
.choice-group { border: 0; display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--gap); min-width: 0; }
.choice-group > legend { margin-bottom: 6px; }
.fieldset { border: 1px solid var(--bd2); border-radius: var(--radius); padding: 12px 16px 16px; margin-bottom: var(--gap); min-width: 0; }
.fieldset > legend { padding: 0 6px; font-size: 13px; font-weight: 600; color: var(--text2); }
.fieldset > :last-child { margin-bottom: 0; }

.input-group { display: flex; gap: var(--gap-sm); align-items: center; }
.input-group > input:not([type=color]):not([type=checkbox]) { flex: 1 1 auto; min-width: 0; }
.input-group > select { width: auto; flex: 0 0 auto; }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.form-card > .form-actions:first-child { margin-top: 0; }
.autosave-status { margin-left: auto; font-size: 12px; color: var(--muted); }
.form-plain { margin-top: 12px; }
.form-section-title { margin: 26px 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.form-section-title:first-child { margin-top: 0; }

/* A short form in a line: label, control, button. */
.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); margin: 0; vertical-align: middle; max-width: 100%; }
.inline-form > label:not(.check) { font-size: 13px; color: var(--text2); }
.inline-form > input:not([type=hidden]):not([type=checkbox]), .inline-form > select { width: auto; flex: 1 1 220px; min-width: 0; }
.inline-form > input[type=datetime-local] { flex: 0 1 240px; }
.form-card > .inline-form, .form-card > form.inline-form { display: flex; }
td > .inline-form { flex-wrap: nowrap; }
td > .inline-form > select { flex: 0 1 auto; }

/* Search and filters above a list. */
.filter-bar { display: flex; flex-wrap: wrap; gap: var(--gap-sm); align-items: center; margin-bottom: var(--gap); }
.filter-bar > input[type=search], .filter-bar > input[type=text] { flex: 1 1 220px; width: auto; max-width: 380px; }
.filter-bar > select { flex: 0 1 190px; width: auto; }
.filter-bar > .tagpicker { flex: 0 1 230px; }
.filter-bar > label:not(.visually-hidden) { font-size: 13px; color: var(--text2); }
.filter-bar-end { margin-left: auto; }

/* ── 7. Buttons ─────────────────────────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--control-h);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: 500 14px/1 var(--font);
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.btn i { font-size: 16px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong-h); border-color: var(--accent-strong-h); }
.btn-secondary { background: transparent; border-color: var(--bd); color: var(--text2); }
.btn-secondary:hover:not(:disabled) { background: var(--hover); border-color: var(--bd-strong); color: var(--text); }
.btn-danger { background: transparent; border-color: rgba(251, 44, 54, .38); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-ghost { background: transparent; color: var(--text2); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.btn-sm { height: var(--control-h-sm); padding: 0 12px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-xs i, .btn-sm i { font-size: 14px; }
.btn-icon { padding: 0; width: var(--control-h); }
.btn-xs.btn-icon { width: 26px; }
.btn-sm.btn-icon { width: var(--control-h-sm); }
.row-actions, .button-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
td > .row-actions { flex-wrap: nowrap; }   /* one line per table row; the table scrolls instead */
.row-actions-end { justify-content: flex-end; }
.button-row { gap: 10px; }
.cell-actions { white-space: nowrap; }
.cell-actions > * + * { margin-left: 6px; }

/* ── 8. Tables ──────────────────────────────────────────────────────────────────────────────────── */
.table-container {
    position: relative;      /* keeps absolutely positioned content (screen-reader labels) inside the scroller */
    background: var(--surface);
    border: 1px solid var(--bd2);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
    margin-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}
/* Inside a card a table is flat: no second shadow, no second background. */
.form-card .table-container, .card .table-container { background: transparent; box-shadow: none; border-radius: var(--radius); margin-bottom: 12px; }
.data-table, .sub-table, .meta-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table, .sub-table { min-width: 520px; }
.data-table th, .sub-table th {
    background: var(--surface2);
    color: var(--text2);
    font-weight: 500;
    text-align: left;
    padding: 10px 12px;
    white-space: nowrap;
    border-bottom: 1px solid var(--bd);
}
.data-table td, .sub-table td { padding: 10px 12px; border-bottom: 1px solid var(--bd2); vertical-align: middle; }
.data-table tbody tr:last-child td, .sub-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td, .sub-table tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.ctr { text-align: center !important; }
.row-link { color: var(--text); }
.row-link:hover { color: var(--accent); }
.row-clickable { cursor: pointer; }
.row-muted td { opacity: .55; }
.row-current td { background: var(--accent-soft) !important; }
.cell-check { width: 40px; }
.cell-muted { color: var(--muted); font-size: 12px; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.cell-nowrap { white-space: nowrap; }
.cell-strong { font-weight: 600; }
.cell-upper { text-transform: uppercase; }
.cell-break { word-break: break-all; }
.cell-truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-error { font-size: 12px; color: var(--danger); margin-top: 3px; }
.cell-empty { color: var(--muted); font-size: 12px; }
.col-dot { width: 24px; text-align: center; }
.table-empty { text-align: center; padding: 40px 16px !important; color: var(--muted); }
.table-empty i { display: block; font-size: 28px; margin-bottom: 8px; color: var(--bd); }
.meta-table td { padding: 6px 0; vertical-align: top; }
.meta-table td:first-child { color: var(--muted); width: 150px; white-space: nowrap; }
.activity-table { table-layout: fixed; }

/* ── 9. Badges and chips ────────────────────────────────────────────────────────────────────────── */
.badge, .status-badge, .event-chip, .provider-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
    background: var(--surface2);
    color: var(--text2);
}
.badge-success, .badge-status-confirmed, .badge-recipient-sent, .badge-status-sent, .status-camp-sent, .ev-delivered { background: var(--success-soft); color: var(--success); }
.badge-danger, .badge-status-unsubscribed, .badge-recipient-failed, .badge-status-failed, .status-camp-failed,
.ev-spamreport, .ev-rendering_failure, .ev-unsubscribe, .ev-group_unsubscribe { background: var(--danger-soft); color: var(--danger); }
.badge-warn, .badge-status-pending, .badge-recipient-uncertain, .badge-status-paused, .badge-status-sending, .badge-status-preparing,
.status-camp-sending, .status-camp-preparing, .status-camp-paused, .ev-bounce, .ev-dropped, .ev-delivery_delay { background: var(--warn-soft); color: var(--warn); }
.badge-info, .badge-status-bounced, .badge-recipient-pending, .badge-recipient-claiming, .badge-status-review, .badge-status-scheduled,
.status-camp-review, .status-camp-scheduled, .ev-open, .ev-click, .provider-badge { background: var(--info-soft); color: var(--info); }
.badge-neutral, .badge-recipient-skipped, .badge-status-draft, .status-camp-draft, .ev-send, .ev-processed, .ev-deferred { background: rgba(255, 255, 255, .06); color: var(--text2); }
.status-camp-partial { box-shadow: inset 0 0 0 1px var(--warn); }
.status-method { font-size: 11px; color: var(--muted); margin-left: 5px; }

.tag-chip {
    --tag: #6495ed;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 10px;
    border-radius: 999px;
    border: 1px solid rgba(100, 149, 237, .35);
    border-color: color-mix(in srgb, var(--tag) 40%, transparent);
    background: rgba(100, 149, 237, .12);
    background: color-mix(in srgb, var(--tag) 15%, transparent);
    color: var(--tag);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}
.tag-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-chips + form { margin-top: 12px; }
.tag-remove { display: inline-flex; padding: 0; border: 0; background: none; color: inherit; opacity: .7; cursor: pointer; font-size: 12px; }
.tag-remove:hover { opacity: 1; color: var(--danger); }

/* ── 10. Messages ───────────────────────────────────────────────────────────────────────────────── */
.flash {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 11px 16px;
    margin-bottom: 18px;
    border-radius: var(--radius);
    border: 1px solid;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.flash i { font-size: 18px; flex-shrink: 0; }
.flash a { color: inherit; text-decoration: underline; }
.flash-success { background: var(--success-soft); border-color: rgba(0, 201, 81, .3); color: var(--success); }
.flash-error   { background: var(--danger-soft);  border-color: rgba(251, 44, 54, .3); color: #ff6b73; }
.flash-warning { background: var(--warn-soft);    border-color: rgba(240, 177, 0, .35); color: var(--warn); }
.flash-info, .alert-info { background: var(--accent-soft); border: 1px solid rgba(70, 174, 208, .3); color: var(--accent); }
.alert-info { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.hint { font-size: 13px; line-height: 1.55; color: var(--text2); }
p.hint { margin-bottom: 12px; }
p.hint:last-child { margin-bottom: 0; }
.hint i { margin-right: 4px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px; }
.empty-state i { display: block; font-size: 32px; margin-bottom: 12px; color: var(--bd); }
.empty-note { color: var(--muted); font-size: 13px; padding: 4px 0 12px; }
.text-success { color: var(--success); font-weight: 600; }
.text-warn { color: var(--warn); font-weight: 600; }
.text-danger { color: var(--danger); }
.text-muted { color: var(--muted); }
.meta-line { font-size: 12px; color: var(--muted); margin: 4px 0 16px; }
.meta-line strong { color: var(--text2); font-weight: 500; }
.subheading { margin: 18px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.code-block {
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 12px;
}
.stock-warning { padding: 10px 12px; margin: 0 0 var(--gap); border: 1px solid rgba(240, 177, 0, .45); border-radius: var(--radius); background: var(--warn-soft); font-size: 13px; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
details > summary { cursor: pointer; }
.help-details { margin-top: 16px; font-size: 13px; }
.help-details > summary { color: var(--accent); font-weight: 500; }
.help-details[open] > summary { margin-bottom: 10px; }
.inline-details { display: inline-block; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { display: block; margin-top: 8px; padding: 12px; border: 1px solid var(--bd); border-radius: var(--radius); background: var(--bg); }

/* ── 11. Tabs, stepper, pagination, progress ────────────────────────────────────────────────────── */
/* The bar's bottom line is an inset shadow, so the active tab's underline sits on it without overflowing:
   a 1px overflow made Windows browsers draw a vertical scrollbar in every tab bar. */
.tabs {
    position: relative;
    display: flex;
    margin-bottom: var(--gap-lg);
    box-shadow: inset 0 -1px 0 var(--bd);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
}
.page-tabs { margin-bottom: 20px; }
.tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--muted);
    font: 600 13px/1.5 var(--font);
    white-space: nowrap;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}
.tab:hover:not(.active) { color: var(--text); text-decoration: none; }
.tab.active, .tab[aria-selected=true], .tab[aria-current=page] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; border-radius: 4px; }
.tab .count, .tab-count, .filter-tab .count { font-size: 11px; font-weight: 500; padding: 0 6px; border-radius: 999px; background: var(--surface2); color: var(--muted); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: var(--gap); }
.filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px;
    border: 1px solid var(--bd);
    border-radius: 999px;
    color: var(--text2);
    font-size: 12px;
    font-weight: 600;
}
.filter-tab:hover { color: var(--text); background: var(--hover); text-decoration: none; }
.filter-tab.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.filter-tab.active .count { background: rgba(255, 255, 255, .2); color: #fff; }
.filter-result-count { margin-left: auto; font-size: 12px; color: var(--muted); }

.stepper { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; }
.stepper li { display: flex; align-items: center; gap: 8px; padding: 5px 12px; border: 1px solid var(--bd); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13px; }
.stepper li span { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bd); color: var(--text); font-size: 11px; font-weight: 600; }
.stepper li.current { color: var(--text); border-color: var(--accent); }
.stepper li.current span { background: var(--accent-strong); color: #fff; }
.stepper li.done { color: var(--text2); }
.stepper li.done span { background: var(--success-strong); color: #fff; }

.pagination { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px; margin-top: 20px; }
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 9px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.pagination a { border: 1px solid var(--bd); color: var(--text2); }
.pagination a:hover { background: var(--hover); color: var(--text); text-decoration: none; }
.pagination .current { background: var(--accent-strong); color: #fff; }

.progress-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.progress-bar-track { width: 100%; height: 26px; border-radius: var(--radius); background: var(--surface2); overflow: hidden; }
.progress-bar-fill {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 100%;
    border-radius: var(--radius);
    background: var(--accent-strong);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    transition: width .4s ease;
}
.progress-bar-fill.done { background: var(--success-strong); }
.progress-stats { margin: 8px 0; font-size: 13px; color: var(--text2); }

/* ── 12. Dialogs ────────────────────────────────────────────────────────────────────────────────── */
dialog.modal {
    margin: auto;
    width: min(460px, 92vw);
    padding: 24px 26px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--bd);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, .6); }
dialog.modal > h3 { margin-bottom: 6px; font-size: 16px; }
dialog.modal .form-actions { margin-top: 16px; }
dialog.modal-preview { width: min(1100px, 94vw); height: 88vh; padding: 12px; }
dialog.modal-preview[open] { display: flex; flex-direction: column; }
.modal-preview-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 8px; }
dialog.modal-preview iframe { flex: 1; width: 100%; border: 0; border-radius: var(--radius-sm); background: #fff; }

/* ── 13. Page blocks ────────────────────────────────────────────────────────────────────────────── */

/* Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: var(--gap); margin-bottom: 10px; }
.stats-note { margin-bottom: 28px !important; }
.stat-card { display: block; padding: 18px 16px; text-align: center; background: var(--surface); border: 1px solid var(--bd); border-radius: var(--radius-lg); color: inherit; }
a.stat-card:hover { border-color: var(--accent); text-decoration: none; }
.stat-value { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1; margin-bottom: 6px; }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stat-active .stat-value { color: var(--success); }
.stat-unconf .stat-value { color: var(--warn); }
.stat-unsub .stat-value { color: var(--text2); }
.stat-bounce .stat-value { color: var(--danger); }
.stat-total .stat-value { color: var(--accent); }
.checklist { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; }
.checklist li a { color: var(--text); font-weight: 600; }
.checklist li.done a { color: var(--text2); font-weight: 400; }
.checklist li.done .hint { color: var(--muted); }
.checklist-mark { flex: 0 0 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--bd); }
.checklist li.done .checklist-mark { background: var(--success-strong); color: #fff; font-size: 14px; }

/* "Needs you": one row per item, coloured by urgency. */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-list li + li { border-top: 1px solid var(--bd2); }
.todo-list a { display: flex; align-items: center; gap: 12px; padding: 12px 18px; color: var(--text); }
.todo-list a:hover { background: var(--hover); text-decoration: none; }
.todo-list a > i { font-size: 18px; flex-shrink: 0; }
.todo-list a > span { flex: 1; min-width: 0; }
.todo-list .todo-go { font-size: 16px; color: var(--muted); }
.todo-danger a > i:first-child { color: var(--danger); }
.todo-warn a > i:first-child { color: var(--warn); }
.todo-info a > i:first-child { color: var(--accent); }

/* List growth: the count with a bar scaled to the best week. */
.growth-table { min-width: 0; }
.growth-table th:first-child { width: 190px; }
.growth-cell { display: flex; align-items: center; gap: 12px; }
.growth-num { flex: 0 0 32px; text-align: right; font-variant-numeric: tabular-nums; }
.growth-bar { flex: 1; max-width: 420px; height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; }
.growth-bar::before { content: ""; display: block; width: var(--pct, 0%); height: 100%; border-radius: 4px; background: var(--accent-strong); }

/* Contacts */
details.add-contact > summary { color: var(--accent); }
.bulk-bar {
    display: flex;           /* shown and hidden with the hidden attribute (js/admin-core.js) */
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--accent-strong);
    border-radius: var(--radius-lg);
    font-size: 13px;
}
.bulk-bar label.check { margin: 0; font-size: 13px; }
.bulk-count { font-weight: 600; }
.bulk-note { flex: 1 1 280px; }
.bulk-warning { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--warn); }
.detail-header { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.detail-email { font-size: 18px; font-weight: 700; word-break: break-all; }
.meta-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; margin-bottom: 12px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { overflow-wrap: anywhere; }
.permission-log { max-height: 220px; overflow: auto; margin: 0; padding: 8px 10px; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--radius); }
.stat-num { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat-good .stat-num { color: var(--success); }
.stat-warn .stat-num { color: var(--warn); }

/* Campaigns */
.campaign-form .form-card > h3 { font-size: 15px; }
.audience-filters { margin: 4px 0 12px; }
.audience-filters > summary { font-weight: 600; color: var(--text2); margin-bottom: 12px; }
.audience-filters:not([open]) > summary { margin-bottom: 0; }
.audience-count { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--accent); }
.editor-preview-button { margin-top: 8px; }   /* js/admin-editor.js puts it right under the editor */
.campaign-compare > summary .hint { margin-left: 6px; }
.campaign-compare .table-container { margin-top: 12px; }
.review-summary { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--text2); }
.review-counts { margin: 6px 0; }
.review-prepare { margin: 12px 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--radius); }
.review-email { margin-top: 12px; border: 1px solid var(--bd); border-radius: var(--radius); overflow: hidden; }
.review-email-head { padding: 10px 14px; background: var(--surface2); border-bottom: 1px solid var(--bd); }
.review-frame { display: block; width: 100%; height: 480px; border: 0; background: #fff; }
.review-email details { padding: 8px 14px; }
.review-text { margin: 8px 0 0; font-size: 12px; white-space: pre-wrap; color: var(--text2); }
.review-uncertain { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-top: 1px solid var(--bd); }
.review-approve { border-color: var(--accent-strong); }
/* The sending plan (review and progress pages): all at once or in batches, rate, duration. */
.send-plan { margin: 10px 0 12px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--radius); font-size: 13px; color: var(--text2); }
.send-plan p { margin: 0; }
.send-plan p + p { margin-top: 4px; }
.send-plan > i, .send-plan p > i { color: var(--accent); margin-right: 4px; }
.send-plan .hint { display: block; margin-top: 4px; font-size: 12px; }

/* Results */
.analytics-meta { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 18px; font-size: 13px; color: var(--muted); }
.analytics-meta strong { color: var(--text2); font-weight: 500; }
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: var(--gap); margin-bottom: 8px; }
.analytics-grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.an-card { display: block; padding: 18px 14px 14px; text-align: center; background: var(--surface); border: 1px solid var(--bd); border-radius: var(--radius-lg); color: inherit; }
.an-card-link:hover, .an-card-link:focus-visible { border-color: var(--accent); box-shadow: var(--ring); text-decoration: none; }
.an-icon { display: block; margin-bottom: 8px; font-size: 22px; color: var(--muted); }
.an-value { margin-bottom: 4px; font-size: 1.15rem; font-weight: 700; white-space: nowrap; }
.an-rate { margin-bottom: 4px; color: var(--muted); }
.an-label { font-size: 12px; color: var(--muted); }
.an-good .an-icon { color: var(--success); }
.an-bad .an-icon, .an-bad .an-value, .an-bad .an-rate { color: var(--danger); }
.an-warn .an-icon, .an-warn .an-value, .an-warn .an-rate { color: var(--warn); }
.ca-section { margin-bottom: 28px; }
.ca-section-title { margin-bottom: 12px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.chart-wrap { padding: 18px; background: var(--surface); border: 1px solid var(--bd); border-radius: var(--radius-lg); }
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 14px; }
.chart-toolbar > .field { margin: 0; min-width: 160px; }
.chart-area { position: relative; height: 260px; }
.chart-empty { padding: 40px 0; text-align: center; color: var(--muted); }
#ca-chart-canvas { display: block; width: 100% !important; }
.ra-export { display: flex; margin-bottom: 14px; }
.delivery-sent { font-size: 12px; color: var(--success); }
.delivery-failed { font-size: 12px; color: var(--danger); }
.delivery-pending { font-size: 12px; color: var(--muted); }
.delivery-other { font-size: 12px; }
.delivery-error { font-size: 11px; color: var(--danger); }
.delivery-reason { font-size: 11px; color: var(--muted); max-width: 260px; }

/* Codes */
.code-reveal { font-family: var(--font-mono); font-size: 16px; font-weight: 600; letter-spacing: .03em; user-select: all; overflow-wrap: anywhere; }

/* Content: image library */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-top: 12px; }
.media-item { display: flex; flex-direction: column; margin: 0; overflow: hidden; background: var(--bg); border: 1px solid var(--bd); border-radius: var(--radius); }
.media-item img { width: 100%; height: 110px; object-fit: cover; background: #fff; }
.media-item figcaption { padding: 8px; font-size: 12px; overflow-wrap: anywhere; }
.media-item figcaption input { margin-top: 6px; }
.media-item .row-actions { padding: 0 8px 8px; }

/* Settings */
.health-list { list-style: none; padding: 0; margin: 0 0 12px; }
.health-list li { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; font-size: 13px; }
.health-list li > i { flex-shrink: 0; margin-top: 1px; font-size: 16px; }
.health-list li.ok { color: var(--text2); }
.health-list li.ok > i { color: var(--success); }
.health-list li.bad { color: var(--text); font-weight: 500; }
.health-list li.bad > i { color: var(--danger); }
.check-list { list-style: none; padding: 0; margin: 0 0 12px; }
.form-status { margin-top: 10px; font-size: 13px; color: var(--muted); }
.stepup-card { border-color: rgba(240, 177, 0, .55); }
.stepup-card .card-head { justify-content: flex-start; margin-bottom: 6px; }
.stepup-card .card-head i { font-size: 20px; color: var(--warn); }
.stepup-card form { display: flex; flex-wrap: wrap; gap: var(--gap-sm); align-items: center; }
.stepup-card input { width: 150px !important; flex: 0 0 auto; letter-spacing: .12em; font-variant-numeric: tabular-nums; }

/* Sent mail (Mailpit viewer) */
.mail-message-header { padding: 18px 22px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--bd2); border-radius: var(--radius-lg); }
.mail-subject { margin-bottom: 12px; font-size: 16px; font-weight: 700; }
.mail-meta-row { display: flex; gap: 8px; margin-bottom: 6px; color: var(--muted); overflow-wrap: anywhere; }
.mail-meta-row .label { flex: 0 0 50px; color: var(--accent); font-weight: 600; }
.mail-meta-row .value { color: var(--text2); min-width: 0; }
.mail-body-wrap { overflow: hidden; background: var(--surface); border: 1px solid var(--bd2); border-radius: var(--radius-lg); }
.mail-body-toolbar { display: flex; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--bd2); }
.toggle-btn { padding: 5px 14px; border: 1px solid var(--bd); border-radius: 999px; background: transparent; color: var(--muted); font: 600 12px var(--font); cursor: pointer; }
.toggle-btn:hover { background: var(--hover); color: var(--text); }
.toggle-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.mail-body-html, .mail-body-text { display: none; }
.mail-body-html.visible, .mail-body-text.visible { display: block; }
.mail-body-html iframe { display: block; width: 100%; min-height: 500px; border: 0; background: #fff; }
.mail-body-empty { padding: 20px 24px; color: var(--muted); }
.mail-body-text pre { padding: 20px 24px; font-size: 13px; line-height: 1.7; color: var(--text2); white-space: pre-wrap; word-break: break-word; }
.mail-row-unread { font-weight: 600; }
.mail-unread-count { color: var(--accent); font-size: 13px; font-weight: 400; }
.unread-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.clear-form { display: inline; }

/* ── 14. Tag picker and email editor ────────────────────────────────────────────────────────────── */
.tagpicker {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    min-height: var(--control-h);
    padding: 4px 8px;
    background: var(--bg);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    cursor: text;
}
.tagpicker:hover { border-color: var(--bd-strong); }
.tagpicker:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.tp-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px 1px 10px;
    border-radius: 999px;
    border: 1px solid rgba(100, 149, 237, .35);
    background: rgba(100, 149, 237, .12);
    color: #7ea6f0;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.tp-chip-x { display: inline-flex; padding: 0 2px; border: 0; background: none; color: inherit; opacity: .7; font-size: 14px; line-height: 1; cursor: pointer; }
.tp-chip-x:hover { opacity: 1; }
.tagpicker .tp-input { flex: 1; min-width: 120px; padding: 3px 2px; border: 0; background: transparent; color: var(--text); font: 14px var(--font); outline: none; }
.tagpicker-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 300;
    max-height: 230px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--bd);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.tp-opt { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.tp-opt:hover, .tp-opt.tp-hl { background: var(--accent-soft); color: var(--accent); }
.tp-empty { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.tp-create { border-top: 1px solid var(--bd2); color: var(--accent); }

/* Jodit (theme "dark"): the toolbar matches the admin; the page stays white, like the email. */
.jodit-container.jodit { border-color: var(--bd) !important; border-radius: var(--radius) !important; overflow: hidden; }
.jodit-container .jodit-toolbar__box { background: var(--surface2) !important; border-bottom: 1px solid var(--bd) !important; }
.jodit-container .jodit-status-bar { background: var(--surface2) !important; color: var(--muted) !important; }
.jodit-container:not(.jodit_inline) .jodit-wysiwyg { background: #fff !important; color: #111 !important; }
.jodit-container:not(.jodit_inline) .jodit-wysiwyg a { color: #1a0dab; }
.he-picker { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; margin-top: 10px; }
.he-picker .btn { justify-content: flex-start; height: auto; min-height: var(--control-h); padding: 6px 12px; text-align: left; white-space: normal; }
.he-picker img { max-width: 110px; max-height: 64px; object-fit: contain; background: #fff; border: 1px solid var(--bd); border-radius: 4px; margin-right: 8px; }

/* ── 15. Small screens ──────────────────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
    .admin-layout .sidebar.open { transform: translateX(0); visibility: visible; transition: transform .25s ease, visibility 0s linear 0s; }
    .sidebar-backdrop.open { display: block; }
    .main-content { margin-left: 0; }
    .topbar { display: flex; }
    .content-wrap { padding: 20px 16px 60px; }
    .card-grid-wide { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 768px) {
    .col-optional { display: none; }
}
@media (max-width: 640px) {
    .form-card { padding: 16px; }
    .page-header h1 { font-size: 18px; }
    .filter-bar > *, .filter-bar > input[type=search], .filter-bar > input[type=text], .filter-bar > select, .filter-bar > .tagpicker { flex: 1 1 100%; max-width: none; }
    .filter-bar-end { margin-left: 0; }
    .inline-form, .form-card > .inline-form { display: flex; width: 100%; }
    .inline-form > input:not([type=hidden]):not([type=checkbox]), .inline-form > select { flex-basis: 100%; }
    .form-actions > .btn { flex: 1 1 auto; }
    .autosave-status { flex-basis: 100%; margin-left: 0; }
    .section-header-actions { width: 100%; }
    .review-frame { height: 360px; }
    .meta-list { grid-template-columns: 1fr; }
    .meta-list dd { margin-bottom: 6px; }
    dialog.modal { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar, .main-content, .skip-link, .progress-bar-fill, .spin { transition: none; animation: none; }
}
