:root {
    color-scheme: light;
    --ink: #16324a;
    --muted: #667a8c;
    --line: #dce6ee;
    --soft: #f3f7f9;
    --brand: #0d6b63;
    --brand-dark: #07574f;
    --white: #fff;
    --danger: #a63b32;
    --shadow: 0 20px 60px rgba(22, 50, 74, 0.11);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.outbox-mail-dialog { width: min(960px, calc(100% - 32px)); max-height: 92vh; overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: #fff; }
.outbox-mail-dialog::backdrop { background: rgba(22, 50, 74, 0.4); }
.outbox-mail-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.outbox-mail-metadata { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; font-size: 0.88rem; }
.outbox-mail-metadata dt { font-weight: 700; }
.outbox-mail-metadata dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.outbox-mail-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 12px; }
.outbox-mail-switch [aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.outbox-mail-frame { display: block; width: 100%; height: 52vh; min-height: 280px; border: 1px solid var(--line); background: #fff; }
.outbox-mail-text { min-height: 280px; padding: 20px; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.6 ui-monospace, monospace; border: 1px solid var(--line); }

* { box-sizing: border-box; }

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 5%, rgba(13, 107, 99, 0.09), transparent 28rem),
        #f7fafb;
}

button, input, select, textarea { font: inherit; }
.admin-check { max-width: 950px; padding: clamp(18px, 4vw, 36px); background: white; border: 1px solid var(--line); border-radius: 18px; }
.admin-check > p { line-height: 1.6; }
.admin-check-search { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0; }
.admin-check-search label { flex-basis: 100%; font-weight: 700; }
.admin-check input[type="search"], .admin-check input[type="text"], .admin-check select { min-width: 0; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; }
.admin-check input[type="search"] { flex: 1 1 240px; }
.admin-check select { display: block; width: 100%; margin: 8px 0; }
.admin-check-practices { display: grid; gap: 10px; }
.admin-check-practice { display: grid; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); text-align: left; }
.admin-check-practice:hover { border-color: var(--brand); background: var(--soft); }
.admin-check-services { margin: 24px 0; padding: 0; border: 0; }
.admin-check-services legend { margin-bottom: 12px; font-weight: 700; }
.admin-check [data-check-services] { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 8px; }
.admin-check [data-check-services] label { display: flex; align-items: center; gap: 10px; padding: 12px; min-height: 48px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; overflow-wrap: anywhere; }
.admin-check [data-check-services] input { accent-color: var(--brand); flex: 0 0 18px; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; }
.admin-check [data-check-services] span { min-width: 0; flex: 1; }
.admin-check [data-check-message] { color: var(--brand-dark); background: #eef8f3; }
.admin-check [data-check-message].is-error { color: var(--danger); background: #fff1ef; }
.admin-check-custom-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; margin-top: 12px; }
.admin-check-custom-row label { grid-column: 1 / -1; font-size: .85rem; font-weight: 700; }
.admin-check button:disabled { opacity: .5; cursor: not-allowed; }
.admin-check [data-check-add] { margin-top: 12px; }
.admin-check :is(input, select, button, a):focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 72px;
    padding: 12px clamp(20px, 4vw, 60px);
    border-bottom: 1px solid rgba(220, 230, 238, 0.9);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
}

.admin-brand {
    display: inline-flex;
    gap: 12px;
    align-items: center;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.admin-brand small {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.admin-brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: 12px;
    color: var(--white);
    background: var(--brand);
    font-size: 0.82rem;
    letter-spacing: 0.04em;
}

.admin-header-actions { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 0.9rem; }
.admin-main { width: min(1380px, calc(100% - 40px)); margin: 0 auto; padding: 56px 0 80px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -0.035em; }
h1 { font-size: clamp(2rem, 4vw, 3.15rem); }
h2 { font-size: 1.65rem; }

.login-card {
    width: min(460px, 100%);
    margin: 7vh auto 0;
    padding: clamp(28px, 5vw, 48px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--white);
    box-shadow: var(--shadow);
}

.login-card > p:not(.eyebrow) { margin: 14px 0 28px; color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 10px; }
.login-card label, .dialog-status label { font-size: 0.84rem; font-weight: 750; }

input, select {
    width: 100%;
    min-height: 46px;
    border: 1px solid #c8d6df;
    border-radius: 10px;
    padding: 10px 13px;
    color: var(--ink);
    background: var(--white);
    outline: none;
}

input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13, 107, 99, 0.13); }
.login-card input { margin-bottom: 8px; }

