/* Fonts */
@font-face {
  font-family: 'Geist';
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: url('./fonts/Geist-Variable.woff2') format('woff2');
}

@font-face {
  font-family: 'Geist';
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
  src: url('./fonts/Geist-Italic-Variable.woff2') format('woff2');
}

/* Theme tokens: the portal design system, product-neutral (design/admin-theme-spec.md section 1). */
* {
    /* Surface ladder. Dark: rail #060709 -> panel #08090b -> page #0a0b0d -> card #111316. */
    --rail: light-dark(#ededef, #060709);
    --panel: light-dark(#f2f2f4, #08090b);
    --body: light-dark(#f7f7f8, #0a0b0d);
    --background: light-dark(#f7f7f8, #0a0b0d);
    --card: light-dark(#ffffff, #111316);
    --popover: light-dark(#ffffff, #15171b);
    --faint: light-dark(#fafafa, #0e1013);
    --muted: light-dark(#eff0f2, #17191d);
    --secondary: light-dark(#ececef, #1b1d22);
    --accent: light-dark(#eaebee, #1a1c21);

    --foreground: light-dark(#17181c, #ededf0);
    --card-foreground: light-dark(#17181c, #ededf0);
    --secondary-foreground: light-dark(#17181c, #ededf0);
    --muted-foreground: light-dark(#676872, #9a9ca6);
    --faint-foreground: light-dark(#8e8f99, #6f717b);

    /* Product accent: neutral blue (the portal's --info pair), never a tenant's brand colour. */
    --primary: light-dark(#2563eb, #58a6ff);
    --primary-foreground: #ffffff;
    --ring: light-dark(#2563eb, #58a6ff);

    --border: light-dark(rgb(9 10 13 / 0.09), rgb(255 255 255 / 0.08));
    --input: light-dark(rgb(9 10 13 / 0.14), rgb(255 255 255 / 0.13));

    --success: light-dark(#14804a, #3ecf8e);
    --warning: light-dark(#a26205, #f0a33f);
    --danger: light-dark(#d92d20, #e5484d);
    --info: light-dark(#2563eb, #58a6ff);
    --success-foreground: #ffffff;
    --danger-foreground: #ffffff;
    --warning-foreground: #ffffff;

    /* Semantic badge tints: 12% of the tone over the surface (portal bg-success/12 etc.). */
    --tone-neutral: var(--muted-foreground);
    --tone-neutral-bg: var(--muted);
    --tone-blue: var(--info);
    --tone-blue-bg: color-mix(in srgb, var(--info) 12%, transparent);
    --tone-green: var(--success);
    --tone-green-bg: color-mix(in srgb, var(--success) 12%, transparent);
    --tone-amber: var(--warning);
    --tone-amber-bg: color-mix(in srgb, var(--warning) 12%, transparent);
    --tone-red: var(--danger);
    --tone-red-bg: color-mix(in srgb, var(--danger) 12%, transparent);
    --tone-rose: var(--danger);
    --tone-rose-bg: var(--tone-red-bg);
    --tone-violet: var(--warning);
    --tone-violet-bg: var(--tone-amber-bg);

    /* Categorical chart slots (portal --chart-1..4, slot 1 swapped to the product accent). */
    --chart-1: var(--primary);
    --chart-2: light-dark(#0e9f6e, #1baf7a);
    --chart-3: light-dark(#b97c02, #c07f00);
    --chart-4: light-dark(#d0567f, #d75f92);

    /* Radius ladder: --radius 10px; sm 6, md 8, lg 10, xl 14. */
    --radius: 0.625rem;
    --radius-small: calc(var(--radius) - 4px);
    --radius-medium: calc(var(--radius) - 2px);
    --radius-large: var(--radius);
    --radius-xl: calc(var(--radius) + 4px);

    --shadow-small: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-medium: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-large: 0 25px 50px -12px rgb(0 0 0 / 0.25);

    /* Type ladder: H1 28, H2 18, card title 14-16 semibold, body 14, meta 12. */
    --font-sans: "Geist", system-ui, sans-serif;
    --font-mono: "Geist Mono", ui-monospace, Consolas, monospace;
    --text-1: 1.75rem;
    --text-2: 1.5rem;
    --text-3: 1.25rem;
    --text-4: 1.125rem;
    --text-5: 1rem;
    --text-6: 0.9375rem;
    --text-7: 0.875rem;
    --text-8: 0.75rem;
    --text-9: 0.6875rem;
    --text-regular: var(--text-7);
    --leading-normal: 1.5;

    /* Shell numbers (canon section 2). */
    --topbar-h: 3.5rem;
    --rail-w: 4rem;
    --panel-w: 16rem;
    --nav-item-h: 2.25rem;
    --row-h: 3rem;
    --control-h: 2.25rem;
    --control-h-sm: 2rem;
    --transition: 0.2s ease;
    --transition-fast: 0.15s ease;

    --rail-w-open: 14rem;
    --container-max: 1300px;

    /* CodeMirror code editor. */
    --cm-bg: var(--card);
    --cm-fg: var(--foreground);
    --cm-caret: var(--foreground);
    --cm-border: var(--border);
    --cm-selection: light-dark(#add6ff, #2c4f7c);
    --cm-selection-match: light-dark(rgb(0 85 212 / 0.12), rgb(255 255 255 / 0.14));
    --cm-search-match: light-dark(#ffe9a8, rgb(230 185 92 / 0.3));
    --cm-active-line: light-dark(rgb(0 0 0 / 0.04), rgb(255 255 255 / 0.045));
    --cm-gutter-fg: var(--faint-foreground);
    --cm-gutter-active-fg: var(--foreground);
    --cm-button-bg: var(--muted);
    --cm-button-active-bg: var(--accent);
    --cm-keyword: light-dark(#0055d4, #6aabec);
    --cm-control: light-dark(#af00db, #c586c0);
    --cm-variable: light-dark(#e45649, #9cdcfe);
    --cm-type: light-dark(#0055d4, #4ec9b0);
    --cm-function: light-dark(#795e26, #dcdcaa);
    --cm-number: light-dark(#098658, #b5cea8);
    --cm-operator: light-dark(#383a42, #d4d4d4);
    --cm-regexp: light-dark(#af00db, #d16969);
    --cm-string: light-dark(#50a14f, #ce9178);
    --cm-comment: light-dark(#999, #7d8590);
    --cm-link: var(--primary);
    --cm-invalid: var(--danger);
}

/* Global */
html,
body {
    height: 100%;
}

html,
body {
    background: var(--body);
}

body {
    font-family: var(--font-sans);
}

a {
    text-decoration: none;

    &.unstyled.text-light:hover {
        color: var(--primary);
    }
}

textarea.monospace {
    font-family: var(--font-mono);
}

table {
    th, td {
        padding: var(--space-3) var(--space-2);
        p {
            margin: 0 0 var(--space-1) 0;
        }
        vertical-align: top;
        border-bottom: 1px solid var(--border);
    }

    .view {
        color: var(--faint-foreground);
        font-size: var(--text-8);

        &:hover {
            color: var(--primary);
        }
    }

    &.has-select {
        tbody tr:hover {
            background-color: transparent;
            td {
                border-bottom: 1px solid light-dark(#ccc, #3c4048);
            }
        }
    }
}

svg.icon {
    display: inline-block;
    height: 1em;
    margin-inline-end: 0.2em;
    vertical-align: -0.125em;
    width: 1em;
    align-self: center;
}

.content pre {
    white-space: pre-wrap;
}

[x-cloak] {
    display: none !important;
}

ot-tabs:not(:defined) {
    > [role="tabpanel"] {
        display: none;
    }

    > [role="tablist"] + [role="tabpanel"] {
        display: block;
    }
}

fieldset {
    > [data-field]:last-child {
        margin-block-end: 0;
    }
}

dialog {
    padding: 0;
    overflow: auto;
    border-radius: var(--radius-medium);

    .dialog-card {
        padding: 0;
    }

    .dialog-head {
        background: var(--muted);
        border-bottom: 1px solid var(--border);
        padding: var(--space-3) var(--space-4);

        .dialog-title {
            margin: 0;
            font-size: var(--text-6);
        }
    }

    .dialog-body {
        padding: var(--space-4);
    }

    .dialog-foot {
        display: flex;
        gap: var(--space-2);
        justify-content: flex-end;
        padding: var(--space-3) var(--space-4) var(--space-4) var(--space-3);

        button {
            min-width: 75px;
        }
    }
}

/* Subscription status icons. */
.status-icon {
    &.status-enabled,
    &.status-confirmed {
        color: var(--tone-green);
    }

    &.status-unsubscribed {
        color: var(--tone-rose);
    }

    &.status-blocklisted,
    &.status-disabled {
        color: var(--tone-red);
    }

    &.status-unconfirmed {
        color: var(--tone-amber);
    }
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    vertical-align: middle;

    a {
        display: inline-flex;
        align-items: center;
    }

    .icon {
        font-size: var(--text-8);
        margin: 0;
    }

    &:hover .icon {
        opacity: 1;
    }
}

/* Tables */
td .badge {
    margin-block: 1px;
}

td.stats {
    dl {
        display: flex;
        flex-flow: column;
        row-gap: var(--space-1);
        margin: 0;
    }

    /* Each dt+dd pair is wrapped in a div so that pairs never flow inline
       with each other when the cell is wide. */
    dl > div {
        display: flex;
        align-items: baseline;
        column-gap: var(--space-2);
    }

    dt {
        flex-shrink: 0;
        min-width: 100px;
        color: var(--muted-foreground);
    }

    dd {
        flex: 1 1 auto;
        margin: 0;
    }
}

.search-form {
    button.outline {
        border-color: var(--input);
    }
    fieldset {
        margin-block-end: 0;
    }
}

/* Utilities */
.text-light {
    color: var(--muted-foreground);
}
.text-4 { font-size: var(--text-4); }
.text-5 { font-size: var(--text-5); }
.text-7 { font-size: var(--text-7); }
.text-8 { font-size: var(--text-8); }

.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.italic { font-style: italic; }
.capitalize { text-transform: capitalize; }
.mb-0 { margin-block-end: 0; }
.mt-5 { margin-block-start: var(--space-5); }

.relative {
    position: relative;
}

ul.no,
ol.no {
    list-style: none;
    margin: 0;
    padding: 0;
}

.avatar {
    img,
    span {
        align-items: center;
        display: inline-flex;
        border-radius: 5px;
        justify-content: center;
        object-fit: cover;
        height: 28px;
        width: 28px;
    }

    span {
        font-size: var(--text-8);
        letter-spacing: 0.02em;
    }
}

.name-stack {
    align-items: flex-start;
    display: flex;
    gap: var(--space-3);

    > .avatar {
        flex-shrink: 0;
    }
}

/* Placeholder for empty tables, lists and cards ({{ template "empty-state" }}). */
.empty-state {
    align-items: center;
    color: var(--muted-foreground);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    padding-block: var(--space-10);
    text-align: center;

    /* The placeholder mark only, not the icon inside the action button. */
    > svg.icon {
        color: var(--faint-foreground);
        font-size: var(--text-2);
        margin: 0;
        stroke-width: 1.5;
    }

    p {
        margin: 0;
    }
}

td > .empty-state {
    padding-block: var(--space-8);
}

.page-content {
    margin-block-end: var(--space-6);

    &.card.has-table {
        padding-block-start: 0;
        padding-block-end: 0;
    }

    .col-bleed {
        margin: calc(-1 * var(--space-6));
        margin-right: inherit;
        padding: var(--space-6) 0;
        border-right: 1px solid var(--border);

        > * {
            padding: 0 var(--space-6);
        }
    }

    /* Stick the table to the edges */
    .table-wrapper {
        margin: 0 calc(-1*var(--space-6));
        position: relative;

        tr th:first-child,
        tr td:first-child {
            padding-left: var(--space-6);
        }
        tr th:last-child,
        tr td:last-child {
            padding-right: var(--space-6);
        }

        th a {
            color: inherit;
            &:hover {
                color: var(--primary);
            }
        }

        th a[data-sort-field] {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.2em;
        }

        th a[data-sorted]::after {
            content: "";
            flex: 0 0 auto;
            width: 1em;
            height: 1em;
            background-color: currentColor;
            -webkit-mask: center / contain no-repeat;
            mask: center / contain no-repeat;
        }

        th a[data-sorted="asc"]::after {
            -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='19' x2='12' y2='5'/%3E%3Cpolyline points='5 12 12 5 19 12'/%3E%3C/svg%3E");
        }

        th a[data-sorted="desc"]::after {
            -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cpolyline points='19 12 12 19 5 12'/%3E%3C/svg%3E");
            mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cpolyline points='19 12 12 19 5 12'/%3E%3C/svg%3E");
        }

        th > input[type=checkbox],
        td > input[type=checkbox] {
            vertical-align: middle;
        }

        .bulk-actions {
            box-shadow: -10px 0 10px var(--card);
            position: absolute;
            right: var(--space-6);
            top: var(--space-2);
            z-index: 1;
        }

        .actions button.more {
            padding: 0 var(--space-1);
            border-radius: 0;
        }
    }
}

.data-field {
    label {
        font-weight: var(--font-semibold);
    }
}

.stat-card {
    .stat-value {
        font-size: var(--text-1);
        font-weight: var(--font-semibold);
    }
}

.dot-indicator {
    position: relative;

    &.is-active::before {
        content: "";
        position: absolute;
        inset-block: -5px auto;
        inset-inline: auto 7px;
        width: 10px;
        height: 10px;
        border: 0;
        border-radius: 50%;
        background: var(--danger);
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
    }
}

/* Dialogs / modals */
.preview-modal {
    padding: 0;
    position: fixed;
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 40px);

    .dialog-body {
        padding: 0;
    }

    #iframe {
        border: 0;
        max-height: 100%;
        min-height: 70vh;
        padding: 0;
        margin: 0;
        width: 100%;
    }
}

.code-source-modal {
    padding: 0;
    width: 90vw;
    max-width: 1100px;
    max-height: calc(100vh - 40px);

    .dialog-body {
        padding: 0;
    }

    .code-editor {
        border: 0;
        border-radius: 0;
    }
}

.media-picker-modal {
    padding: 0;
    min-width: min(90vw, 900px);
    max-height: calc(100vh - 40px);

    .dialog-body {
        background: var(--body);
        padding-left: 0;
        padding-right: 0;
    }

    iframe {
        border: 0;
        min-height: 70vh;
        width: 100%;
    }
}

/* Editors */
.plain-editor,
.plain-editor textarea,
.code-editor {
    min-height: 250px;
    position: relative;
    width: 100%;
    border: 0;
}

code-editor,
.code-editor {
    display: block;
    height: 65vh;

    .cm-editor {
        height: 100%;
    }

    .cm-lineNumbers .cm-gutterElement {
        color: var(--faint-foreground);
        padding-inline-end: var(--space-3);
    }

    .cm-gutters {
        margin-inline-end: var(--space-3);
    }
}

visual-editor {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    width: 100%;

    iframe {
        border: 0;
        width: 100%;
        min-height: 65vh;
    }
}

.editor {
    margin-block-end: var(--space-8);
}

.sql-btn {
    border-right: 0;
}

.sql-editor.sql-editor:popover-open {
    width: min(90vw, 40rem);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);

    textarea {
        width: 100%;
        box-sizing: border-box;
        font-family: var(--font-mono);
        resize: vertical;
    }
}

.campaign-test.campaign-test:popover-open {
    width: min(90vw, 24rem);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.media-upload.media-upload:popover-open {
    width: min(90vw, 24rem);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

@supports (anchor-name: --a) {
    .sql-btn {
        anchor-name: --sql-anchor;
    }

    .sql-editor.sql-editor {
        position-anchor: --sql-anchor;
        inset: auto !important;
        top: calc(anchor(bottom) + var(--space-1)) !important;
        right: anchor(right) !important;
    }

    .campaign-test-btn {
        anchor-name: --campaign-test-anchor;
    }

    .campaign-test.campaign-test {
        position-anchor: --campaign-test-anchor;
        inset: auto !important;
        bottom: calc(anchor(top) + var(--space-1)) !important;
        left: anchor(left) !important;
    }

    .media-upload-btn {
        anchor-name: --media-upload-anchor;
    }

    .media-upload.media-upload {
        position-anchor: --media-upload-anchor;
        inset: auto !important;
        top: calc(anchor(bottom) + var(--space-1)) !important;
        right: anchor(right) !important;
    }
}

/* Sections */

/* Dashboard */
section.dashboard {
    .chart-box {
        position: relative;
        height: 18rem;
    }
    .stat-card {
        display: flex;
        flex-direction: column;
        min-height: 9.5rem;
    }

    .stat-meta {
        margin-block: auto calc(-1 * var(--space-6));
        margin-inline: calc(-1 * var(--space-6));
        padding: var(--space-3) var(--space-6);
        border-block-start: 1px solid var(--border);
        font-size: var(--text-7);
    }
}

/* Lists */
section.lists {
    th, td {
        &.subscribers {
            text-align: center;
        }
    }

    .date-stack small {
        display: block;
        margin-block-start: var(--space-1);
    }
}

/* Subscribers */
.subscribers {
    .blocklisted {
        td > a,
        td .name-stack > div > a {
            color: var(--tone-red);
        }
    }

    td {
        &.email {
            width: 30%;
        }

        &.link-click-url {
            max-width: 220px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    }
}

/* Campaigns list and campaign builder: see section 14 below. */
section.campaigns tbody .spinner {
    display: inline-flex;
    vertical-align: middle;
}
section.campaigns tbody tr.status-running td {
    border-bottom-color: color-mix(in srgb, var(--primary) 20%, var(--border));
}

/* Templates */
section.templates {
    td .badge {
        min-width: 100px;
    }

    .editor-body {
        margin-block: var(--space-3);
    }
}

/* Analytics */
section.analytics {
    .chart-box,
    .donut-container {
        position: relative;
        height: 340px;
    }

    .conversions-summary {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-4) var(--space-12);
        margin-block: var(--space-3) var(--space-4);

        .figure {
            font-size: 1.75rem;
            font-weight: 600;
            line-height: 1.1;
            letter-spacing: -0.02em;
            font-variant-numeric: tabular-nums;
        }
    }

    .conversions-by-campaign td.num {
        font-variant-numeric: tabular-nums;
    }
}

/* Import */
section.import {
    .delimiter input {
        max-width: 100px;
    }

    .status {
        padding: var(--space-12);
    }

    .log-view .lines {
        max-height: 240px;
        text-align: start;
    }

    .fields fieldset {
        min-height: 170px;
    }
}

/* Media */
.media-files,
.attachments {
    .gallery {
        display: grid;
        gap: var(--space-4);
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        list-style: none;
    }

    figure {
        position: relative;
        padding: 0;
    }

    .thumb {
        align-items: center;
        aspect-ratio: 4 / 3;
        background: var(--faint);
        border-radius: var(--radius-medium);
        display: flex;
        justify-content: center;
        overflow: hidden;

        img {
            max-height: 100%;
            max-width: 100%;
            object-fit: cover;
        }
    }

    figcaption {
        display: grid;
        padding: var(--space-2);
    }

    .filename {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .actions {
        opacity: 0;
        position: absolute;
        right: var(--space-2);
        top: var(--space-2);
    }

    figure:hover .actions,
    figure:focus-within .actions {
        opacity: 1;
    }
}

/* Settings, and the brand page which shares its sub-nav tabs layout. */
:is(.settings, .brand-page) {
    .settings-tabs {
        display: flex;
        align-items: stretch;
        gap: var(--space-6);
        min-width: 0;

        /* The settings sections as the house sub-nav (canon section 2): 36px tiles, accent fill on the
           active one. It stays a role=tablist for ot-tabs; the horizontal tab rules are undone here. */
        .settings-sidebar {
            display: flex;
            flex: 0 0 auto;
            flex-direction: column;
            align-items: stretch;
            gap: 2px;
            width: 12rem;
            padding: 0;
            border: 0;
            background: transparent;
            align-self: flex-start;
            position: sticky;
            top: var(--space-6);

            [role="tab"] {
                display: flex;
                align-items: center;
                justify-content: flex-start;
                height: var(--nav-item-h);
                padding: 0 var(--space-3);
                border: 0;
                border-radius: var(--radius-large);
                background: transparent;
                color: var(--muted-foreground);
                font-size: var(--text-7);
                font-weight: 400;
                text-align: left;
                box-shadow: none;
            }

            [role="tab"]::after {
                display: none;
            }

            [role="tab"]:hover {
                background: color-mix(in srgb, var(--accent) 50%, transparent);
                color: var(--foreground);
            }

            [role="tab"][aria-selected="true"] {
                background: var(--accent);
                color: var(--foreground);
                font-weight: 500;
            }
        }

        >[role="tabpanel"] {
            flex: 1 1 auto;
            min-width: 0;
            padding-block: 0;
        }
    }

    [role="tabpanel"] > hr,
    .settings-items > hr {
        display: none;
    }

    .code-editor {
        height: 20vh;
        min-height: 350px;
    }

    .repeat-block {
        margin-block: 0 var(--space-6);
        padding: 0;
        border-radius: var(--radius-medium);

        summary {
            background: var(--card);
        }
    }

    &.is-searching {
        .settings-tabs {
            display: grid;
            grid-template-columns: 12rem 1fr;
            grid-template-rows: repeat(20, auto);
            column-gap: var(--space-6);
            row-gap: 0;
        }

        .settings-tabs>[role="tablist"] {
            grid-column: 1;
            grid-row: 1 / -1;
        }

        .settings-tabs>[role="tabpanel"] {
            display: none !important;
        }

        .settings-tabs>[role="tabpanel"].search-match {
            display: block !important;
            grid-column: 2;
            margin-bottom: var(--space-6);
        }

        [role="tabpanel"] [role="tabpanel"] {
            display: block !important;
        }

        [role="tabpanel"] hr {
            display: none;
        }

        .search-hide {
            display: none !important;
        }
    }
    fieldset.card {
        padding-block-start: var(--space-4);
    }
}

/* Users & roles */
section.users {
    td .badge {
        margin-inline: var(--space-1);
    }
}

/* Bounces */
.bounces {
    tr.details td,
    tr.detail td {
        max-width: 0;
    }

    pre {
        max-width: 100%;
        overflow-x: auto;
        padding: var(--space-2) var(--space-3);
    }

    .blocklisted {
        color: var(--tone-red);
    }
}

/* Logs */
.log-view {
    .lines {
        border: 1px solid var(--border);
        font-family: var(--font-mono);
        font-size: var(--text-7);
        height: 70vh;
        overflow-y: auto;
        padding: var(--space-4);
    }

    .line {
        display: block;
        margin-block-end: 2px;

        &:hover {
            background: var(--faint);
        }
    }

    .timestamp,
    .file {
        color: var(--primary);
        display: inline-block;
        margin-inline-end: var(--space-2);
        min-width: 100px;
        user-select: auto;
    }

    .timestamp {
        margin-inline-end: var(--space-4);
    }
}

/* Forms */
.forms {
    code-editor {
        font-size: var(--text-8);
        height: auto;
        max-height: 40vh;
        min-height: 0;
    }
    .lists {
        max-height: 30vh;
        overflow-y: auto;
    }
}

/* Send controls (campaign form Sending section, campaign page status strip, deliverability). */
/* Sending section on the campaign form. */
fieldset.sending {
    margin-block-end: var(--space-6);

    > legend {
        font-weight: var(--font-semibold);
        padding: 0;
    }

    > .caption {
        margin: var(--space-1) 0 var(--space-3);
    }

    details > summary {
        align-items: flex-start;
    }

    .summary-text {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
        flex: 1;

        .name { font-weight: var(--font-medium); }
        .sentence { font-weight: var(--font-normal); }
    }

    summary > .badge { margin-inline-start: var(--space-3); flex-shrink: 0; }

    details > .group-body {
        margin: 0;
        padding: var(--space-4);
    }

    details > .group-body > .caption {
        margin: 0 0 var(--space-4);
    }
}

/* A sentence with inline inputs ("Up to [500] messages a day"). */
.inline-sentence {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-block-end: var(--space-3);

    input, select {
        width: auto;
        margin: 0;
    }

    input[type="number"] { width: 6rem; }
    input[type="time"] { width: 8.75rem; }
    select { width: auto; max-width: 16rem; }
}

/* Radio choices stacked with their sub-controls indented. */
.choice-list {
    > label[data-field] { margin-block-end: var(--space-2); }
    > .choice-body { margin: 0 0 var(--space-4) calc(var(--space-6) + var(--space-1)); }
}

/* Audience condition builder. */
.filter-builder {
    .fgroup {
        padding: var(--space-4);
        background: var(--faint);
        border: 1px solid var(--border);
        border-radius: var(--radius-medium);
    }

    .fgroup > .group-label {
        display: block;
        margin-block-end: var(--space-3);
        color: var(--muted-foreground);
        font-size: var(--text-8);
    }

    .frow {
        display: flex;
        align-items: stretch;
        gap: var(--space-2);
        margin-block-end: var(--space-2);
    }

    .frow > fieldset.group { flex: 1; margin: 0; min-width: 0; }
    .frow > fieldset.group > select { flex: 0 1 11rem; }
    .frow > fieldset.group > select.op { flex: 0 1 10rem; }
    .frow > fieldset.group > input,
    .frow > fieldset.group > ot-taginput { flex: 1 1 10rem; }
    .frow > fieldset.group > ot-taginput { border-start-start-radius: 0; border-end-start-radius: 0; }
    .frow > button.ghost { flex-shrink: 0; align-self: center; }

    .or-divider {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        margin-block: var(--space-3);
        color: var(--muted-foreground);
        font-size: var(--text-8);
        text-transform: uppercase;
        letter-spacing: 0.06em;

        &::before, &::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
    }

    .match-count {
        margin-block: var(--space-4) var(--space-2);
        display: flex;
        align-items: center;
        gap: var(--space-3);
        flex-wrap: wrap;
    }

    .match-count strong { font-size: var(--text-5); }

    .advanced-query textarea {
        width: 100%;
        min-height: 4.5rem;
        font-family: var(--font-mono);
        font-size: var(--text-8);
    }
}

/* Ramp preview: the dashboard's dl.stat-meta pattern, one cell per send day. */
dl.ramp-preview {
    margin: var(--space-2) 0 var(--space-3);
    font-size: var(--text-7);

    dt, dd { margin: 0; }
}

/* Weekday checkboxes in one row. */
.day-picker {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    margin-block-end: var(--space-2);

    label { display: inline-flex; align-items: center; gap: var(--space-1); margin: 0; font-weight: var(--font-normal); }
}

/* Hold banner actions. */
[role="alert"] .alert-body { flex: 1; min-width: 0; }
[role="alert"] .alert-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-block-start: var(--space-3); }

/* Deliverability tables: count + muted rate stacked in one cell. */
td.rate-cell { white-space: nowrap; }
td.rate-cell .rate { display: block; }
.health-badge { white-space: nowrap; }

@media (max-width: 640px) {
    .filter-builder .frow > fieldset.group {
        flex-direction: column;
        align-items: stretch;

        /* In a column the flex basis would become a height: reset every basis set above. */
        > select, > select.op, > input, > input.attrib-key, > input[type="number"], > input[type="date"],
        > ot-taginput, > span.unit, > .day-picker { flex: 0 0 auto; width: 100%; }
        > :not(:first-child) { border-inline-end-color: var(--input); margin-block-start: -1px; }
        > ot-taginput { border-radius: 0 0 var(--radius-medium) var(--radius-medium); }
    }
}

/* Inline validation under a sending group, and the read-only audience rows. */
.field-error {
    color: var(--danger);
    font-size: var(--text-7);
    margin: 0 0 var(--space-3);
}

fieldset.sending {

    ul.filter-readonly {
        margin: 0 0 var(--space-3);
        padding-inline-start: var(--space-5);

        li + li::before {
            content: attr(data-join);
            display: block;
            color: var(--muted-foreground);
            font-size: var(--text-8);
            text-transform: uppercase;
            letter-spacing: 0.06em;
            margin-block: var(--space-1);
        }
    }
}

.filter-builder .frow > fieldset.group > input.attrib-key { flex: 0 1 9rem; }
.filter-builder .frow > fieldset.group > input[type="number"],
.filter-builder .frow > fieldset.group > input[type="date"] { flex: 0 1 10rem; }
.filter-builder .frow > fieldset.group > span.unit {
    display: inline-flex;
    align-items: center;
    padding-inline: var(--space-2);
    color: var(--muted-foreground);
    font-size: var(--text-8);
    border: 1px solid var(--input);
    border-inline-start: 0;
}

/* Responsive: card-per-row tables and settings tabs (the shell rules follow the theme block below). */
@media (max-width: 769px) {
    :is(.settings, .brand-page) .settings-tabs {
        display: block;

        > [role="tablist"] {
            margin: 0 0 var(--space-4);
            position: static;
            width: auto;
            flex-direction: row;
            overflow-x: auto;
            gap: var(--space-1);
            padding-bottom: var(--space-1);
            scrollbar-width: none;
        }

        > [role="tablist"] [role="tab"] {
            flex-shrink: 0;
            height: 2rem;
            padding: 0 var(--space-3);
            border-radius: var(--radius-medium);
            white-space: nowrap;
        }
    }

    /* Make table rows into cards. */
    .page-content table:not(.rte-content table) {
        display: block;

        thead {
            display: none;
        }

        thead:has(th input[type="checkbox"], th a[data-sort-field]) {
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            gap: var(--space-2);
            padding-block: var(--space-4);
            border-bottom: 0;
        }

        thead tr {
            display: contents;
        }

        th {
            display: none;
            width: auto;
            padding: 0;
            border: 0;
        }

        th:has(input[type="checkbox"], a[data-sort-field]) {
            display: block;
        }

        /* Sort links become pills. */
        th a[data-sort-field] {
            display: inline-flex;
            align-items: center;
            gap: var(--space-1);
            min-height: 1.75rem;
            padding: 2px var(--space-3);
            border: 1px solid var(--border);
            border-radius: var(--radius-full);
        }

        tbody {
            display: block;
        }

        tbody tr {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto auto;
            row-gap: var(--space-3);
            padding-block: var(--space-4);
        }

        td {
            grid-column: 1 / -1;
            width: auto;
            max-width: none;
            padding: 0;
            border: 0;
            overflow-wrap: anywhere;
            white-space: normal;
            text-align: start;
        }

        td:first-child:not([colspan]),
        td:first-child:has(> input[type="checkbox"]) + td,
        td.actions {
            grid-row: 1;
            grid-column: 1;
            padding-block-end: var(--space-3);
            border-bottom: 1px solid var(--border);
        }

        td:first-child:has(> input[type="checkbox"]) {
            grid-column: 2;
            padding-inline: var(--space-3);
        }

        td.actions {
            grid-column: 3;
            text-align: end;
        }

        td .view {
            display: none;
        }

        td[data-label] {
            display: flex;
            flex-wrap: wrap;
            align-items: baseline;
            column-gap: var(--space-4);
            text-align: end;

            &::before {
                content: attr(data-label);
                flex: 0 0 auto;
                margin-inline-end: auto;
                color: var(--muted-foreground);
                text-align: start;
            }
        }

        td.stats {
            &:not(:has(dd)) {
                display: none;
            }

            dl {
                row-gap: var(--space-3);
            }

            dl > div {
                column-gap: var(--space-4);
            }

            dt {
                min-width: 0;
            }

            dd {
                text-align: end;
            }
        }

        td.lists {
            padding-block-end: var(--space-3);
            border-bottom: 1px solid var(--border);

            li {
                max-width: none;
            }

            li a {
                white-space: normal;
            }
        }

        td.type .schedule {
            flex-direction: row;
            justify-content: space-between;
            align-items: baseline;
            column-gap: var(--space-4);
        }
    }

    .page-content.card.has-table {
        background: none;
        border: 0;
        box-shadow: none;
        padding-inline: 0;
    }

    .page-content .table-wrapper {
        margin-inline: 0;

        tr :is(th, td) {
            &:first-child { padding-left: 0; }
            &:last-child { padding-right: 0; }
        }

        tbody tr {
            margin-block-end: var(--space-3);
            padding-inline: var(--space-4);
            background-color: var(--card);
            border: 1px solid var(--border);
            border-radius: var(--radius-medium);
            box-shadow: var(--shadow-small);
        }

        tbody td:first-child:not([colspan]):not(:has(> input[type="checkbox"])),
        tbody td:first-child:has(> input[type="checkbox"]) + td {
            margin-inline-start: calc(-1 * var(--space-4));
            padding-inline-start: var(--space-4);
        }

        tbody td.lists {
            margin-inline: calc(-1 * var(--space-4));
            padding-inline: var(--space-4);
        }

        tbody td.actions {
            margin-inline-end: calc(-1 * var(--space-4));

            button.more {
                font-size: var(--text-3);
                padding-inline: var(--space-4) 0;
            }
        }

        .bulk-actions {
            top: var(--space-3);
            right: var(--space-3);
            box-shadow: none;

            > button {
                height: 1.75rem;
            }
        }

        .pagination {
            padding-inline-end: 0;
        }
    }

    section.campaign {
        [role="tablist"] {
            max-width: 100%;
            overflow-y: auto;
        }
    }
}

/* ==================================================================================
 * Portal design system on the admin (design/admin-theme-spec.md). Shell, primitives and
 * responsive rules. Values come from the portal's globals.css and primitives; the accent
 * is the portal's info blue, never a tenant colour.
 * ================================================================================== */
html, body { background: var(--body); color: var(--foreground); }
body { font-size: var(--text-7); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
a.unstyled { color: inherit; }
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklab, var(--foreground) 22%, transparent) transparent; }
button:not(:disabled), [role="button"]:not(:disabled), select:not(:disabled), summary { cursor: pointer; }
h1, h2, h3, h4, h5 { letter-spacing: -0.01em; }

/* ---------- Shell: top bar + icon rail + contextual panel + liquid work area ---------- */
#app[data-sidebar-layout] {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    gap: 0;
    grid-template-columns: none;
    overflow: hidden;
}

nav[data-topnav] {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-shrink: 0;
    height: var(--topbar-h);
    padding: 0 var(--space-4);
    background: var(--rail);
    border-bottom: 1px solid var(--border);
    box-shadow: none;
    position: static;
    z-index: 30;

    button[data-sidebar-toggle] { display: none; margin: 0; padding: 0; width: 2rem; height: 2rem; border: 0; border-radius: var(--radius-medium); color: var(--muted-foreground); background: transparent; box-shadow: none; }
    button[data-sidebar-toggle]:hover { background: var(--accent); color: var(--foreground); }
    button[data-sidebar-toggle] .icon { margin: 0; font-size: 1.125rem; }

    .brand { display: inline-flex; align-items: center; gap: var(--space-2); color: var(--foreground); min-width: 0; }
    .brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; border-radius: var(--radius-small); background: var(--foreground); color: var(--body); }
    .brand-mark .icon { margin: 0; font-size: 0.875rem; }
    .brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
    /* A configured logo sits on a white tile so a dark mark survives the dark rail. */
    .brand img { display: block; height: 1.75rem; width: auto; max-height: 1.75rem; max-width: 10rem; object-fit: contain; padding: 3px 6px; border-radius: var(--radius-small); background: #fff; border: 1px solid var(--border); }
    .spacer { flex: 1; }
    .topbar-search { display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-h-sm); width: 14rem; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-medium); background: color-mix(in srgb, var(--background) 60%, transparent); color: var(--muted-foreground); font-size: var(--text-7); font-weight: 400; box-shadow: none; }
    .topbar-search:hover { color: var(--foreground); border-color: color-mix(in srgb, var(--ring) 40%, transparent); background: color-mix(in srgb, var(--background) 60%, transparent); }
    .topbar-search span { flex: 1; text-align: left; }
    .topbar-search .icon { margin: 0; font-size: 0.875rem; }
    .topbar-search kbd { border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 500; font-family: var(--font-sans); background: transparent; box-shadow: none; color: inherit; }
    .topbar-icon { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--radius-medium); background: transparent; color: var(--muted-foreground); box-shadow: none; }
    .topbar-icon:hover { background: var(--accent); color: var(--foreground); }
    .topbar-icon .icon { margin: 0; font-size: 1rem; }
    .topbar-icon > span { display: flex; }
    .user-trigger { width: 2rem; height: 2rem; padding: 0; border: 1px solid var(--border); border-radius: 9999px; background: var(--card); color: var(--foreground); justify-content: center; box-shadow: none; overflow: hidden; }
    .user-trigger:hover { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring) 40%, transparent); background: var(--card); }
    .user-trigger .avatar img, .user-trigger .avatar span { width: 2rem; height: 2rem; border-radius: 9999px; font-size: var(--text-9); }
    .user-label { display: none; }
    .theme-switch { display: flex; gap: var(--space-1); padding: var(--space-1) var(--space-2); }
    .theme-switch button.is-active { background: var(--accent); color: var(--foreground); }
    menu[popover] { top: calc(var(--topbar-h) - 4px) !important; }
}

.shell-body { display: flex; flex: 1; min-height: 0; }

/* Icon rail: 64px of icons; expands to labels on hover as an overlay, or stays open when pinned. */
.rail-slot { position: relative; flex-shrink: 0; width: var(--rail-w); transition: width var(--transition); z-index: 15; }
html[data-rail-pinned] .rail-slot { width: var(--rail-w-open); }

aside[data-rail] {
    position: absolute;
    inset: 0 auto 0 0;
    width: var(--rail-w);
    display: flex;
    flex-direction: column;
    padding: var(--space-2) 0;
    background: var(--rail);
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: width var(--transition), box-shadow var(--transition);

    nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; }
    .rail-foot { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-1); }
    a, button { position: relative; display: flex; align-items: center; gap: var(--space-3); height: 2.75rem; width: 100%; padding: 0 var(--space-3); border: 0; border-radius: 0; background: transparent; color: var(--muted-foreground); box-shadow: none; font-size: var(--text-7); font-weight: 400; justify-content: flex-start; }
    a > span:first-child, button > span:first-child { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 2.5rem; height: 2.5rem; border-radius: var(--radius-large); transition: background var(--transition-fast), color var(--transition-fast); }
    a:hover, button:hover { background: transparent; color: var(--foreground); }
    a:hover > span:first-child, button:hover > span:first-child { background: var(--accent); color: var(--foreground); }
    a[aria-current] { color: var(--foreground); }
    a[aria-current] > span:first-child { background: color-mix(in srgb, var(--primary) 12%, transparent); }
    a[aria-current]::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); height: 1.5rem; width: 3px; border-radius: 0 9999px 9999px 0; background: var(--primary); }
    .icon { margin: 0; font-size: 1.25rem; }
    .label { white-space: nowrap; opacity: 0; transition: opacity var(--transition-fast); }
    .rail-pin .icon { transition: transform var(--transition); }
    .rail-pin .when-pinned { display: none; }
}
html[data-rail-pinned] aside[data-rail] { width: var(--rail-w-open); }
html[data-rail-pinned] aside[data-rail] .label { opacity: 1; }
html[data-rail-pinned] aside[data-rail] .rail-pin .icon { transform: rotate(180deg); }
html[data-rail-pinned] aside[data-rail] .rail-pin .when-pinned { display: inline; }
html[data-rail-pinned] aside[data-rail] .rail-pin .when-open { display: none; }
@media (hover: hover) {
    html:not([data-rail-pinned]) aside[data-rail]:hover { width: var(--rail-w-open); box-shadow: var(--shadow-large); }
    html:not([data-rail-pinned]) aside[data-rail]:hover .label { opacity: 1; }
}

/* Contextual panel: the active area's pages. Every area is in the markup (the phone drawer
   shows them all); on desktop only the active one renders, and no panel at all without one. */
aside[data-sidebar] {
    position: static;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--panel-w);
    height: auto;
    margin: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    box-shadow: none;
    overflow-y: auto;
    transform: none;
    visibility: visible;

    .panel-area { display: none; }
    .panel-area[data-active] { display: block; }
    .panel-title { display: flex; align-items: center; gap: var(--space-2); height: 3rem; padding: 0 var(--space-4); font-size: var(--text-7); font-weight: 600; letter-spacing: -0.01em; flex-shrink: 0; color: var(--foreground); }
    .panel-title .icon { display: none; }
    nav { margin: 0; padding: 0 var(--space-3) var(--space-4); max-height: none; overflow: visible; }
    nav ul { list-style: none; margin: 0; padding: 0; }
    nav ul > li { margin: 0 0 2px; }
    .group-heading { display: block; padding: var(--space-5) var(--space-3) var(--space-1); font-size: var(--text-8); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }
    a { position: relative; display: flex; align-items: center; height: var(--nav-item-h); padding: 0 var(--space-3); border-radius: var(--radius-large); color: var(--muted-foreground); font-size: var(--text-7); font-weight: 400; transition: background var(--transition-fast), color var(--transition-fast); }
    a:hover { background: var(--accent); color: var(--foreground); }
    a[aria-current] { background: color-mix(in srgb, var(--primary) 8%, transparent); color: var(--foreground); font-weight: 500; }
    a[aria-current]::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 9999px; background: var(--primary); }
    a .count { margin-left: auto; font-size: var(--text-8); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
    a .icon { display: none; }
    #footer { margin-top: auto; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); flex-shrink: 0; }
}
aside[data-sidebar]:not(:has(.panel-area[data-active])) { display: none; }

.panel-chips { display: none; }

main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    grid-row: auto;
    grid-column: auto;

    > .container { max-width: none; width: 100%; margin: 0; padding: var(--space-6) var(--space-8); display: flex; flex-direction: column; flex: 1; }
}

/* ---------- Page header (PageHeader primitive) and page body ---------- */
.page-header {
    display: block;
    flex-shrink: 0;
    margin: 0;
    padding: var(--space-5) var(--space-8);
    border-bottom: 1px solid var(--border);
    background: var(--background);

    .breadcrumbs { display: flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-2); font-size: var(--text-8); }
    .breadcrumbs a { color: var(--muted-foreground); }
    .breadcrumbs a:hover { color: var(--foreground); }
    .breadcrumbs .icon { margin: 0; font-size: 0.75rem; color: color-mix(in srgb, var(--muted-foreground) 60%, transparent); }
    .breadcrumbs .current { color: var(--foreground); }
    .title-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3) var(--space-6); }
    .title-block { min-width: 0; display: flex; align-items: flex-start; gap: var(--space-4); }
    .title-line { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
    h1, .page-title { margin: 0; font-size: 1.75rem; line-height: 2.25rem; font-weight: 600; letter-spacing: -0.02em; }
    .title-line h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    h1 > span:not(.badge):not(.filter-tag) { font-weight: 400; color: var(--muted-foreground); }
    h1 .badge, h1 .filter-tag { font-size: var(--text-8); font-weight: 500; letter-spacing: 0; vertical-align: middle; }
    .caption { margin: var(--space-1) 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
    .actions { display: flex; flex-shrink: 0; align-items: center; gap: var(--space-2); }
    .thumb { display: flex; align-items: center; justify-content: center; width: 3.5rem; height: 3.5rem; flex-shrink: 0; border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--card); overflow: hidden; }
    .thumb span { font-size: var(--text-6); font-weight: 600; }
    .meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); margin-top: var(--space-1); font-size: var(--text-7); color: var(--muted-foreground); }
    .meta-line a { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--info); }
    .back { display: inline-flex; align-items: center; color: var(--muted-foreground); }
    .back .icon { font-size: 1.25rem; margin: 0; }
    .back:hover { color: var(--foreground); }
    .avatar { flex-shrink: 0; }
    .avatar img, .avatar span { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-large); font-size: var(--text-7); }
    h4 { margin: 0; }
}

/* The header band bleeds to the work-area edges; the container's padding frames the body. */
main > .container > .page-header, main > .container > * > .page-header { margin: 0 calc(-1 * var(--space-8)) var(--space-6); }
main > .container > .page-header:first-child, main > .container > :first-child > .page-header:first-child { margin-top: calc(-1 * var(--space-6)); }
.page-body { display: flex; flex-direction: column; gap: var(--space-6); }
.page-body > .page-content:last-child { margin-bottom: 0; }

/* Existing views keep their Oat grid header (.row > .col-4 title, .col-8 tools) until each
   is moved to .title-row; this lays that grid out as the same band. */
.page-header.row {
    width: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3) var(--space-6);
    --grid-gap: 0;

    > [class*="col-"] { grid-column: auto; width: auto; min-width: 0; flex: 1 1 auto; }
    > .col-8, > .col-6.col-end, > .col-4.col-end { flex: 0 1 auto; margin-left: auto; justify-content: flex-end; }
    > .col-12 { flex: 1 1 100%; }
    h1, .page-title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); white-space: normal; }
    h1 > span:not(.badge):not(.filter-tag) { font-size: var(--text-5); }
    .hstack { gap: var(--space-2); flex-wrap: nowrap; }
    .search-form { display: flex; }
    .search-form input:not([type="checkbox"]) { height: var(--control-h-sm); width: 14rem; box-shadow: none; }
    .search-form fieldset.group { margin: 0; }
    .search-form fieldset.group > button { height: var(--control-h-sm); padding: 0 var(--space-3); }
    .search-form ot-dropdown { display: block; }
}

/* Section primitive: H2 18px + optional description, right-aligned meta. */
.section-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-1) var(--space-4); margin-bottom: var(--space-3); }
.section-head h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.section-head p { margin: 2px 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.section-head .meta { font-size: var(--text-8); color: var(--muted-foreground); }

/* ---------- 4. Cards ---------- */
.card {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-small);
    padding: var(--space-6);
}
.card > header h4, .card > header h5, .card > h4, .card > h5 { margin: 0; font-size: var(--text-6); font-weight: 600; }
.card > header { margin-bottom: var(--space-4); }
.card > header p { margin: 2px 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.page-content { margin: 0; }
.page-content.card.has-table { padding: 0; overflow: hidden; }
.page-content.card.has-table > h4, .page-content.card.has-table > header { padding: var(--space-4) var(--space-4) 0; }

/* ---------- 5. Filter bar + tables (FilterBar + DataTable primitives) ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.filter-bar .count { margin-left: auto; font-size: var(--text-8); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.filter-bar input, .filter-bar select { height: var(--control-h-sm); width: auto; }
.filter-bar input[type="search"], .filter-bar input[name="query"], .filter-bar input[name="search"] { width: 14rem; }
.filter-bar .search-form fieldset.group { margin: 0; }
.filter-bar .search-form { display: contents; }
.filter-bar select { padding-right: var(--space-8); }

/* Segmented chip group (portal sites filter chips). */
.segmented { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-medium); background: var(--card); }
.segmented > a, .segmented > button { height: 1.75rem; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-small); background: transparent; color: var(--muted-foreground); font-size: var(--text-8); font-weight: 500; box-shadow: none; display: inline-flex; align-items: center; gap: var(--space-1); }
.segmented > [aria-current], .segmented > [aria-pressed="true"] { background: var(--accent); color: var(--foreground); }

.page-content .table-wrapper { margin: 0; position: relative; }
.page-content .table-wrapper tr th:first-child, .page-content .table-wrapper tr td:first-child { padding-left: var(--space-4); }
.page-content .table-wrapper tr th:last-child, .page-content .table-wrapper tr td:last-child { padding-right: var(--space-4); }
.table-scroll { overflow-x: auto; }
.table-scroll > table { min-width: 960px; }
@media (min-width: 770px) { .deliverability .table-scroll > table { min-width: 1180px; width: 100%; } }
.deliverability td:first-child a { white-space: nowrap; }
.subscribers .blocklisted td > a, .subscribers .blocklisted td .name-stack > div > a.name { color: inherit; }

table {
    font-size: var(--text-7);
    border-collapse: collapse;

    thead { border: 0; }
    th {
        position: sticky; top: 0; z-index: 2;
        padding: var(--space-3) var(--space-4);
        background: var(--card);
        border-bottom: 1px solid var(--border);
        font-size: var(--text-9);
        font-weight: 500;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        color: var(--muted-foreground);
        text-align: left;
        white-space: nowrap;
        vertical-align: middle;
    }
    th a[data-sort-field] { display: inline-flex; gap: var(--space-1); justify-content: flex-start; color: inherit; text-transform: uppercase; }
    th a[data-sorted] { color: var(--foreground); }
    th.align-right, td.align-right { text-align: right; }
    td { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); vertical-align: middle; height: var(--row-h); }
    tbody tr { transition: background var(--transition-fast); }
    tbody tr:hover td { background: color-mix(in srgb, var(--accent) 40%, transparent); }
    tbody tr:last-child td { border-bottom: 0; }
    td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
    td.date { white-space: nowrap; }
    td .sub { white-space: nowrap; }
    td .view { display: none; }
    &.has-select tbody tr:hover { background: transparent; }
    &.has-select tbody tr:hover td { border-bottom-color: var(--border); }
    input[type="checkbox"] { margin: 0; vertical-align: middle; }
}

/* Primary cell: anchor tile + name + meta stack. */
.name-stack { display: flex; align-items: center; gap: var(--space-3); }
.name-stack .avatar { flex-shrink: 0; }
.name-stack > div { min-width: 0; }
.name-stack .name { display: block; font-weight: 500; color: var(--foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.name-stack .meta { display: block; margin-top: 1px; font-size: var(--text-8); color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40ch; }
.avatar img, .avatar span { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-medium); font-size: var(--text-8); font-weight: 500; }
.avatar.tile span { background: var(--muted); border: 1px solid var(--border); color: var(--muted-foreground); }
td .stack { display: flex; flex-direction: column; gap: 2px; }
td .sub { font-size: var(--text-8); color: var(--muted-foreground); }

/* Table footer: count left, per-page + pager right. */
.table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-8); color: var(--muted-foreground); }
.table-foot .count { font-variant-numeric: tabular-nums; }
.table-foot .right { display: flex; align-items: center; gap: var(--space-3); }
.table-foot label { display: flex; align-items: center; gap: var(--space-2); font-weight: 400; margin: 0; }
.table-foot select { height: 1.75rem; width: 5rem; font-size: var(--text-8); padding: 0 var(--space-6) 0 var(--space-2); }
.table-foot .pager { display: flex; align-items: center; gap: var(--space-1); }
.table-foot .pager a, .table-foot .pager button { display: inline-flex; align-items: center; justify-content: center; width: 1.75rem; height: 1.75rem; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-medium); background: transparent; color: var(--foreground); box-shadow: none; }
.table-foot .pager a:hover, .table-foot .pager button:hover { background: var(--accent); }
.table-foot .pager [aria-disabled="true"], .table-foot .pager :disabled { opacity: 0.4; pointer-events: none; }
.table-foot .pager span { min-width: 5.5rem; text-align: center; font-variant-numeric: tabular-nums; }
.table-foot .pager .icon { margin: 0; font-size: 1rem; }
/* Pager rendered by the views today (models.PageProps): the table-foot look until the foot lands. */
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: var(--space-1); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-8); color: var(--muted-foreground); }
.pagination a { display: inline-flex; align-items: center; justify-content: center; min-width: 1.75rem; height: 1.75rem; padding: 0 var(--space-2); border: 1px solid transparent; border-radius: var(--radius-medium); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.pagination a:hover { background: var(--accent); color: var(--foreground); }
.pagination a[aria-current="page"] { border-color: var(--border); background: var(--card); color: var(--foreground); font-weight: 500; }

/* Footnote under cached counts (dashboard, lists): when the cache last refreshed and when it refreshes next. */
.cache-notice { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0; font-size: var(--text-8); color: var(--muted-foreground); }
.page-content + .cache-notice { margin-top: var(--space-3); }
.cache-notice > .icon { flex-shrink: 0; margin-top: 2px; }
.cache-notice time { color: var(--foreground); font-variant-numeric: tabular-nums; }
.cache-notice a { text-decoration: underline; text-underline-offset: 2px; }
.table-wrapper .bulk-actions { position: absolute; top: var(--space-2); right: var(--space-4); box-shadow: none; }

/* Kebab per row. */
td.actions { text-align: right; white-space: nowrap; }
td.actions button.more, .kebab { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border: 0; border-radius: var(--radius-medium); background: transparent; color: var(--muted-foreground); box-shadow: none; }
td.actions button.more:hover, .kebab:hover { background: var(--accent); color: var(--foreground); }
td.actions .icon, .kebab .icon { margin: 0; font-size: 1rem; }

/* ---------- 6. Badges (semantic vocabulary) ---------- */
.badge {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
    height: 1.375rem; padding: 0 var(--space-2);
    border: 1px solid transparent; border-radius: var(--radius-medium);
    background: var(--badge-bg); color: var(--badge-fg);
    font-size: var(--text-8); font-weight: 500; line-height: 1; white-space: nowrap;
    max-width: none; overflow: visible;
    --badge-fg: var(--muted-foreground); --badge-bg: var(--muted);
}
.badge .dot { display: none; }
.badge .icon { margin: 0; font-size: 0.75rem; }
.badge.small { height: 1.25rem; padding: 0 var(--space-2); font-size: var(--text-9); }
.badge.outline, .badge.status-draft { --badge-bg: transparent; border-color: var(--border); --badge-fg: var(--foreground); }
.badge.status-running, .badge.status-enabled, .badge.status-confirmed, .badge.status-finished.live, .badge[data-variant="success"] { --badge-fg: var(--success); --badge-bg: var(--tone-green-bg); }
.badge.status-scheduled, .badge.optin, .badge.campaign, .badge[data-variant="info"] { --badge-fg: var(--info); --badge-bg: var(--tone-blue-bg); }
.badge.status-paused, .badge.status-unconfirmed, .badge[data-variant="warning"] { --badge-fg: var(--warning); --badge-bg: var(--tone-amber-bg); }
.badge.status-cancelled, .badge.status-blocklisted, .badge.status-disabled, .badge[data-variant="danger"] { --badge-fg: var(--danger); --badge-bg: var(--tone-red-bg); }
.badge.status-finished, .badge.status-unsubscribed, .badge.tx, .badge[data-variant="secondary"] { --badge-fg: var(--muted-foreground); --badge-bg: var(--muted); }
.badge.status-finished .icon { color: var(--success); }
td .badge { margin: 0; }
.filter-tag { gap: 0; }
.filter-tag .badge { border-radius: var(--radius-medium) 0 0 var(--radius-medium); }
.filter-tag a { display: inline-flex; align-items: center; height: 1.375rem; padding: 0 var(--space-1); border-radius: 0 var(--radius-medium) var(--radius-medium) 0; background: var(--muted); color: var(--muted-foreground); }
.filter-tag a:hover { color: var(--foreground); }
.status-icon { font-size: 0.875rem; vertical-align: -1px; }

/* ---------- 7. Buttons ---------- */
button, .button, input[type="submit"] {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    height: var(--control-h); padding: 0 var(--space-4);
    border: 1px solid transparent; border-radius: var(--radius-medium);
    background: var(--secondary); color: var(--secondary-foreground);
    font-family: var(--font-sans); font-size: var(--text-7); font-weight: 500; line-height: 1; white-space: nowrap;
    box-shadow: var(--shadow-small);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    text-decoration: none;
}
button:hover, .button:hover { background: color-mix(in srgb, var(--secondary) 80%, transparent); }
button .icon, .button .icon { margin: 0; font-size: 1rem; flex-shrink: 0; }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
button:disabled, .button[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
button[data-variant="primary"], .button[data-variant="primary"] { background: var(--primary); color: var(--primary-foreground); }
button[data-variant="primary"]:hover, .button[data-variant="primary"]:hover { background: color-mix(in srgb, var(--primary) 90%, transparent); }
button[data-variant="danger"]:not(.ghost):not(.outline), .button[data-variant="danger"]:not(.ghost):not(.outline) { background: var(--danger); color: #fff; }
button.outline, .button.outline { background: var(--background); border-color: var(--border); color: var(--foreground); }
button.outline:hover, .button.outline:hover { background: var(--accent); }
button.outline[data-variant="danger"], .button.outline[data-variant="danger"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
button.ghost, .button.ghost { background: transparent; box-shadow: none; color: var(--foreground); }
button.ghost:hover, .button.ghost:hover { background: var(--accent); }
button.ghost[data-variant="danger"], .button.ghost[data-variant="danger"] { color: var(--danger); }
button.ghost[data-variant="danger"]:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
button.small, .button.small { height: var(--control-h-sm); padding: 0 var(--space-3); font-size: var(--text-8); gap: 6px; }
button.icon, .button.icon { width: var(--control-h); padding: 0; }
button.link, .button.link { background: transparent; box-shadow: none; color: var(--primary); padding: 0; height: auto; }
button.link:hover { text-decoration: underline; }
.theme-switch button { height: 1.75rem; width: 1.75rem; padding: 0; box-shadow: none; }

/* ---------- 8. Inputs ---------- */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]), select, textarea, ot-taginput {
    height: var(--control-h); width: 100%; min-width: 0;
    padding: 0 var(--space-3);
    border: 1px solid var(--input); border-radius: var(--radius-medium);
    background: transparent; color: var(--foreground);
    font-family: var(--font-sans); font-size: var(--text-7); line-height: 1.5;
    box-shadow: var(--shadow-small);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input::placeholder, textarea::placeholder { color: var(--muted-foreground); }
textarea { height: auto; min-height: 5rem; padding: var(--space-2) var(--space-3); }
select { padding-right: var(--space-8); background-position: right var(--space-2) center; }
ot-taginput { height: auto; min-height: var(--control-h); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-2); }
ot-taginput input { border: 0; box-shadow: none; height: 1.5rem; flex: 1; padding: 0 var(--space-1); }
input:disabled, select:disabled, textarea:disabled, ot-taginput[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
label[data-field], [data-field] > label, .data-field label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-7); font-weight: 500; margin-bottom: var(--space-4); }
[data-field] small, small[data-hint] { display: block; margin-top: 4px; font-size: var(--text-8); font-weight: 400; color: var(--muted-foreground); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-4); }
fieldset.group { display: flex; align-items: stretch; }
fieldset.group > input, fieldset.group > button { border-radius: 0; box-shadow: none; }
fieldset.group > :first-child { border-radius: var(--radius-medium) 0 0 var(--radius-medium); }
fieldset.group > :last-child { border-radius: 0 var(--radius-medium) var(--radius-medium) 0; }
fieldset.group > * + * { margin-left: -1px; }
fieldset.group > button.outline { border-color: var(--input); }
legend { padding: 0; font-size: var(--text-7); font-weight: 600; }
/* Settings cards are fieldsets: the legend reads as the card title, not a caption on the border. */
fieldset.card > legend { float: left; width: 100%; margin: 0 0 var(--space-4); padding: 0; font-size: var(--text-6); font-weight: 600; }
fieldset.card > legend + * { clear: both; }
input[type="checkbox"], input[type="radio"] { width: 1rem; height: 1rem; accent-color: var(--primary); }
progress, meter { height: 0.5rem; background: var(--muted); border-radius: 9999px; }
progress::-webkit-progress-bar { background: var(--muted); border-radius: 9999px; }
progress::-webkit-progress-value { background: var(--primary); border-radius: 9999px; }
meter::-webkit-meter-bar { background: var(--muted); border-radius: 9999px; }
meter::-webkit-meter-optimum-value { background: var(--primary); }
meter::-webkit-meter-suboptimum-value { background: var(--warning); }
meter::-webkit-meter-even-less-good-value { background: var(--danger); }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warning); }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }

/* Toggle switch (portal Switch): 36x20 pill, 16px thumb. */
.switch { position: relative; display: inline-flex; align-items: center; width: 2.25rem; height: 1.25rem; padding: 0; border: 0; border-radius: 9999px; background: var(--input); box-shadow: none; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch::after { content: ""; position: absolute; left: 2px; width: 1rem; height: 1rem; border-radius: 9999px; background: var(--background); box-shadow: var(--shadow-small); transition: transform var(--transition-fast); }
.switch[aria-checked="true"]::after { transform: translateX(1rem); }
.switch-row { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-7); }

/* ---------- 9. Stat strip (StatStrip primitive) ---------- */
.card.stat-strip {
    display: flex; padding: 0; margin: 0; overflow: hidden;
    > div, > a { display: block; flex: 1 1 0; min-width: 0; padding: var(--space-4) var(--space-5); }
    > * + * { border-left: 1px solid var(--border); }
    > a { color: inherit; text-decoration: none; transition: background var(--transition-fast); }
    > a:hover { background: color-mix(in srgb, var(--accent) 50%, transparent); }
    small.text-light { display: flex; align-items: center; gap: 6px; margin: 0; font-size: var(--text-9); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }
    small.text-light .icon { margin: 0; font-size: 0.875rem; }
    small.tone-success .icon { color: var(--success); }
    small.tone-warning .icon { color: var(--warning); }
    small.tone-danger .icon { color: var(--danger); }
    small.tone-info .icon { color: var(--info); }
    .stat-value { margin-top: var(--space-2); display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); font-size: 1.75rem; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
    .stat-value .of { font-size: var(--text-6); font-weight: 400; color: var(--muted-foreground); margin-left: 4px; }
    .stat-value .badge { font-size: var(--text-8); }
    .stat-value svg.spark { width: 72px; height: 24px; flex-shrink: 0; color: color-mix(in srgb, var(--muted-foreground) 50%, transparent); }
    .stat-meta { margin-top: 6px; font-size: var(--text-8); color: var(--muted-foreground); line-height: 1.4; }
    .stat-meta.up { color: var(--success); }
    .stat-meta.down { color: var(--danger); }
    progress { margin-top: var(--space-2); }
}
@media (max-width: 900px) {
    .card.stat-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); }
    .card.stat-strip > div { background: var(--card); border: 0 !important; }
}

/* ---------- 10. Tabs, sub-nav ---------- */
[role="tablist"] { display: flex; align-items: center; gap: var(--space-6); padding: 0; background: transparent; border-radius: 0; border-bottom: 1px solid var(--border); }
[role="tab"] { position: relative; height: auto; padding: var(--space-3) 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--muted-foreground); font-size: var(--text-7); font-weight: 400; }
[role="tab"]:hover { background: transparent; color: var(--foreground); }
[role="tab"][aria-selected="true"] { color: var(--foreground); font-weight: 500; }
[role="tab"][aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 9999px; background: var(--primary); }
[role="tab"] .count { border-radius: 9999px; background: var(--muted); padding: 2px 6px; font-size: var(--text-8); color: var(--muted-foreground); }

.sub-nav { width: 12rem; flex-shrink: 0; position: sticky; top: var(--space-6); align-self: flex-start; display: flex; flex-direction: column; gap: 2px; }
.sub-nav a { display: flex; align-items: center; gap: 10px; height: var(--nav-item-h); padding: 0 var(--space-3); border-radius: var(--radius-large); color: var(--muted-foreground); font-size: var(--text-7); }
.sub-nav a:hover { background: color-mix(in srgb, var(--accent) 50%, transparent); color: var(--foreground); }
.sub-nav a[aria-current] { background: var(--accent); color: var(--foreground); font-weight: 500; }
.sub-nav a .count { margin-left: auto; font-size: var(--text-8); color: var(--muted-foreground); }
.sub-nav .icon { margin: 0; font-size: 1rem; }
.with-sub-nav { display: flex; gap: var(--space-8); align-items: flex-start; }
.with-sub-nav > .sub-nav-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------- 11. Alerts, empty state, dialogs, dropdown menus ---------- */
[role="alert"] {
    display: flex; align-items: flex-start; gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border); border-radius: var(--radius-large);
    background: var(--card); color: var(--foreground); font-size: var(--text-7);
    margin: 0;
}
[role="alert"] > .icon { margin: 2px 0 0; font-size: 1rem; flex-shrink: 0; align-self: flex-start; }
[role="alert"][data-variant="warning"] { border-color: color-mix(in srgb, var(--warning) 30%, transparent); background: color-mix(in srgb, var(--warning) 12%, transparent); color: var(--warning); }
[role="alert"][data-variant="danger"] { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
[role="alert"][data-variant="success"] { border-color: color-mix(in srgb, var(--success) 30%, transparent); background: color-mix(in srgb, var(--success) 12%, transparent); color: var(--success); }
[role="alert"][data-variant] .alert-body { color: var(--foreground); }
[role="alert"][data-variant] .alert-body strong { color: inherit; }
[role="alert"] .alert-link { margin-left: auto; flex-shrink: 0; font-weight: 500; }
[role="alert"] .alert-actions { margin-top: var(--space-3); }

.empty-state { padding: var(--space-16) var(--space-6); border: 1px dashed var(--border); border-radius: var(--radius-xl); gap: var(--space-3); }
.empty-state > svg.icon { font-size: 2rem; color: var(--muted-foreground); }
.empty-state p { max-width: 36rem; font-size: var(--text-7); color: var(--muted-foreground); }
.empty-state .button, .empty-state button { margin-top: var(--space-1); }
td > .empty-state { border: 0; }

dialog { border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-large); max-width: 32rem; width: 100%; }
dialog::backdrop { background: rgb(0 0 0 / 0.5); }
dialog .dialog-head { background: transparent; padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--border); }
dialog .dialog-head .dialog-title { font-size: var(--text-7); font-weight: 600; }
dialog .dialog-body { padding: var(--space-4) var(--space-5); }
dialog .dialog-foot { border-top: 1px solid var(--border); padding: var(--space-3) var(--space-5); }
dialog.drawer { position: fixed; inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: none; width: 100%; max-width: 36rem; border-radius: 0; border-width: 0 0 0 1px; flex-direction: column; }
/* Only an open drawer is laid out: display on the closed one would undo the browser's own
   display: none and leave an invisible panel over the page, taking its clicks. */