.button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 16px;
    font-weight: 750;
}

.button:disabled { cursor: not-allowed; opacity: 0.5; }
.button--primary { color: var(--white); background: var(--brand); }
.button--primary:hover { background: var(--brand-dark); }
.button--secondary { border-color: #b8cbc8; color: var(--brand-dark); background: #edf7f5; }
.button--quiet { border-color: var(--line); color: var(--ink); background: var(--white); }
.login-card .button { margin-top: 8px; }

.form-message, .dashboard-message {
    margin: 8px 0;
    padding: 11px 13px;
    border-radius: 9px;
    color: var(--danger);
    background: #fff0ee;
    font-size: 0.88rem;
}

.dashboard-title-row { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; }
.last-updated { min-height: 1.2em; margin: 7px 0 0; color: var(--muted); font-size: 0.83rem; }

.admin-tabs {
    display: inline-flex;
    gap: 5px;
    margin: 0 0 34px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--white);
}

.admin-tab {
    min-height: 40px;
    border: 0;
    border-radius: 9px;
    padding: 8px 16px;
    color: var(--muted);
    background: transparent;
    font-weight: 750;
}

.admin-tab:hover { color: var(--ink); background: var(--soft); }
.admin-tab.is-active { color: var(--white); background: var(--brand); }
.tab-alert {
    display: inline-grid;
    min-width: 21px;
    height: 21px;
    margin-left: 5px;
    place-items: center;
    border-radius: 999px;
    padding: 0 6px;
    color: #fff;
    background: var(--danger);
    font-size: 0.7rem;
    line-height: 1;
}
.admin-tab.is-active .tab-alert { color: var(--danger); background: #fff; }

.stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 34px 0 22px;
}

.stat {
    display: flex;
    min-height: 105px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px;
    color: var(--muted);
    background: var(--white);
    text-align: left;
}