dialog.drawer[open] { display: flex; }
dialog.drawer .dialog-head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) var(--space-5); }
dialog.drawer .dialog-body { flex: 1; overflow-y: auto; }

menu[popover], [popover].menu { padding: var(--space-1); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--popover); box-shadow: var(--shadow-medium); min-width: 12rem; }
menu[popover] .button, menu[popover] button { width: 100%; justify-content: flex-start; height: 2rem; padding: 0 var(--space-2); border-radius: var(--radius-small); font-weight: 400; }
menu[popover] hr { margin: var(--space-1) 0; }

/* ---------- 12. Send controls (fieldset.sending) on the portal surface ---------- */
fieldset.sending { margin: var(--space-2) 0 var(--space-6); }
fieldset.sending > legend { font-size: var(--text-6); font-weight: 600; }
fieldset.sending > .caption { margin: 2px 0 var(--space-3); font-size: var(--text-7); color: var(--muted-foreground); }
fieldset.sending details { border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--card); margin-bottom: var(--space-2); }
fieldset.sending details > summary { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); list-style: none; }
fieldset.sending details > summary::-webkit-details-marker { display: none; }
fieldset.sending details > summary::after { content: ""; width: 1rem; height: 1rem; margin-top: 2px; flex-shrink: 0; background: currentColor; color: var(--muted-foreground); -webkit-mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); mask: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); transition: transform var(--transition-fast); }
fieldset.sending details[open] > summary::after { transform: rotate(180deg); }
fieldset.sending details[open] > summary { border-bottom: 1px solid var(--border); }
fieldset.sending .summary-text .name { font-size: var(--text-7); font-weight: 500; }
fieldset.sending .summary-text .sentence { font-size: var(--text-8); color: var(--muted-foreground); }
fieldset.sending details > .group-body { margin: 0; padding: var(--space-4); animation: none; }
fieldset.sending details > .group-body > .caption { font-size: var(--text-8); color: var(--muted-foreground); }
fieldset.sending .group-body fieldset.group { margin: 0; }
fieldset.sending .group-body label[data-field] { margin-bottom: var(--space-3); }
.filter-builder .fgroup { background: var(--faint); border-radius: var(--radius-large); }
.inline-sentence input, .inline-sentence select { height: var(--control-h-sm); width: auto !important; }
.inline-sentence input[type="number"] { width: 6rem !important; }
.inline-sentence input[type="time"] { width: 8.75rem !important; }
.inline-sentence input[type="text"] { width: 10rem !important; }
label[data-field]:has(> input[type="checkbox"]), label[data-field]:has(> input[type="radio"]) { flex-direction: row; align-items: center; gap: var(--space-2); font-weight: 400; margin-bottom: var(--space-2); }
label[data-field]:has(> input[role="switch"]) { font-weight: 500; margin-bottom: var(--space-4); }
input[type="checkbox"][role="switch"] { appearance: none; position: relative; width: 2.25rem; height: 1.25rem; margin: 0; border: 0; border-radius: 9999px; background: var(--input); transition: background var(--transition-fast); }
input[type="checkbox"][role="switch"]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 1rem; height: 1rem; border-radius: 9999px; background: var(--background); box-shadow: var(--shadow-small); transform: none; transition: transform var(--transition-fast); }
input[type="checkbox"][role="switch"]:checked { background: var(--primary); }
input[type="checkbox"][role="switch"]:checked::before { transform: translateX(1rem); background: #fff; }
.choice-list > label[data-field] { flex-direction: row; align-items: center; gap: var(--space-2); font-weight: 400; }
.day-picker label { font-size: var(--text-7); }
dl.ramp-preview { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: var(--space-2); }
dl.ramp-preview > div { padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-medium); white-space: nowrap; }
dl.ramp-preview dt { font-size: var(--text-9); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }
dl.ramp-preview dd { font-weight: 500; }

/* ---------- 13. Dashboard charts and system panel ---------- */
.chart-box { position: relative; height: 16rem; }
.chart-box svg { width: 100%; height: 100%; }
.chart-legend { display: flex; gap: var(--space-4); font-size: var(--text-8); color: var(--muted-foreground); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 9999px; margin-right: 6px; vertical-align: 1px; }
.kv { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: var(--space-4); font-size: var(--text-7); }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv .bar { flex-direction: column; gap: 6px; }
.kv .bar dt { display: flex; justify-content: space-between; }

/* Utilities on this surface. */
.text-light { color: var(--muted-foreground); }
.text-8 { font-size: var(--text-8); }
.text-7 { font-size: var(--text-7); }
.mono { font-family: var(--font-mono); }
.hstack { display: flex; align-items: center; gap: var(--space-3); }
.vstack { display: flex; flex-direction: column; gap: var(--space-3); }
.gap-6 { gap: var(--space-6); }
.gap-4 { gap: var(--space-4); }
.gap-2 { gap: var(--space-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.grid-8-4 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--space-6); }

/* ---------- 14. Campaigns list and the campaign builder ---------- */
/* Brand tile: the instance logo on a white tile (dark marks survive dark mode), or the envelope mark. */
.avatar.brand img, .avatar.brand .brand-mark { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-medium); }
.avatar.brand img { display: block; object-fit: contain; padding: 4px; background: #fff; border: 1px solid var(--border); }
.avatar.brand .brand-mark { display: inline-flex; align-items: center; justify-content: center; background: var(--foreground); color: var(--body); }
.avatar.brand .brand-mark .icon { margin: 0; font-size: 1.125rem; }
.page-header .avatar.brand img, .page-header .avatar.brand .brand-mark { width: 3rem; height: 3rem; border-radius: var(--radius-large); }

/* Campaigns table: primary cell carries the status; stats are their own numeric columns. */
.campaign-table td { padding-block: var(--space-4); vertical-align: top; }
.campaign-table td:first-child { padding-top: calc(var(--space-4) + 0.75rem); }
.campaign-table td.actions { padding-top: calc(var(--space-4) + 0.25rem); }
.campaign-table .name-stack { align-items: flex-start; }
.campaign-table .name-stack > .stack { gap: 3px; }
.campaign-table .title-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.campaign-table .title-line .name { font-size: var(--text-6); font-weight: 500; line-height: 1.35; max-width: 40ch; white-space: normal; overflow: visible; }
.campaign-table .name-stack .meta.subject { font-size: var(--text-7); max-width: 56ch; }
.campaign-table .meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-3); margin-top: 2px; font-size: var(--text-8); color: var(--muted-foreground); }
.campaign-table .meta-line .schedule { display: inline-flex; align-items: center; gap: 4px; }
.campaign-table .meta-line .schedule .icon { margin: 0; font-size: 0.8125rem; }
.campaign-table .meta-line .tag { color: var(--info); }
.campaign-table .meta-line .tag:hover { text-decoration: underline; }
.campaign-table td.lists { padding-top: calc(var(--space-4) + 0.5rem); }
.campaign-table ul.list-names { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.campaign-table ul.list-names li a { display: block; max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--foreground); }
.campaign-table ul.list-names li a:hover { color: var(--primary); }
.campaign-table td.stat { padding-top: calc(var(--space-4) + 0.25rem); }
.campaign-table td.stat .value { display: block; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--foreground); }
.campaign-table td.stat .value.zero { color: var(--faint-foreground); font-weight: 400; }
.campaign-table td.stat a.value:hover { color: var(--primary); }
.campaign-table td.stat .sub { display: block; margin-top: 2px; font-size: var(--text-8); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.campaign-table td.stat progress { display: block; width: 100%; max-width: 7rem; height: 0.375rem; margin: 6px 0 0 auto; }
/* Each stat wears its own colour once it has a value: opens = green, clicks = blue, bounces = red. */
.campaign-table td.stat.views .value:not(.zero) { color: var(--success); }
.campaign-table td.stat.clicks .value:not(.zero) { color: var(--info); }
.campaign-table td.stat.bounces .value:not(.zero) { color: var(--danger); }
.campaign-table td.stat.views .sub { color: color-mix(in srgb, var(--success) 75%, var(--muted-foreground)); font-weight: 500; }
.campaign-table td.stat.clicks .sub { color: color-mix(in srgb, var(--info) 75%, var(--muted-foreground)); font-weight: 500; }
.campaign-table td.stat.bounces .sub { color: color-mix(in srgb, var(--danger) 75%, var(--muted-foreground)); font-weight: 500; }
.campaign-table tr.status-finished td.stat progress::-webkit-progress-value { background: var(--success); }
.campaign-table tr.status-cancelled td.stat progress::-webkit-progress-value { background: var(--muted-foreground); }
.campaign-table tr.status-paused td.stat progress::-webkit-progress-value { background: var(--warning); }
.campaign-table td.stat .rate-line { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.campaign-table td.stat .rate-line .icon { margin: 0; }
.campaign-table th.num:not(:last-child) { padding-inline: var(--space-3); }
.campaign-table td.stat { padding-inline: var(--space-3); }

/* ---------- 15. Full-screen builder shell ----------
   The campaign page takes the whole viewport (Brevo / Mailchimp editors): no top bar, rail or panel;
   its own 64px bar (exit, logo, name + status, save state, actions), the stepper as a band under it,
   step cards centred at reading width, the Content step at full width for the split editor. */
#app:has(section.campaign.builder) {
    > nav[data-topnav], .rail-slot, aside[data-sidebar], .panel-chips { display: none !important; }
    main > .container { padding: 0; }
}
.builder .page-header {
    position: sticky; top: 0; z-index: 25;
    margin: 0 !important;
    padding: 0 var(--space-6);
    min-height: 4rem;
    display: flex; align-items: center;
    background: var(--rail);
    border-bottom: 1px solid var(--border);
}
.builder .page-header .title-row { flex: 1; align-items: center; gap: var(--space-3) var(--space-4); }
.builder .page-header .back { display: inline-flex; align-items: center; gap: 4px; height: 2.25rem; padding: 0 var(--space-3) 0 var(--space-2); border-radius: var(--radius-medium); color: var(--muted-foreground); font-size: var(--text-7); font-weight: 500; }
.builder .page-header .back:hover { background: var(--accent); color: var(--foreground); }
.builder .page-header .back .icon { font-size: 1.125rem; }
.builder .page-header .title-block::before { content: ""; width: 1px; height: 1.75rem; background: var(--border); margin: 0 var(--space-1); }
.builder .page-header .avatar.brand img, .builder .page-header .avatar.brand .brand-mark { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-medium); }
.builder .page-header h1, .builder .page-header .page-title { font-size: 1rem; line-height: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.builder .page-header .caption { margin: 0; font-size: var(--text-8); }
.builder .page-header .actions { gap: var(--space-2); }
.builder .page-header .actions button { height: var(--control-h-sm); font-size: var(--text-7); }
.builder .stepper { position: sticky; top: 4rem; z-index: 24; margin: 0; padding: 0 var(--space-6); background: var(--background); border-bottom: 1px solid var(--border); }
.builder .stepper ol { max-width: 72rem; margin: 0 auto; gap: 0; }
.builder .stepper button { padding: var(--space-3) var(--space-4); border-top: 0; border-bottom: 2px solid transparent; border-radius: 0; margin-bottom: -1px; }
.builder .stepper li.is-current button { border-bottom-color: var(--primary); }
.builder .stepper li.is-done button { border-bottom-color: transparent; }
.builder .stat-strip, .builder > [role="alert"] { margin: var(--space-6) auto 0; max-width: 72rem; width: calc(100% - 2 * var(--space-6)); }
.builder .step { width: 100%; max-width: 72rem; margin: 0 auto; padding: var(--space-8) var(--space-6) var(--space-12); }
.builder .step[data-cy="step-content"] { max-width: none; padding-top: var(--space-6); }
.builder .step[data-cy="step-content"] .editor-split { min-height: calc(100dvh - 20rem); }
.builder .step[data-cy="step-content"] .editor-split > .editor-body, .builder .step[data-cy="step-content"] .code-editor, .builder .step[data-cy="step-content"] .plain-editor { min-height: calc(100dvh - 20rem); }
.builder .step[data-cy="step-content"] .preview-pane iframe { min-height: calc(100dvh - 25rem); }
.builder .step-foot { padding-top: var(--space-2); }

/* Campaigns list: status tabs + sort in a strip above the table, and the up-next strip. */
.campaign-filters { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); gap: var(--space-3); }
.campaign-filters .status-tabs { flex-wrap: wrap; }
.campaign-filters .status-tabs > a { gap: 6px; }
.campaign-filters .status-tabs > a .count { font-variant-numeric: tabular-nums; color: var(--faint-foreground); font-weight: 400; }
.campaign-filters .status-tabs > a[aria-current] .count { color: var(--muted-foreground); }
.campaign-filters .status-tabs > a.is-empty { color: var(--faint-foreground); }
.campaign-filters .status-tabs .dot { width: 6px; height: 6px; border-radius: 9999px; background: var(--faint-foreground); }
.campaign-filters .status-tabs .dot.status-draft { background: var(--muted-foreground); }
.campaign-filters .status-tabs .dot.status-scheduled { background: var(--info); }
.campaign-filters .status-tabs .dot.status-running { background: var(--success); }
.campaign-filters .status-tabs .dot.status-paused { background: var(--warning); }
.campaign-filters .status-tabs .dot.status-finished { background: var(--success); opacity: 0.6; }
.campaign-filters .status-tabs .dot.status-cancelled { background: var(--danger); }
.campaign-filters .sort-form { margin-left: auto; }
.campaign-filters .sort-form label { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-8); font-weight: 500; color: var(--muted-foreground); }
.campaign-filters .sort-form select { height: var(--control-h-sm); width: auto; font-size: var(--text-7); color: var(--foreground); }
.card.stat-strip.up-next { margin-bottom: var(--space-4); }
.card.stat-strip.up-next > .cell { display: block; min-width: 0; }
.card.stat-strip.up-next .stat-value { display: block; margin-top: 6px; font-size: var(--text-6); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card.stat-strip.up-next .stat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--space-2); margin-top: 4px; }
.card.stat-strip.up-next .stat-meta strong { color: var(--foreground); font-weight: 500; }
.card.stat-strip.up-next progress { max-width: 12rem; height: 0.375rem; }
.card.stat-strip.up-next > .cell.live { background: color-mix(in srgb, var(--success) 5%, transparent); }
@media (max-width: 769px) {
    .campaign-filters { padding: var(--space-3) 0; border: 0; }
    .campaign-filters .status-tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
    .campaign-filters .sort-form { margin-left: 0; width: 100%; }
    .campaign-filters .sort-form select { flex: 1; }
    .card.stat-strip.up-next { grid-template-columns: minmax(0, 1fr); }
}