.stat:hover { border-color: #a9c4c0; transform: translateY(-1px); }
.stat span { display: block; margin-bottom: 4px; color: var(--ink); font-size: 1.85rem; font-weight: 850; }
.stat--new { border-color: rgba(13, 107, 99, 0.25); background: #edf7f5; }
.stats--outbox { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat--attention { border-color: rgba(166, 59, 50, 0.3); background: #fff5f3; }
.stat--attention span { color: var(--danger); }

.outbox-alert {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin: 26px 0 -12px;
    border: 1px solid #efc7c1;
    border-radius: 12px;
    padding: 13px 15px;
    color: #7c2d26;
    background: #fff5f3;
    font-size: 0.88rem;
}
.outbox-alert strong { white-space: nowrap; }
.toolbar--outbox { grid-template-columns: minmax(260px, 1fr) 220px 220px; }

.toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) 220px auto; gap: 10px; margin-bottom: 14px; }
.table-shell { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--white); box-shadow: 0 12px 36px rgba(22, 50, 74, 0.06); }
.table-shell table { width: 100%; border-collapse: collapse; }
.table-shell th, .table-shell td { padding: 15px 16px; border-bottom: 1px solid #e7eef2; text-align: left; vertical-align: middle; }
.table-shell th { color: var(--muted); background: #f8fafb; font-size: 0.73rem; letter-spacing: 0.055em; text-transform: uppercase; }
.table-shell td { font-size: 0.9rem; }
.table-shell tbody tr:hover { background: #fafcfc; }
.table-shell tbody tr:last-child td { border-bottom: 0; }
.cell-main { display: block; margin-bottom: 3px; color: var(--ink); font-weight: 750; }
.cell-sub { display: block; color: var(--muted); font-size: 0.78rem; }
.row-action { white-space: nowrap; }

.status-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 9px;
    color: #445b6c;
    background: #edf2f5;
    font-size: 0.75rem;
    font-weight: 750;
    white-space: nowrap;
}

.status-badge[data-status="new"] { color: #07574f; background: #dff2ed; }
.status-badge[data-status="in_progress"] { color: #85521a; background: #fff0d7; }
.status-badge[data-status="contacted"] { color: #285a8f; background: #e4f0fb; }
.status-badge[data-status="completed"] { color: #47634b; background: #e8f1e8; }
.status-badge[data-status="sent"] { color: #07574f; background: #dff2ed; }
.status-badge[data-status="pending"] { color: #85521a; background: #fff0d7; }
.status-badge[data-status="failed"],
.status-badge[data-status="invalid_recipient"] { color: #8b2f28; background: #ffe5e1; }
.status-badge[data-status="not_configured"] { color: #6c4c13; background: #fff0cb; }

.outbox-table-shell table { min-width: 1040px; }
.outbox-row--problem { background: #fffaf9; }
.outbox-status-detail {
    display: block;
    max-width: 280px;
    margin-top: 6px;
    color: var(--danger);
    font-size: 0.74rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.outbox-resolved { color: var(--muted); }
.outbox-attempt { white-space: nowrap; }

.empty-state { display: grid; min-height: 220px; place-content: center; gap: 6px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); }
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 16px; color: var(--muted); font-size: 0.86rem; }

.detail-dialog {
    width: min(880px, calc(100% - 30px));
    max-height: calc(100vh - 36px);
    border: 0;
    border-radius: 22px;
    padding: 0;
    color: var(--ink);
    background: var(--white);
    box-shadow: 0 28px 100px rgba(5, 31, 49, 0.3);
}

.detail-dialog::backdrop { background: rgba(11, 30, 44, 0.56); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; padding: 26px 30px 20px; border-bottom: 1px solid var(--line); }
.dialog-close { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--muted); background: var(--white); font-size: 1.5rem; line-height: 1; }
.dialog-status { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; padding: 20px 30px; background: var(--soft); }
.dialog-status > div { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.dialog-status select { min-width: 190px; }
.detail-content { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; padding: 26px 30px 34px; }
.detail-section { min-width: 0; }
.detail-section--full { grid-column: 1 / -1; }
.detail-section h3 { margin: 0 0 12px; color: var(--brand-dark); font-size: 0.78rem; letter-spacing: 0.07em; text-transform: uppercase; }
.detail-list { display: grid; grid-template-columns: minmax(110px, 0.8fr) minmax(0, 1.6fr); margin: 0; font-size: 0.88rem; }
.detail-list dt, .detail-list dd { margin: 0; padding: 7px 0; border-bottom: 1px solid #edf1f3; overflow-wrap: anywhere; }
.detail-list dt { color: var(--muted); }
.detail-list dd { font-weight: 650; }
.detail-message-box { margin: 0; padding: 16px; border-radius: 12px; color: #334f63; background: var(--soft); line-height: 1.65; white-space: pre-wrap; }
.event-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.84rem; line-height: 1.7; }
.email-state--sent { color: #07574f; }
.email-state--failed { color: #a63b32; }
.email-state--pending, .email-state--not_configured { color: #85521a; }
.detail-dialog > .form-message { margin: 0 30px 26px; }

.email-tool-heading { margin-bottom: 22px; }

.email-workspace {
    display: grid;
    grid-template-columns: minmax(210px, 0.7fr) minmax(520px, 1.75fr) minmax(300px, 1fr);
    gap: 16px;
    align-items: start;
}

.template-sidebar,
.template-editor-card,
.email-preview-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--white);
    box-shadow: 0 12px 36px rgba(22, 50, 74, 0.055);
}

.template-sidebar { overflow: hidden; }
.template-sidebar-head { padding: 18px; border-bottom: 1px solid var(--line); }
.template-sidebar-head h2 { margin: 0 0 4px; font-size: 1rem; letter-spacing: 0; }
.template-sidebar-head span { color: var(--muted); font-size: 0.78rem; }
.template-list { display: grid; max-height: 680px; overflow-y: auto; }

.template-list-item {
    display: grid;
    gap: 5px;
    width: 100%;
    border: 0;
    border-bottom: 1px solid #e7eef2;
    padding: 15px 17px;
    color: var(--ink);
    background: var(--white);
    text-align: left;
}

.template-list-item:last-child { border-bottom: 0; }
.template-list-item:hover { background: #f8fbfb; }
.template-list-item.is-selected { box-shadow: inset 4px 0 0 var(--brand); background: #edf7f5; }
.template-list-item strong { font-size: 0.87rem; line-height: 1.35; }
.template-list-item small { color: var(--muted); font-size: 0.72rem; }
.template-list-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.template-kind-label,
.template-list-active,
.template-active-badge {
    display: inline-flex;
    width: fit-content;
    border-radius: 999px;
    padding: 4px 7px;
    color: #445b6c;
    background: #edf2f5;
    font-size: 0.67rem;
    font-weight: 800;
}
.template-list-active,
.template-active-badge { color: var(--brand-dark); background: #dff2ed; }

.template-editor-card { padding: 22px; }
.template-editor-heading { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.template-editor-heading h2 { font-size: 1.45rem; }
.template-active-badge { align-self: center; }
.template-fields-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.template-editor-card label,
.editor-label-row > span { display: grid; gap: 7px; color: var(--ink); font-size: 0.8rem; font-weight: 750; }
.template-subject-field { margin-top: 12px; }
.editor-label-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin: 20px 0 8px; }
.editor-label-row small { color: var(--muted); font-size: 0.72rem; }

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    padding: 8px;
    border: 1px solid #c8d6df;
    border-bottom: 0;
    border-radius: 11px 11px 0 0;
    background: #f8fafb;
}

.editor-toolbar button {
    min-width: 34px;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 5px 8px;
    color: var(--ink);
    background: var(--white);
    font-size: 0.78rem;
}

.editor-toolbar button:hover { border-color: #a9c4c0; background: #edf7f5; }
.editor-toolbar select { width: auto; min-width: 100px; min-height: 34px; border-radius: 7px; padding: 4px 7px; font-size: 0.76rem; }
.toolbar-separator { width: 1px; height: 28px; margin: 0 2px; background: var(--line); }
.color-tool { display: flex !important; grid: none !important; flex-direction: row; gap: 5px !important; align-items: center; min-height: 34px; border: 1px solid var(--line); border-radius: 7px; padding: 4px 7px; background: var(--white); font-size: 0.72rem !important; }
.color-tool input { width: 24px; min-height: 24px; border: 0; border-radius: 4px; padding: 0; }
.saved-colors { display: grid; gap: 7px; border: 1px solid #c8d6df; border-bottom: 0; padding: 10px; background: #fff; }
.saved-colors > span { color: var(--muted); font-size: 0.73rem; font-weight: 700; }
.saved-color-list { display: flex; flex-wrap: wrap; gap: 6px; }
.saved-color { display: inline-flex; max-width: 100%; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.saved-color.is-active { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.saved-color button { min-height: 36px; border: 0; padding: 5px 8px; color: var(--ink); background: #fff; font-size: 0.72rem; }
.saved-color button:first-child { display: inline-flex; align-items: center; gap: 6px; }
.saved-color button[aria-pressed="true"] { background: #e5f3ee; }
.saved-color button:hover { background: #edf7f5; }
.saved-color button:focus-visible { outline: 2px solid var(--ink); outline-offset: -3px; }
.saved-color-label { display: grid; gap: 2px; text-align: left; overflow-wrap: anywhere; }
.saved-color-label small { font-family: ui-monospace, Consolas, monospace; font-size: 0.7rem; color: var(--muted); }
.saved-color-check { width: 1em; flex-shrink: 0; color: var(--brand-dark); font-weight: 900; visibility: hidden; }
.saved-color.is-active .saved-color-check { visibility: visible; }
.saved-color-chip, .current-color-chip { display: inline-block; flex-shrink: 0; width: 20px; height: 20px; border: 1px solid #16324a66; border-radius: 4px; }
.editor-color-status { display: flex; gap: 8px; align-items: center; min-height: 32px; color: var(--ink); font-size: 0.8rem; font-weight: 700; overflow-wrap: anywhere; }
.editor-color-status[data-mode="mixed"] .current-color-chip { background: linear-gradient(135deg, #16324a 50%, #dce6ee 50%); }
.saved-color-message { margin: 0; color: var(--muted); font-size: 0.73rem; line-height: 1.45; }
.color-apply-message { margin: 0; padding: 8px 10px; border-radius: 6px; background: #e5f3ee; color: var(--brand-dark); font-size: 0.78rem; font-weight: 700; }
.color-apply-message[data-error="true"] { background: #fff1ef; color: var(--danger); }
.color-name-dialog { width: min(460px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 16px; padding: 24px; color: var(--ink); }
.color-name-dialog::backdrop { background: rgba(22, 50, 74, 0.35); }
.color-name-dialog p { font-size: 0.85rem; line-height: 1.5; }
.color-name-dialog label { display: block; margin-bottom: 8px; font-size: 0.85rem; font-weight: 700; }
.color-name-preview { display: flex; align-items: center; gap: 10px; }
.color-name-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.rich-editor {
    min-height: 360px;
    max-height: 620px;
    overflow-y: auto;
    border: 1px solid #c8d6df;
    border-radius: 0 0 11px 11px;
    padding: 24px;
    color: #16324a;
    background: var(--white);
    outline: none;
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

.rich-editor:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13, 107, 99, 0.13); }
.rich-editor img { max-width: 100%; height: auto; }
.rich-editor table { min-width: 0; }
.rich-editor p, .email-preview-body p { margin: 0 0 16px; }
/* The admin page's large H1/H2 rules must never size email text or its line box.
   Explicit sizes from templates still win; otherwise headings inherit the
   email's base size while selected spans determine their displayed size. */
.rich-editor h1, .rich-editor h2, .rich-editor h3,
.email-preview-body h1, .email-preview-body h2, .email-preview-body h3 {
    font-size: inherit;
    letter-spacing: normal;
}
.editor-help { margin: 9px 0 14px; color: var(--muted); font-size: 0.75rem; line-height: 1.6; }
.editor-help kbd { border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; color: var(--ink); background: var(--soft); font: inherit; font-weight: 650; }
.editor-paste-notice { padding: 10px 12px; border-radius: 8px; color: #624613; background: #fff6df; font-size: 0.8rem; line-height: 1.5; }
.paste-dialog { width: min(510px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; border: 1px solid var(--line); border-radius: 18px; padding: 24px; color: var(--ink); background: var(--white); box-shadow: 0 20px 80px #16324a33; }
.paste-dialog::backdrop { background: #16324a66; }
.paste-dialog h2 { font-size: 1.35rem; }
.paste-dialog > p { line-height: 1.5; }
.paste-choice { display: grid; gap: 6px; width: 100%; margin: 10px 0; padding: 15px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #f8fafb; text-align: left; }
.paste-choice strong { font-size: 0.95rem; }
.paste-choice span { color: var(--muted); font-size: 0.83rem; line-height: 1.5; }
.paste-choice:hover, .paste-choice:focus-visible { border-color: var(--brand); background: #edf7f5; }
.paste-choice:disabled { opacity: 0.6; cursor: wait; }

.template-insert-grid { display: grid; gap: 10px; margin-top: 12px; }
.insert-card { border: 1px solid var(--line); border-radius: 11px; padding: 13px; background: #fafcfc; }
.insert-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.insert-card-head > div { display: grid; gap: 2px; }
.insert-card-head strong { font-size: 0.8rem; }
.insert-card-head small { color: var(--muted); font-size: 0.7rem; line-height: 1.4; }
.upload-button { display: inline-flex !important; width: auto; align-items: center; white-space: nowrap; font-size: 0.72rem !important; }
.variable-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.variable-button {
    border: 1px solid #c8d6df;
    border-radius: 999px;
    padding: 5px 8px;
    color: var(--brand-dark);
    background: var(--white);
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.68rem;
}
.variable-button:hover { border-color: var(--brand); background: #edf7f5; }

.asset-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.asset-empty { grid-column: 1 / -1; margin: 3px 0; color: var(--muted); font-size: 0.74rem; }
.asset-button { display: grid; gap: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; color: var(--muted); background: var(--white); font-size: 0.63rem; text-align: left; overflow: hidden; }
.asset-button:hover { border-color: var(--brand); }
.asset-button img { width: 100%; height: 55px; object-fit: contain; border-radius: 5px; background: #f2f5f6; }
.asset-button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.template-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.template-actions-spacer { flex: 1; }

.email-preview-card { position: sticky; top: 16px; overflow: hidden; }
.preview-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px; border-bottom: 1px solid var(--line); }
.preview-head h2 { font-size: 1.15rem; }
.preview-head > span { color: var(--muted); font-size: 0.7rem; }
.preview-subject { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f8fafb; font-size: 0.75rem; line-height: 1.5; overflow-wrap: anywhere; }
.preview-subject strong { color: var(--ink); }
.email-preview-body { min-height: 380px; max-height: 690px; overflow-y: auto; padding: 22px; color: #16324a; background: #fff; font-family: Arial, sans-serif; font-size: 16px; line-height: 1.6; }
.email-preview-body > *:first-child { margin-top: 0; }
.email-preview-body img { max-width: 100%; height: auto; }
.email-preview-body table { min-width: 0; }
.rich-editor th, .email-preview-body th { text-transform: none; letter-spacing: normal; }

@media (max-width: 900px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat:last-child { grid-column: span 2; }
    .table-shell { overflow-x: auto; }
    table { min-width: 850px; }
    .email-workspace { grid-template-columns: minmax(190px, 0.65fr) minmax(0, 1.8fr); }
    .email-preview-card { position: static; grid-column: 1 / -1; }
}

@media (max-width: 620px) {
    .admin-header { padding-inline: 16px; }
    .admin-header-actions > span { display: none; }
    .admin-main { width: min(100% - 28px, 1380px); padding-top: 34px; }
    .dashboard-title-row { align-items: flex-start; flex-direction: column; }
    .admin-tabs { display: grid; grid-template-columns: 1fr; width: 100%; }
    .stats { grid-template-columns: 1fr 1fr; }
    .stat { min-height: 90px; padding: 14px; }
    .toolbar { grid-template-columns: 1fr; }
    .outbox-alert { align-items: flex-start; flex-direction: column; }
    .dialog-head, .dialog-status { padding-inline: 18px; }
    .dialog-status { align-items: stretch; flex-direction: column; }
    .dialog-status > div { align-items: stretch; flex-direction: column; }
    .detail-content { grid-template-columns: 1fr; padding: 22px 18px 28px; }
    .detail-section--full { grid-column: auto; }
    .email-workspace { grid-template-columns: 1fr; }
    .template-sidebar { max-height: 310px; }
    .template-list { max-height: 230px; }
    .template-fields-row { grid-template-columns: 1fr; }
    .editor-label-row { align-items: flex-start; flex-direction: column; }
    .editor-toolbar select { min-width: 90px; }
    .rich-editor { min-height: 320px; padding: 17px; }
    .asset-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .template-actions > .button { flex: 1 1 100%; }
    .template-actions-spacer { display: none; }
}

.admin-check { max-width: none; }
.check-history { margin: 1.5rem 0 2.5rem; padding-bottom: 2rem; border-bottom: 1px solid #dce3e8; }
.check-history .dashboard-title-row { align-items: flex-start; gap: 1rem; }
.check-history .toolbar label { display: grid; gap: .4rem; }
.check-history-table { overflow-x: auto; }
.check-history-table table { width: 100%; min-width: 1000px; border-collapse: collapse; text-align: left; }
.check-history-table th:first-child { width: 165px; }
.check-history-table th:nth-child(2) { width: 28%; }
.check-history-table th:nth-child(4) { width: 100px; }
.check-history-table th:last-child { width: 190px; }
.check-history-table th, .check-history-table td { padding: 1rem .75rem; vertical-align: top; border-bottom: 1px solid #dce3e8; }
.check-history-table th { font-size: .85rem; background: #f4f7f8; }
.check-history-table td { max-width: 320px; overflow-wrap: anywhere; }
.check-history-table small { display: block; margin-top: .35rem; color: #52616a; font-size: .8rem; }
.check-history-table a { display: inline-block; padding: .25rem 0; }
.check-history-table details { margin-top: .65rem; font-size: .85rem; }
.check-history-table summary { cursor: pointer; }
.check-history-status { display: inline-block; border-radius: 1rem; padding: .3rem .6rem; background: #eef1f4; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.check-history-status[data-status="completed"] { background: #e2f4eb; color: #195c3c; }
.check-history-status[data-status="running"] { background: #e3effb; color: #234f78; }
.check-history-status[data-status="failed"] { background: #fce7e7; color: #8a2525; }
.check-history-status[data-status="partial"] { background: #fff1d7; color: #704b0e; }
.check-history .toolbar { grid-template-columns: minmax(240px, 1fr) 180px 160px auto; align-items: end; }
@media (max-width: 900px) { .check-history .toolbar { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .check-history .toolbar { grid-template-columns: 1fr; } }