/* Builder header: title line with status, subject caption, save state. */
.builder .stat-strip { margin-bottom: var(--space-6); }
.builder .page-header .title-block { align-items: center; }
.builder .page-header .title-text { min-width: 0; }
.builder .page-header .title-line h1 { white-space: normal; }
.builder .page-header .caption .sep { margin: 0 2px; }
.save-state { display: inline-flex; align-items: center; gap: 6px; margin-right: var(--space-2); font-size: var(--text-8); color: var(--muted-foreground); white-space: nowrap; }
.save-state::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: var(--success); }
.save-state.dirty::before { background: var(--warning); }

/* Stepper: five segments, each a button with a numbered dot; done = green check, current = accent. */
.stepper { margin: 0 0 var(--space-6); }
.stepper ol { list-style: none; margin: 0; padding: 0; display: flex; align-items: stretch; gap: var(--space-2); }
.stepper li { flex: 1 1 0; min-width: 0; display: flex; }
.stepper button { width: 100%; height: auto; justify-content: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-2); border: 0; border-top: 2px solid var(--border); border-radius: 0 0 var(--radius-medium) var(--radius-medium); background: transparent; color: var(--muted-foreground); font-weight: 500; box-shadow: none; text-align: left; transition: background var(--transition-fast), border-color var(--transition-fast); }
.stepper button:hover { background: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--foreground); }
.stepper .dot { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.5rem; height: 1.5rem; border: 1px solid var(--border); border-radius: 9999px; font-size: var(--text-8); font-weight: 600; color: var(--muted-foreground); background: var(--card); }
.stepper .dot .icon { display: none; margin: 0; font-size: 0.8125rem; }
.stepper .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-7); }
.stepper li.is-current button { border-top-color: var(--primary); color: var(--foreground); }
.stepper li.is-current .dot { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.stepper li.is-done button { border-top-color: var(--success); color: var(--foreground); }
.stepper li.is-done .dot { background: var(--success); border-color: var(--success); color: #fff; }
.stepper li.is-done .dot .n { display: none; }
.stepper li.is-done .dot .icon { display: inline-block; }
.stepper li.is-disabled button { opacity: 0.45; pointer-events: none; }

/* Step cards. */
.builder .step { display: flex; flex-direction: column; gap: var(--space-4); }
.builder .step > .card:not(.editor) { padding: var(--space-6); }
.step-card > header { margin-bottom: var(--space-5); }
.step-card > header h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.step-card > header p { margin: 2px 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.step-card > header p.text-warning { color: var(--warning); }
.step-card .fields-grid { gap: 0 var(--space-6); }
.step-card .fields-grid > label[data-field], .step-card .fields-grid > [data-field] { min-width: 0; }
.step-card fieldset.sending { margin-bottom: 0; }
.step-card fieldset.sending details:last-child { margin-bottom: 0; }
.step-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-1); }
.step-foot > button.ghost { color: var(--muted-foreground); }
.step-foot > button.ghost:hover { color: var(--foreground); }

/* Advanced group on Setup: collapsed by default, a hairline above. */
details.advanced { margin: var(--space-2) 0 0; padding: var(--space-4) 0 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; background: transparent; box-shadow: none; }
details.advanced > summary { display: flex; align-items: center; justify-content: flex-start; gap: var(--space-2); margin: 0; padding: 0; border: 0; background: transparent; list-style: none; font-size: var(--text-7); font-weight: 500; color: var(--foreground); cursor: pointer; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::after { display: none; }
details.advanced[open] > summary { border: 0; }
details.advanced > summary > .icon { margin: 0; color: var(--muted-foreground); transition: transform var(--transition-fast); }
details.advanced[open] > summary > .icon { transform: rotate(90deg); }
details.advanced > summary .text-light { font-weight: 400; }
details.advanced > .group-body { padding-top: var(--space-4); }
details.advanced > .group-body > :last-child { margin-bottom: 0; }

/* Recipients reach strip. */
.reach { display: flex; align-items: center; min-height: 3.25rem; margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--faint); font-size: var(--text-7); }
.reach strong { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }

/* Content step: toolbar, editor + live preview split. */
.step-card.editor { padding: 0; overflow: hidden; }
.content-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--card); }
.content-toolbar .left, .content-toolbar .right { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); min-width: 0; }
.content-toolbar label { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-8); font-weight: 500; color: var(--muted-foreground); }
.content-toolbar select { height: var(--control-h-sm); width: auto; max-width: 14rem; font-size: var(--text-7); }
.content-toolbar fieldset.group { margin: 0; }
.content-toolbar fieldset.group > select { border-radius: var(--radius-medium) 0 0 var(--radius-medium); }
.content-toolbar fieldset.group > button { height: var(--control-h-sm); }
.content-toolbar .ref { display: inline-flex; align-items: center; gap: 4px; }
.content-toolbar .ref .icon { margin: 0; }
.content-toolbar .segmented > button { height: 1.75rem; }
.content-toolbar .segmented > button .icon { font-size: 0.875rem; }
.editor-split { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 65vh; }
.editor-split[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.editor-split[data-mode="preview"] > .editor-body { display: none; }
.editor-split > .editor-body { position: relative; min-width: 0; min-height: 65vh; }
.editor-split[data-mode="split"] > .preview-pane { border-left: 1px solid var(--border); }
.editor-split .plain-editor { min-height: 65vh; border: 0; border-radius: 0; box-shadow: none; padding: var(--space-4); font-family: var(--font-mono); font-size: var(--text-7); resize: vertical; }
.editor-split richtext-editor { display: block; min-width: 0; }
.editor-split .editor-body.is-loading > * { visibility: hidden; }
.editor-split .editor-body.is-loading::before { content: ""; position: absolute; inset: 0; margin: auto; width: 2rem; height: 2rem; border: 3px solid var(--muted); border-top-color: var(--primary); border-radius: 9999px; animation: spin 1s linear infinite; z-index: 2; }
.preview-pane { display: flex; flex-direction: column; min-width: 0; background: var(--faint); }
.preview-pane .inbox-head { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); background: var(--card); }
.preview-pane .inbox-head .avatar.brand img, .preview-pane .inbox-head .avatar.brand .brand-mark { width: 2rem; height: 2rem; }
.preview-pane .inbox-head .lines { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.preview-pane .inbox-head .subject { font-size: var(--text-7); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-pane .inbox-head .from { font-size: var(--text-8); color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-pane .inbox-head button.icon { width: 2rem; }
.preview-pane .frame { flex: 1; display: flex; justify-content: center; align-items: stretch; padding: var(--space-4); overflow: auto; }
.preview-pane iframe { display: block; width: 100%; min-height: 60vh; border: 1px solid var(--border); border-radius: var(--radius-medium); background: #fff; transition: width var(--transition); }
.preview-pane[data-device="mobile"] iframe { width: 375px; max-width: 100%; }
.step-card.editor .after-editor { display: flex; flex-direction: column; gap: var(--space-5); padding: var(--space-4) var(--space-6) var(--space-6); border-top: 1px solid var(--border); }
.step-card.editor .after-editor fieldset.alt-text { margin: 0; }
.step-card.editor .after-editor .alt-body textarea { margin-top: var(--space-3); min-height: 8rem; width: 100%; }
.attachments-group .section-head { align-items: center; }
.attachments-group .section-head h3 { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-6); font-weight: 600; }
.attachments-group .gallery { margin: 0; padding: 0; }

/* Review step: checklist + send card. */
.review-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--space-4); align-items: start; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.checklist li:first-child { padding-top: 0; }
.checklist li:last-child { border-bottom: 0; padding-bottom: 0; }
.checklist .mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.75rem; height: 1.75rem; margin-top: 1px; border-radius: 9999px; background: var(--tone-amber-bg); color: var(--warning); }
.checklist .mark .icon { margin: 0; font-size: 0.9375rem; }
.checklist .mark > span { display: inline-flex; }
.checklist li.done .mark { background: var(--tone-green-bg); color: var(--success); }
.checklist li.optional .mark { background: var(--muted); color: var(--muted-foreground); }
.checklist .body { flex: 1; min-width: 0; }
.checklist .body strong { display: block; font-size: var(--text-7); font-weight: 600; }
.checklist .body .sentence { display: block; margin-top: 2px; font-size: var(--text-7); color: var(--muted-foreground); overflow-wrap: anywhere; }
.checklist li:not(.done):not(.optional) .body .sentence { color: var(--warning); }

/* Review step: what the brand's restriction does to this audience. One fixed line, so the
   skeleton and the sentence that replaces it take the same room. */
[role="alert"] .policy-line { margin-top: var(--space-2); min-height: 1.25rem; line-height: 1.25rem; }
[role="alert"] .policy-line .skeleton { display: block; width: 22rem; max-width: 100%; height: 0.875rem; margin: 3px 0; }
.send-card .held-back { margin: var(--space-4) 0 0; }
.checklist > li > button, .checklist > li > .hstack { flex-shrink: 0; }
.send-card > div > header { margin-bottom: var(--space-4); }
.send-card > div > header h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.send-card > div > header p { margin: 2px 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.send-card > div > header p.text-warning { color: var(--warning); }
.send-card .send-modes { margin-bottom: 0; }
.send-card .send-modes .choice-body { margin-bottom: var(--space-2); }
.send-card .send-modes .choice-body label[data-field] { margin-bottom: 0; }
.send-card .send-modes input[type="datetime-local"] { width: auto; }
.send-card .send-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); margin-top: var(--space-4); }
.send-card .outcome { margin-bottom: var(--space-2); }
.send-card .test-send { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.send-card .test-send h3 { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-1); font-size: var(--text-7); font-weight: 600; }
.send-card .test-row { display: flex; gap: var(--space-2); align-items: flex-start; }
.send-card .test-row ot-taginput { flex: 1; min-width: 0; }
.send-card footer.ids { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--border); flex-wrap: wrap; }
.send-card footer.ids button { font-family: var(--font-mono); font-size: var(--text-9); font-weight: 400; box-shadow: none; }
.send-card footer.ids button strong { font-family: var(--font-sans); font-weight: 600; margin-right: 4px; }

@media (max-width: 1100px) {
    .review-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
    .editor-split[data-mode="split"] { grid-template-columns: minmax(0, 1fr); }
    .editor-split[data-mode="split"] > .preview-pane { border-left: 0; border-top: 1px solid var(--border); }
    .preview-pane iframe { min-height: 50vh; }
}

@media (max-width: 769px) {
    .stepper ol { gap: var(--space-1); }
    .stepper li { flex: 0 0 auto; }
    .stepper li.is-current { flex: 1 1 auto; }
    .stepper button { padding: var(--space-2) var(--space-2); gap: var(--space-2); }
    .stepper .label { display: none; }
    .stepper li.is-current .label { display: inline; }
    .builder .step > .card:not(.editor) { padding: var(--space-4); }
    .step-card .fields-grid { display: block; }
    .step-card.editor .after-editor { padding: var(--space-4); }
    .content-toolbar .left, .content-toolbar .right { width: 100%; }
    .content-toolbar select { max-width: none; flex: 1; }
    .step-foot { flex-wrap: wrap; }
    .step-foot > button[type="submit"] { margin-left: auto; }
    .save-state { display: none !important; }
    .builder .page-header { padding: var(--space-3) var(--space-4); position: static; }
    .builder .page-header .back .back-label { display: none; }
    .builder .page-header .title-block::before { display: none; }
    .builder .page-header .actions { width: 100%; flex-wrap: wrap; }
    .builder .page-header .actions > button { flex: 1 1 auto; }
    .builder .stepper { position: static; padding: 0 var(--space-2); }
    .builder .step { padding: var(--space-4) var(--space-4) var(--space-8); }
    .builder .stat-strip, .builder > [role="alert"] { width: calc(100% - 2 * var(--space-4)); margin-top: var(--space-4); }
    .campaign-table td.stat { text-align: end; }
    .campaign-table td.stat .value { display: inline; font-size: var(--text-6); }
    .campaign-table td.stat .sub { display: inline; margin-left: var(--space-1); }
    .campaign-table td.stat progress { display: none; }
    .campaign-table td.stat .rate-line { display: inline-flex; margin-left: var(--space-2); }
    .campaign-table td.name .title-line .name { max-width: none; }
    .campaign-table td.lists { padding-top: 0; }
}

/* ---------- Responsive: rail hides, the drawer lists every area, the panel's pages become chips ---------- */
@media (max-width: 769px) {
    #app[data-sidebar-layout] { padding: 0; height: 100dvh; }
    nav[data-topnav] { position: static; height: var(--topbar-h); padding: 0 var(--space-4); box-shadow: none; background: var(--rail); }
    nav[data-topnav] button[data-sidebar-toggle] { display: inline-flex; }
    nav[data-topnav] .topbar-search, nav[data-topnav] .topbar-icon.help { display: none; }
    .rail-slot { display: none; }
    aside[data-sidebar] {
        display: flex !important;
        position: fixed;
        inset: var(--topbar-h) auto 0 0;
        z-index: 20;
        width: 18rem;
        max-width: calc(100vw - 3rem);
        margin: 0;
        border-right: 1px solid var(--border);
        box-shadow: var(--shadow-large);
        background: var(--panel);
        transform: translateX(-100%);
        visibility: hidden;
        transition: transform var(--transition), visibility var(--transition);
    }
    #app[data-sidebar-open] aside[data-sidebar] { transform: none; visibility: visible; }
    aside[data-sidebar] .panel-area { display: block; }
    aside[data-sidebar] .panel-title { height: auto; padding: var(--space-5) var(--space-4) var(--space-1); font-size: var(--text-8); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }
    aside[data-sidebar] .panel-area:first-child .panel-title { padding-top: var(--space-3); }
    aside[data-sidebar] .panel-area.single .panel-title { display: none; }
    aside[data-sidebar] .panel-area.single nav { padding-top: var(--space-3); }
    aside[data-sidebar] .panel-area.single a .icon { display: inline-block; margin: 0 var(--space-2) 0 0; font-size: 1rem; }
    aside[data-sidebar] nav { padding-bottom: var(--space-1); }
    .panel-chips { display: flex; gap: var(--space-1); overflow-x: auto; margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) 0; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); background: var(--panel); flex-shrink: 0; scrollbar-width: none; }
    .panel-chips a { white-space: nowrap; padding: 6px var(--space-3); border-radius: var(--radius-medium); color: var(--muted-foreground); font-size: var(--text-7); flex-shrink: 0; }
    .panel-chips a[aria-current] { background: var(--accent); color: var(--foreground); font-weight: 500; }
    main > .container { padding: var(--space-4); }
    .page-header { padding: var(--space-4); }
    main > .container > .page-header, main > .container > * > .page-header { margin: 0 calc(-1 * var(--space-4)) var(--space-4); }
    main > .container > .page-header:first-child, main > .container > :first-child > .page-header:first-child { margin-top: calc(-1 * var(--space-4)); }
    .page-header h1, .page-header .page-title { font-size: 1.5rem; line-height: 2rem; white-space: normal; }
    .page-header .actions { width: 100%; }
    .page-header .actions > * { flex: 1; }
    .page-header.row > [class*="col-"] { flex: 1 1 100%; margin-left: 0; }
    .page-header.row .hstack { flex-wrap: wrap; }
    .page-header.row .hstack.justify-end > * { flex: 1 1 auto; }
    .page-header.row .hstack.justify-end > .search-form { flex-grow: 999; }
    .page-header.row .search-form input:not([type="checkbox"]) { width: 100%; }
    .page-header.row .search-form fieldset.group { width: 100%; }
    .page-body { gap: var(--space-4); }
    .filter-bar input[type="search"], .filter-bar input[name="query"], .filter-bar input[name="search"] { width: 100%; }
    .filter-bar .search-form { display: block; width: 100%; }
    .grid-2, .grid-8-4 { grid-template-columns: minmax(0, 1fr); }
    .with-sub-nav { flex-direction: column; }
    .sub-nav { position: static; width: 100%; flex-direction: row; overflow-x: auto; }
    [role="tablist"] { overflow-x: auto; gap: var(--space-4); }
    /* Card-per-row tables: keep the mobile grid above, restyle the card. */
    .page-content.card.has-table { background: none; border: 0; box-shadow: none; overflow: visible; }
    .page-content .table-wrapper tbody tr { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-large); box-shadow: var(--shadow-small); padding: var(--space-3) var(--space-4); }
    .page-content table td { height: auto; padding: 0; }
    .page-content table td:first-child:not([colspan]), .page-content table td:first-child:has(> input[type="checkbox"]) + td, .page-content table td.actions { padding-bottom: var(--space-3); }
    .page-content table thead:has(th input[type="checkbox"], th a[data-sort-field]) { padding: 0 0 var(--space-3); }
    .page-content table th a[data-sort-field] { height: 1.75rem; border-radius: 9999px; padding: 0 var(--space-3); font-size: var(--text-9); }
    .page-content table thead th { position: static; background: transparent; border: 0; }
    .name-stack .name, .name-stack .meta { max-width: none; white-space: normal; }
    .table-foot { border: 0; padding: var(--space-3) 0; }
    .table-scroll { overflow: visible; }
    .table-scroll > table { min-width: 0; }
    .card.stat-strip > div { padding: var(--space-3) var(--space-4); }
    .card.stat-strip .stat-value { font-size: 1.5rem; }
}

/* Campaigns list: Batched toggle in the filter bar, the batched badge in row meta, the Active cell in the up-next strip. */
.campaign-filters .toggle-chip { display: inline-flex; align-items: center; gap: 6px; height: 1.75rem; padding: 0 var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-medium); background: var(--card); color: var(--muted-foreground); font-size: var(--text-8); font-weight: 500; text-decoration: none; white-space: nowrap; }
.campaign-filters .toggle-chip .icon { margin: 0; font-size: 0.8125rem; }
.campaign-filters .toggle-chip:hover { color: var(--foreground); }
.campaign-filters .toggle-chip[aria-pressed="true"] { background: var(--tone-blue-bg); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }
.campaign-table .meta-line .schedule.batched { color: var(--info); }
.campaign-table .meta-line .schedule.lists { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.card.stat-strip.up-next > .cell.active-link { flex: 0 0 auto; min-width: 12rem; background: color-mix(in srgb, var(--accent) 40%, transparent); }
.card.stat-strip.up-next > .cell.active-link small .icon { color: var(--info); }
.card.stat-strip.up-next > .cell.active-link:hover { background: var(--accent); }

/* Active campaigns: sending, held and scheduled with today's progress. */
.active-campaigns .page-header .caption.active-counts { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--text-8); }
.active-campaigns .page-header .caption.active-counts > span { display: inline-flex; align-items: center; gap: 6px; }
.active-campaigns .page-header .caption.active-counts > span.is-empty { color: var(--faint-foreground); }
.active-campaigns .page-header .caption.active-counts .dot { width: 6px; height: 6px; border-radius: 9999px; background: var(--faint-foreground); }
.active-campaigns .page-header .caption.active-counts .dot.status-running { background: var(--success); }
.active-campaigns .page-header .caption.active-counts .dot.status-paused { background: var(--warning); }
.active-campaigns .page-header .caption.active-counts .dot.status-scheduled { background: var(--info); }
.active-campaigns .page-header .caption.active-counts > span.is-empty .dot { background: var(--faint-foreground); }
.active-table td.next { padding-top: calc(var(--space-4) + 0.25rem); font-size: var(--text-8); color: var(--muted-foreground); line-height: 1.4; }
.active-table td.next .badge { margin: 0 0 4px; }
.active-table td.next .line { display: block; margin-top: 2px; max-width: 34ch; }
.active-table td.next .line:empty { display: none; }
.active-table td.next strong { color: var(--foreground); font-weight: 500; }
.active-table td.stat.today progress::-webkit-progress-value { background: var(--info); }
.active-table tr.status-running td.stat.today progress::-webkit-progress-value { background: var(--success); }
.active-table td.stat.rate .value { color: var(--success); }
.active-table td.stat.rate .value.zero { color: var(--faint-foreground); }
.active-table td.stat.rate .rate-line { justify-content: flex-end; }
@media (max-width: 769px) {
    .active-campaigns .page-header .caption.active-counts { margin-top: var(--space-2); }
    .active-table td.next .line { max-width: none; }
    .card.stat-strip.up-next > .cell.active-link { min-width: 0; }
}

/* Signed-out screens (login, first-time setup, forgot and reset password, two-factor):
   the brand above one centered card. Markup in static/public/templates/auth.html. */
body.auth { min-height: 100dvh; margin: 0; display: flex; flex-direction: column; background: var(--body); color: var(--foreground); }
.auth-shell { flex: 1; width: 100%; max-width: 25rem; margin: 0 auto; padding: var(--space-12) var(--space-4); display: flex; flex-direction: column; justify-content: center; gap: var(--space-6); }
.auth-theme { position: fixed; top: var(--space-4); right: var(--space-4); color: var(--muted-foreground); }
.auth-theme .when-dark, :root[data-dark] .auth-theme .when-light { display: none; }
:root[data-dark] .auth-theme .when-dark { display: inline-flex; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.avatar.brand.auth-brand img { width: auto; min-width: 2.5rem; max-width: 12rem; padding: 6px 10px; }
.auth-brand strong { font-size: var(--text-4); font-weight: 600; letter-spacing: -0.01em; }
.auth-card { padding: var(--space-8); }
.auth-card > header { margin-bottom: var(--space-6); }
.auth-card > header h1 { margin: 0; font-size: var(--text-3); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.auth-card > header p { margin: var(--space-1) 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.auth-card form { margin: 0; }
.auth-card [data-field] { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-4); }
.auth-card [data-field] > label, .auth-card .label-row label { margin: 0; }
.auth-card [data-field] input { width: 100%; }
.auth-card .label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); font-size: var(--text-7); font-weight: 500; }
.auth-card .label-row a { font-size: var(--text-8); font-weight: 400; }
.auth-card form > button { width: 100%; margin-top: var(--space-2); }
.auth-card form > button img { width: 1rem; height: 1rem; }
.auth-card [role="alert"] { margin-bottom: var(--space-4); }
.auth-card [data-field] input.auth-code:not([type="checkbox"]):not([type="radio"]) { height: 3rem; text-align: center; font-size: var(--text-3); font-variant-numeric: tabular-nums; letter-spacing: 0.4em; text-indent: 0.4em; }
.auth-card input.auth-code::placeholder { color: var(--faint-foreground); }
.auth-or { margin: var(--space-6) 0; border: 0; border-top: 1px solid var(--border); }
.auth-back { margin: var(--space-6) 0 0; text-align: center; font-size: var(--text-7); }
.auth-back a { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-foreground); }
.auth-back a:hover { color: var(--foreground); }
@media (max-width: 480px) {
    .auth-shell { justify-content: flex-start; padding-top: var(--space-16); }
    .auth-card { padding: var(--space-6); }
}

/* ---------- Brands: list, brand page, and the brand block in the campaign builder ---------- */
.brand-table td:first-child { padding-top: var(--space-4); }
.brand-table td.health { padding-top: calc(var(--space-4) + 0.125rem); }
.brand-table td.health .reason { display: block; margin-top: 6px; min-width: 19rem; max-width: 44ch; font-size: var(--text-8); line-height: 1.4; color: var(--muted-foreground); }
.brand-table ul.list-names li { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-7); }
.brand-table tr.status-archived .name-stack { opacity: 0.6; }
.health-badge .icon { margin: 0; }
.campaign-table .meta-line .brand a { color: var(--foreground); }
.campaign-table .meta-line .brand a:hover { color: var(--primary); }
.campaign-table .meta-line .brand .badge { margin-left: 2px; }

.brand-page .page-header .badge { margin-left: var(--space-2); }
.brand-page .settings-items { display: flex; flex-direction: column; gap: var(--space-4); max-width: 56rem; }
.brand-page [data-cy="panel-health"] .settings-items, .brand-page [data-cy="panel-suppressions"] .settings-items { max-width: none; }
.brand-page .settings-items > fieldset.card { margin: 0; }
.brand-page .settings-sidebar [role="tab"] .count { margin-left: auto; font-size: var(--text-8); color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.brand-page .brand-health-card { padding: var(--space-4) var(--space-5); }
.brand-page .brand-health-card .section-head { margin: 0; align-items: center; }
.brand-page .brand-health-card .reason { font-size: var(--text-6); font-weight: 500; }
.brand-page .brand-health-card p { margin-top: var(--space-2); }
.brand-page .stat-strip meter { display: block; width: 100%; margin-top: var(--space-3); }
.brand-page .stat-strip .stat-value { justify-content: flex-start; }
.brand-page .identity-rows .frow > fieldset.group > input { flex: 1 1 12rem; }
/* The global input rule outranks fieldset.group's joined corners; restate them at its weight. */
.brand-page .identity-rows .frow > fieldset.group > input:first-child { border-radius: var(--radius-medium) 0 0 var(--radius-medium); }
.brand-page .identity-rows .frow > fieldset.group > input:last-child { border-radius: 0 var(--radius-medium) var(--radius-medium) 0; }
.brand-page .choice-list > label[data-field] { align-items: flex-start; }
.brand-page .choice-list > label[data-field] > input { margin-top: 3px; }
.brand-page .page-content.has-table { margin: 0; }
.brand-page .pagination button { min-width: 1.75rem; height: 1.75rem; padding: 0 var(--space-1); }

/* Incidents tab: one card per incident, its timeline a plain list (time, sentence, who). */
.brand-page [data-cy="panel-incidents"] .settings-items { max-width: 64rem; }
/* The report action comes and goes; the row keeps its height either way. */
.brand-page .incidents-head > p { display: flex; align-items: center; min-height: 2rem; margin: 0; }
.brand-page .incident-card { margin: 0; }
.brand-page .past-head { margin: var(--space-2) 0 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 11.5rem minmax(0, 1fr); gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); font-size: var(--text-7); }
.timeline li:first-child { padding-top: 0; }
.timeline li:last-child { border-bottom: 0; padding-bottom: 0; }
.timeline time { color: var(--muted-foreground); font-size: var(--text-8); line-height: 1.25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.timeline .who { color: var(--muted-foreground); white-space: nowrap; }
.timeline .who::before { content: "\00b7"; margin: 0 var(--space-1) 0 2px; }
.incident-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border); }
.brand-page .open-rates { margin-top: var(--space-3); }
.brand-page .open-rates .inline-sentence:last-of-type { margin-bottom: 0; }
/* The legend floats; its next sibling clears it. When that sibling is the hidden rule line, the timeline has to. */
.incident-card .timeline { clear: both; }
.incident-card .incident-rule { margin: 0 0 var(--space-4); }
.incident-card[data-quiet="true"] legend { color: var(--muted-foreground); }
/* Warmth (Health tab): the sentence, then last week's accepted mail by provider. */
.brand-page .warmth .card { margin: 0; }
.brand-page .warmth .warmth-strip { margin-top: var(--space-4); }
.brand-page .warmth-card .section-head { margin: 0; align-items: center; }
.brand-page .warmth-card .section-head + p { margin-top: var(--space-2); }
.brand-page .warmth-card[data-level="amber"] strong { color: var(--warning); }
.brand-page .warmth-card[data-level="red"] strong { color: var(--danger); }
.brand-page .stat-strip progress { display: block; width: 100%; margin-top: var(--space-3); }
/* Heartbeat tab: a written-out day and "Not queued" never wrap; the campaign's name is what gives. */
.brand-page [data-cy="heartbeat-history"] td.day, .brand-page [data-cy="heartbeat-history"] td.who { white-space: nowrap; }
/* Daily check: the midday check's line under the day's sentence, and the warmth column. */
.daily .gate-line { margin: calc(-1 * var(--space-4)) 0 0; color: var(--muted-foreground); }
.daily .gate-line[data-tone="amber"] { color: var(--warning); }
/* All brands: warmth is a second line under the health pill (a ninth column did not fit). */
.daily .warmth-line { display: block; margin-top: var(--space-1); white-space: nowrap; color: var(--muted-foreground); }
.daily .warmth-line.text-warning { color: var(--warning); }
.daily .warmth-line.text-danger { color: var(--danger); }
.daily .warmth-line .swing-mark svg { width: 0.875rem; height: 0.875rem; margin-left: var(--space-1); vertical-align: -2px; }
.incident-card .show-all { margin: var(--space-3) 0 0 calc(-1 * var(--space-2)); }
@media (max-width: 770px) {
    .timeline li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}

.brand-field select { width: auto; min-width: 16rem; max-width: 100%; }
.brand-locked { margin: 0 0 var(--space-5); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--faint); }
.brand-locked .section-head { align-items: center; }
.brand-locked .section-head strong { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.brand-locked .section-head .icon { margin: 0; color: var(--muted-foreground); }
.brand-locked .kv { gap: var(--space-2); }
.brand-locked .kv dd { text-align: right; max-width: 36rem; }
@media (max-width: 769px) {
    .brand-table td.health .reason { min-width: 0; }
    .brand-locked .kv > div { flex-direction: column; gap: 2px; }
    .brand-locked .kv dd { text-align: left; }
    .brand-field select { min-width: 0; width: 100%; }
}

/* ---------- Daily check, the compare panel and the complaint-rate chart ---------- */
/* Brand chips reuse the campaign filter's status dots, in the health vocabulary's tints. */
.campaign-filters .status-tabs .dot.health-healthy { background: var(--success); }
.campaign-filters .status-tabs .dot.health-watch, .campaign-filters .status-tabs .dot.health-throttled { background: var(--warning); }
.campaign-filters .status-tabs .dot.health-paused { background: var(--danger); }
.daily .page-header .day-label { min-width: 6.5rem; text-align: center; font-size: var(--text-7); font-weight: 500; font-variant-numeric: tabular-nums; }
.daily .day-sentence { margin: 0; font-size: 1rem; font-weight: 500; line-height: 1.5; }
.daily .day-sentence[data-tone="amber"] { color: var(--warning); }
.daily .day-sentence[data-tone="red"] { color: var(--danger); }
.daily .page-content.has-table { margin: 0; }
.daily tr.is-link { cursor: pointer; }
.daily > .campaign-filters { padding: 0; border: 0; }
.daily .daily-table { width: 100%; }
.daily .daily-table .name-stack .name { max-width: none; }
.daily .daily-table .name-stack .meta { max-width: 44ch; white-space: normal; line-height: 1.4; }
.daily .day-grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
.daily .day-grid th, .daily .day-grid td { padding-inline: var(--space-3); }
.daily .day-grid td { padding-block: var(--space-2); }
.campaign-filters .status-tabs .mark { display: inline-flex; }
.campaign-filters .status-tabs .mark .icon { margin: 0; font-size: 0.75rem; }
.campaign-filters .status-tabs .mark.health-throttled { color: var(--warning); }
.campaign-filters .status-tabs .mark.health-paused { color: var(--danger); }
.daily .day-grid th:first-child, .daily .day-grid td:first-child { padding-left: var(--space-4); }
.daily .day-grid th:last-child, .daily .day-grid td:last-child { padding-right: var(--space-4); }
.daily .card-note { margin: 0; padding: var(--space-3) var(--space-4) var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-8); line-height: 1.5; color: var(--muted-foreground); }
@media (max-width: 1099px) { .daily .day-grid { grid-template-columns: minmax(0, 1fr); } }

/* Why mail was blocked: one row per reason, its count on the right, sample answers under it. */
.block-reasons { display: flex; flex-direction: column; padding: var(--space-2) var(--space-4) var(--space-2); }
.block-row { padding: var(--space-3) 0; }
.block-row + .block-row { border-top: 1px solid var(--border); }
.block-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.block-head .name { display: block; font-weight: 500; }
.block-head .meta { display: block; margin-top: 1px; font-size: var(--text-8); line-height: 1.4; color: var(--muted-foreground); }
.block-count { flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
.block-count .value { display: block; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.block-count .sub { display: block; margin-top: 2px; font-size: var(--text-8); color: var(--muted-foreground); white-space: nowrap; }
.block-row.is-zero .block-count .value { font-weight: 400; color: var(--faint-foreground); }
.block-samples { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.block-samples li { display: flex; justify-content: space-between; gap: var(--space-4); font-size: var(--text-8); line-height: 1.5; color: var(--muted-foreground); }
.block-samples .text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.block-samples .n { flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* Campaign review step: this send against the last send of the same list. */
.review-grid > .compare-card { grid-column: 1; margin: 0; min-width: 0; }
.compare-table { width: 100%; }
.compare-table th { vertical-align: bottom; white-space: normal; }
.compare-table th .last { display: block; margin-top: 2px; white-space: normal; text-transform: none; letter-spacing: 0; font-size: var(--text-8); font-weight: 400; }
.compare-table th .last a { font-weight: 500; }
.compare-table td:first-child { color: var(--muted-foreground); white-space: nowrap; }
.compare-table .now { font-weight: 500; }
.compare-table .delta { display: inline-block; min-width: 5.5rem; margin-left: var(--space-3); font-size: var(--text-8); color: var(--muted-foreground); text-align: right; }
.compare-table .delta.is-worse { color: var(--warning); font-weight: 500; }

/* Brand health: complaint rate by day, inline SVG on the chart tokens. */
.brand-page .trend .section-head { margin-top: var(--space-2); }
.brand-page .trend-card { padding: var(--space-4) var(--space-5); margin: 0; }
.trend-chart { width: 100%; min-height: 180px; }
.trend-chart svg { display: block; overflow: visible; }
.trend-chart + p { margin-top: var(--space-2); }
.trend-chart .grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.trend-chart .axis { fill: var(--muted-foreground); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-chart .ref { stroke-width: 1; stroke-dasharray: 4 3; shape-rendering: crispEdges; }
.trend-chart .ref.watch { stroke: var(--warning); }
.trend-chart .ref.limit { stroke: var(--danger); }
.trend-chart .ref-label { font-size: 11px; font-weight: 500; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.trend-chart .ref-label.watch { fill: var(--warning); }
.trend-chart .ref-label.limit { fill: var(--danger); }
.trend-chart .line { fill: none; stroke: var(--chart-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .point { fill: var(--chart-1); stroke: var(--card); stroke-width: 1.5; }
.trend-chart .point.hollow { fill: var(--card); stroke: var(--muted-foreground); }

/* ---------- Engagement tiers, sunsetting and the frequency limit ---------- */
/* One tint per tier, on the breakdown's bar and cells, the tier pills and the audience picker. */
[data-tier="engaged"] { --tier: var(--success); }
[data-tier="new"] { --tier: var(--info); }
[data-tier="lapsed"] { --tier: var(--warning); }
[data-tier="dormant"] { --tier: var(--muted-foreground); }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 9999px; background: var(--tier, var(--muted-foreground)); flex-shrink: 0; }

/* Recipients step: the breakdown sits under the reach strip, in the same faint box. */
.tier-breakdown { margin: 0 0 var(--space-5); padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--faint); }
.tier-breakdown .section-head { align-items: flex-start; margin-bottom: var(--space-3); }
.tier-breakdown .section-head strong { display: block; font-weight: 500; }
.tier-breakdown .section-head p { margin-top: 2px; }
.tier-bar { display: flex; gap: 2px; height: 0.5rem; border-radius: 9999px; overflow: hidden; background: var(--muted); }
.tier-bar > span { display: block; height: 100%; min-width: 0; background: var(--tier); }
.tier-cells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin-top: var(--space-3); }
.tier-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; height: auto; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-medium); background: var(--card); color: var(--foreground); text-align: left; box-shadow: none; font-weight: 400; transition: background var(--transition-fast), border-color var(--transition-fast); }
.tier-cell:hover:not(:disabled) { background: var(--accent); }
.tier-cell:disabled { opacity: 1; cursor: default; }
.tier-cell[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.tier-cell small { display: flex; align-items: center; gap: 6px; font-size: var(--text-9); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); }
.tier-cell .n { font-size: 1.375rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }
.tier-cell .meta { font-size: var(--text-8); color: var(--muted-foreground); }
.tier-cell[aria-pressed="true"] .meta { color: var(--primary); font-weight: 500; }
.tier-cell:disabled .meta { color: var(--faint-foreground); }
.tier-breakdown .line { margin: var(--space-3) 0 0; font-size: var(--text-8); color: var(--muted-foreground); }
.tier-breakdown .skeleton + .tier-cells .skeleton { border-radius: var(--radius-medium); }
@media (max-width: 640px) { .tier-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Review step: the frequency line under the send card's header. One fixed line, so the
   skeleton and the sentence that replaces it take the same room. */
.send-card .frequency-line { margin: calc(-1 * var(--space-2)) 0 var(--space-4); min-height: 1.25rem; line-height: 1.25rem; font-size: var(--text-7); color: var(--muted-foreground); }
.send-card .frequency-line .skeleton { display: block; width: 22rem; max-width: 100%; height: 0.875rem; margin: 3px 0; }
.send-card .frequency-line .actions { margin-top: var(--space-2); }
.campaign-table td.sent .sub.skipped { color: var(--warning); }

/* Brand page: the Audience card's tier picker, and the Sunset tab. */
.tier-picker label { display: inline-flex; align-items: center; gap: var(--space-2); }
.brand-page [data-cy="panel-sunset"] .settings-items { max-width: 64rem; }
.brand-page .sunset-card .sunset-lists { margin-top: var(--space-4); }
.brand-page .sunset-card .kv { max-width: 28rem; }
.brand-page .sunset-card .kv dt a { color: var(--foreground); }
.brand-page .sunset-card .incident-actions { align-items: center; }
.brand-page .sunset-card .incident-actions .text-light { flex-basis: 100%; }
/* The sample of the batch: folded under the decision, the disclosure the sending groups use. */
.brand-page details.sunset-sample { margin-top: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-medium); }
/* Oat draws the disclosure's chevron on the right; the label stays on the left. */
.brand-page details.sunset-sample > summary { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); cursor: pointer; font-weight: 500; list-style: none; }
/* Oat draws an arrow before the label and a chevron after it; one is enough. */
.brand-page details.sunset-sample > summary::before { display: none; }
.brand-page details.sunset-sample > .table-wrapper { border-top: 1px solid var(--border); }
.brand-page details.sunset-sample table { margin: 0; }
.brand-page details.sunset-sample td { padding-block: var(--space-2); }
.timeline .body .spinner { margin-left: var(--space-2); vertical-align: middle; }

/* Subscribers: the tier filter beside the search, and the engagement lines on a person. */
.subscribers .tier-filter select { height: var(--control-h-sm); width: auto; max-width: 10.5rem; margin: 0; padding-right: var(--space-8); }
/* With the two selects beside it the search box gives way, so the header stays one row at 1440. */
.subscribers .page-header.row .search-form:has(.tier-filter) input[name="search"] { width: 11rem; }
.subscribers .engagement .page-content.has-table { margin: 0; }
.subscribers .engagement .section-head { margin-top: var(--space-2); }
.badge.tier-badge { font-weight: 500; }

/* ---------- Activity log: Settings > Activity and the campaign History tab ---------- */
.activity .page-content.has-table, .activity-history .page-content.has-table { margin: 0; }
.activity-filters select { max-width: 11rem; text-overflow: ellipsis; }
/* Wide enough for "API key: hubspot-sync" and "Users, roles and API keys" to read whole. */
.activity-filters select[name="person"], .activity-filters select[name="kind"] { max-width: 14rem; }
/* The two dates of a custom range take a row of their own under the selects: beside them the
   bar is wider than the card at 1440 and at 1600, and the count would drop to a row alone. */
.activity-filters .custom-range { display: flex; flex-wrap: nowrap; align-items: center; order: 3; flex-basis: 100%; }
.activity .page-header .search-form fieldset.group { margin: 0; }
.activity .page-header .search-form input[type="search"] { width: 15rem; height: var(--control-h); }
.activity-filters .custom-range input[type="date"] { width: 8.75rem; height: var(--control-h-sm); flex: 0 0 auto; margin: 0; }
.activity-filters .bar-end { display: inline-flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.activity-filters .count { white-space: nowrap; }
.activity-filters .bar-end .count { margin-left: 0; }
.activity .table-wrapper > .empty-state { border: 0; }
.activity-table { width: 100%; table-layout: fixed; }
.activity-table th.when { width: 8.5rem; }
.activity-table th.who { width: 13rem; }
.activity-table th.brand { width: 12rem; }
.activity-table td { height: 2.75rem; padding-top: calc(var(--space-2) - 1px); padding-bottom: var(--space-2); box-sizing: border-box; }
.activity-table tr.is-link { cursor: pointer; }
.activity-table tr.is-link:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.activity-table td.when { color: var(--muted-foreground); font-variant-numeric: tabular-nums; }
.activity-table .avatar img, .activity-table .avatar span, .activity-table .avatar.brand .brand-mark { width: 1.75rem; height: 1.75rem; border-radius: var(--radius-small); font-size: var(--text-9); }
.activity-table .avatar.tile .icon, .activity-drawer .avatar.tile .icon { margin: 0; font-size: 0.875rem; }
.activity-table .avatar.brand .brand-mark .icon { font-size: 0.875rem; }
.activity-table .name-stack .name { max-width: none; }
.activity-table td.what .sentence { overflow-wrap: anywhere; }
.activity-table td.what .reason { white-space: normal; overflow-wrap: anywhere; }
/* A block so a long brand name can end in an ellipsis; the line is the pill's inner height, or the
   name sits at the top of the pill. */
.activity-table td.brand .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: middle; line-height: calc(1.25rem - 2px); }
.activity-drawer .dialog-head .avatar img, .activity-drawer .dialog-head .avatar span, .activity-drawer .dialog-head .avatar.brand .brand-mark { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-medium); }
/* Wider than the house drawer: Before and After are two columns of words, and at 36rem an
   e-mail address breaks in the middle. */
dialog.drawer.activity-drawer { max-width: 42rem; }
.activity-drawer .dialog-card { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.activity-drawer .dialog-head .title-text { flex: 1; min-width: 0; }
.activity-drawer .dialog-head .dialog-title { margin: 0; line-height: 1.4; overflow-wrap: anywhere; }
.activity-drawer .dialog-body { display: flex; flex-direction: column; gap: var(--space-5); }
.activity-drawer .kv dd { text-align: right; overflow-wrap: anywhere; }
.activity-drawer h5 { margin: 0 0 var(--space-2); font-size: var(--text-7); font-weight: 600; }
.activity-drawer .activity-reason p { margin: 0; font-size: var(--text-7); overflow-wrap: anywhere; }
.activity-drawer .entry-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); }
.activity-drawer .entry-head h5 { font-weight: 500; }
.activity-drawer .entry-head > span { flex-shrink: 0; font-variant-numeric: tabular-nums; }
table.changes { width: 100%; table-layout: fixed; border: 1px solid var(--border); border-radius: var(--radius-medium); border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.changes th { position: static; background: var(--faint); }
table.changes th:first-child { width: 28%; }
table.changes tbody th { text-transform: none; letter-spacing: 0; font-size: var(--text-8); font-weight: 500; color: var(--muted-foreground); white-space: normal; vertical-align: top; border-bottom: 1px solid var(--border); }
table.changes td { height: auto; vertical-align: top; font-size: var(--text-8); overflow-wrap: anywhere; text-wrap: pretty; }
table.changes tbody tr:last-child th { border-bottom: 0; }
/* Nothing here is a link, so a row under the pointer stays as it is (the row and its cells both). */
table.changes tbody tr:hover, .activity-drawer table.changes tbody tr:hover td { background: transparent; }
/* History is not a step of the builder: it sits at the end of the stepper, unnumbered. */
.stepper li.is-aside { flex: 0 0 auto; }
.stepper li.is-aside .dot .icon { display: inline-block; }
/* A page this person may not open: worded, in the shell, never the API's JSON. */
.refused .empty-state { margin-top: var(--space-4); }
.refused-actions { display: flex; align-items: center; justify-content: center; gap: var(--space-2); margin-top: var(--space-2); }
.refused-actions .button, .refused-actions button { margin: 0; }

/* ---------- Approvals and the content lock (governance, slice B) ---------- */
/* The badge beside the status and the small state word under a name: waiting reads as
   information, sent back as something to act on. Approved shows nothing. */
.badge.approval-requested { --badge-fg: var(--info); --badge-bg: var(--tone-blue-bg); }
.badge.approval-changes_requested { --badge-fg: var(--warning); --badge-bg: var(--tone-amber-bg); }
.campaign-table .meta-line .approval-word { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; color: var(--info); }
.campaign-table .meta-line .approval-word::before { content: ""; width: 6px; height: 6px; border-radius: 9999px; background: currentColor; }
.campaign-table .meta-line .approval-word[data-state="changes_requested"] { color: var(--warning); }
.campaign-filters .status-tabs > a.approval-tab .icon { margin: 0; font-size: 0.8125rem; color: var(--faint-foreground); }
.campaign-filters .status-tabs > a.approval-tab[aria-current] .icon, .campaign-filters .status-tabs > a.approval-tab:not(.is-empty) .icon { color: var(--info); }
.approval-queue td { vertical-align: top; }
.approval-queue td.note .note-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--text-8); color: var(--muted-foreground); text-wrap: pretty; }
.campaigns .table-wrapper > .empty-state { border: 0; }
/* The number waiting, on the rail and on the panel: a plain muted number, as the theme has it. */
aside[data-rail] a .count { margin-left: auto; margin-right: var(--space-2); font-size: var(--text-8); color: var(--muted-foreground); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity var(--transition-fast); }
html[data-rail-pinned] aside[data-rail] a .count, html:not([data-rail-pinned]) aside[data-rail]:hover a .count { opacity: 1; }
aside[data-rail] a:has(.count:not([hidden])) > span:first-child::after { content: ""; position: absolute; top: 0.625rem; left: 2.375rem; width: 7px; height: 7px; border-radius: 9999px; background: var(--info); box-shadow: 0 0 0 2px var(--rail); }

/* The one line on a locked step, and the frozen fields as text under it. */
.approval-lock { display: flex; align-items: center; gap: var(--space-3); margin: 0 0 var(--space-5); padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--faint); font-size: var(--text-7); }
.approval-lock .lock-mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: var(--muted); color: var(--muted-foreground); }
.approval-lock .lock-mark .icon { margin: 0; font-size: 0.875rem; }
.approval-lock .sentence { flex: 1; min-width: 0; text-wrap: pretty; }
.approval-lock button { flex-shrink: 0; margin: 0; }
.approval-lock.in-card { margin-bottom: var(--space-4); align-items: flex-start; flex-wrap: wrap; }
.approval-lock.in-card .sentence { flex-basis: calc(100% - 1.75rem - var(--space-3)); }
.approval-lock.in-card button { margin-left: calc(1.75rem + var(--space-3)); }
.approval-frozen .kv dd { overflow-wrap: anywhere; }
.step-card .approval-preview { border: 1px solid var(--border); border-radius: var(--radius-large); overflow: hidden; }
.step-card .approval-preview iframe { min-height: 30rem; }
/* The locked Content step is a page to read, not an editor: the width of the other steps. */
.builder .step[data-cy="step-content"]:has([data-cy="content-locked"]) { max-width: 72rem; padding-top: var(--space-8); }
.builder .step[data-cy="step-content"] .approval-preview iframe { min-height: 34rem; }

/* The send card while the campaign is not approved. */
.send-card .approval-ask header { margin-bottom: var(--space-4); }
.send-card .approval-ask header h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }
.send-card .approval-ask header p { margin: 2px 0 0; font-size: var(--text-7); color: var(--muted-foreground); }
.send-card .approval-ask header p.text-warning { color: var(--warning); }
.approval-note { margin: var(--space-2) 0 0; padding: var(--space-2) var(--space-3); border-left: 3px solid var(--border); border-radius: 0 var(--radius-medium) var(--radius-medium) 0; background: var(--faint); font-size: var(--text-7); font-style: normal; color: var(--foreground); overflow-wrap: anywhere; text-wrap: pretty; white-space: pre-line; }
.send-card .approval-note { margin: 0 0 var(--space-4); }
.send-card .approval-sent-back { margin-bottom: var(--space-4); }
.send-card .approval-sent-back strong { display: block; margin-bottom: var(--space-2); font-weight: 500; }
.send-card .approval-sent-back .approval-note { margin: 0; border-left-color: var(--warning); }

/* The approval panel: who asks, what changed, what goes out, then the two decisions. */
.approval-panel { margin-bottom: var(--space-4); }
.review-grid + .approval-panel { margin: var(--space-4) 0 0; }
.approval-panel h3 { margin: var(--space-6) 0 var(--space-3); font-size: var(--text-7); font-weight: 600; }
.approval-panel .approval-thread li { grid-template-columns: 7rem minmax(0, 1fr); }
.approval-panel .approval-thread .approval-note { max-width: 46rem; }
.approval-panel .approval-changes table.changes { max-width: 60rem; }
.approval-panel table.changes tr[data-kind="content"] td { white-space: pre-line; }
/* The thread shows the newest message; what came before folds under it. */
.approval-thread[data-folded="true"] { margin-bottom: 0; }
.approval-thread-toggle { display: inline-block; margin: var(--space-2) 0 0 7rem; padding: 0; border: 0; background: none; font-size: var(--text-8); color: var(--muted-foreground); cursor: pointer; }
.approval-thread-toggle:hover { color: var(--foreground); text-decoration: underline; }
/* The facts are a strip of cells; the message itself gets the panel's full width, at the
   width an inbox gives it, and tall enough to read without scrolling inside the frame. */
.approval-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin-bottom: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); overflow: hidden; }
.approval-facts > div { display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--faint); }
.approval-facts > div:nth-child(-n+4 of :not([style*="display: none"])) { border-top: 0; }
.approval-facts > div:nth-child(4n+1 of :not([style*="display: none"])) { border-left: 0; }
.approval-facts dt { font-size: var(--text-8); }
.approval-facts dd { min-width: 0; text-align: left; overflow-wrap: anywhere; text-wrap: pretty; font-variant-numeric: normal; }
.approval-facts dd .line { display: block; }
/* A last cell alone on its row takes the rest of it. */
.approval-facts > div:nth-child(4n+1 of :not([style*="display: none"])):nth-last-child(1 of :not([style*="display: none"])) { grid-column: 1 / -1; }
.approval-facts > div:nth-child(4n+2 of :not([style*="display: none"])):nth-last-child(1 of :not([style*="display: none"])) { grid-column: 2 / -1; }
.approval-facts > div:nth-child(4n+3 of :not([style*="display: none"])):nth-last-child(1 of :not([style*="display: none"])) { grid-column: 3 / -1; }
.approval-preview .inbox-head .button { margin: 0; flex: 0 0 auto; }
.approval-panel .approval-preview .frame { padding: var(--space-5); }
.approval-panel .approval-preview iframe { width: 100%; max-width: 52rem; min-height: 44rem; }
/* The two decisions stay in reach while the panel is on screen. */
.approval-actions { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: var(--space-3); margin: var(--space-6) calc(-1 * var(--space-6)) calc(-1 * var(--space-6)); padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-large) var(--radius-large); background: var(--card); }
.approval-actions .spacer { flex: 1; }
.approval-panel .approval-actions p { max-width: 36rem; margin: 0; }
.approval-actions button { margin: 0; }
@media (max-width: 1000px) {
    .approval-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .approval-facts > div:nth-child(-n+4 of :not([style*="display: none"])) { border-top: 1px solid var(--border); }
    .approval-facts > div:nth-child(-n+2 of :not([style*="display: none"])) { border-top: 0; }
    .approval-facts > div:nth-child(4n+1 of :not([style*="display: none"])) { border-left: 1px solid var(--border); }
    .approval-facts > div:nth-child(2n+1 of :not([style*="display: none"])) { border-left: 0; }
    .approval-facts > div:nth-last-child(1 of :not([style*="display: none"])) { grid-column: auto; }
    .approval-facts > div:nth-child(2n+1 of :not([style*="display: none"])):nth-last-child(1 of :not([style*="display: none"])) { grid-column: 1 / -1; }
}

/* Brand page: the warning before a changed footer is saved, and a heartbeat's approval. */
.footer-warning { margin-top: var(--space-3); }
.heartbeat-approval { color: var(--muted-foreground); }
.heartbeat-approval .mark .icon { margin: 0 2px 0 0; font-size: 0.875rem; vertical-align: -2px; }
.heartbeat-approval[data-state="matched"] .mark { color: var(--success); }
.heartbeat-approval[data-state="waiting"] .mark { color: var(--warning); }
td .heartbeat-approval.sub { display: block; margin-top: 2px; font-size: var(--text-8); }
/* Template page: approved campaigns keep the version they were approved with. */
.approval-note-line { align-items: center; }
.templates .approval-note-line { margin-bottom: var(--space-4); }

/* Approved templates and the parts of a visual template a campaign cannot change (slice C). */
.templates .locked-parts { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--border); }
.locked-parts .section-head { align-items: center; margin-bottom: var(--space-2); }
.locked-parts .section-head h3 { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: var(--text-6); font-weight: 600; }
.locked-parts .section-head .icon { margin: 0; color: var(--muted-foreground); }
.locked-parts .block-list { display: flex; flex-direction: column; gap: var(--space-2); margin: var(--space-4) 0; padding: 0; }
.locked-parts .block-list li { padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-large); background: var(--faint); }
.locked-parts .block-list li[data-locked] { border-color: var(--info); background: var(--background); }
.locked-parts .block-lock { display: flex; align-items: baseline; gap: var(--space-3); font-size: var(--text-7); }
.locked-parts .block-lock input { margin: 0; flex-shrink: 0; }
.locked-parts .block-lock .kind { flex-shrink: 0; font-weight: 500; }
.locked-parts .block-lock .excerpt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-8); }
.locked-parts .block-label { max-width: 24rem; margin: var(--space-3) 0 0 1.75rem; }
.locked-parts .lock-warning { display: flex; align-items: center; gap: var(--space-2); margin: var(--space-3) 0 0; color: var(--warning); }
.locked-parts .lock-warning .icon { margin: 0; flex-shrink: 0; }
.approved-only-warning { margin-bottom: var(--space-4); }
.template-approval .approval-state { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-6); font-weight: 500; }
.template-approval .approval-state .mark .icon { margin: 0; color: var(--muted-foreground); }
.template-approval[data-state="approved"] .approval-state .mark .icon { color: var(--success); }
.template-approval .send-actions { margin-top: var(--space-4); }
.template-approval .send-actions button { margin: 0; }
/* The builder: which parts the template sets, and the word when one is put back. */
.locked-parts-line { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); font-size: var(--text-7); color: var(--muted-foreground); }
.locked-parts-line .icon { margin: 0; flex-shrink: 0; }
.locked-restored { margin: 0 0 var(--space-3); font-size: var(--text-7); color: var(--info); }
