:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --ink: #20283a;
    --muted: #667085;
    --line: #d9e0ea;
    --brand: #b3152d;
    --brand-dark: #831125;
    --brand-soft: #fff0f3;
    --ok: #0b7a53;
    --ok-soft: #e8f7f0;
    --warn: #9a5b00;
    --warn-soft: #fff5df;
    --bad: #b42318;
    --bad-soft: #fff0ee;
    --shadow: 0 16px 44px rgba(31, 42, 68, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--brand);
    font-weight: 700;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 800;
}

button:hover {
    background: var(--brand-dark);
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    padding: 10px 14px;
    text-decoration: none;
    font-weight: 800;
}

.button-link:hover {
    background: var(--brand-dark);
}

.btn-secondary {
    background: #eef2f8;
    color: var(--ink);
}

.btn-secondary:hover {
    background: #dfe6f1;
}

.btn-small {
    min-height: 32px;
    padding: 7px 10px;
    font-size: 12px;
}

.link-button {
    min-height: 0;
    background: transparent;
    color: var(--bad);
    padding: 0;
}

.login-body,
.verify-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(180deg, #fff7f8 0%, #f5f7fb 46%, #eef2f8 100%);
}

.login-card,
.verify-card {
    width: min(500px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.login-card h1,
.verify-card h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.login-card p,
.verify-card p {
    color: var(--muted);
}

label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    background: #fff;
    color: var(--ink);
    font-weight: 400;
}

input[type="checkbox"] {
    width: auto;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(179, 21, 45, 0.16);
    border-color: var(--brand);
}

textarea {
    resize: vertical;
}

form {
    display: grid;
    gap: 14px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: minmax(230px, 1fr) minmax(240px, 380px) auto;
    gap: 16px;
    align-items: center;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(31, 42, 68, 0.05);
}

.brand-block strong {
    display: block;
    margin-top: 1px;
    font-size: 18px;
}

.brand-block span:not(.eyebrow) {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 13px;
}

.eyebrow {
    display: inline-flex;
    color: var(--brand);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.campaign-switcher {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: end;
}

.campaign-switcher label {
    font-size: 12px;
}

.campaign-switcher select {
    min-height: 40px;
}

.role-chip,
.role {
    justify-self: start;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    color: var(--muted);
    font-weight: 800;
}

.topbar nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.topbar nav a {
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 11px;
    background: #fff;
    white-space: nowrap;
}

.topbar nav a.active {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.wrap {
    width: min(1260px, calc(100% - 32px));
    margin: 22px auto 48px;
}

.page-head,
.hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    border-radius: 8px;
}

.page-head {
    margin-bottom: 18px;
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
}

.page-head h1,
.hero h1 {
    margin: 4px 0 7px;
    font-size: 30px;
    line-height: 1.15;
}

.page-head p {
    margin: 0;
    color: var(--muted);
}

.hero {
    padding: 28px;
    color: #fff;
    background: linear-gradient(135deg, #9f1730 0%, #30384d 100%);
    box-shadow: var(--shadow);
}

.hero p {
    max-width: 760px;
    margin: 0;
    color: rgba(255, 255, 255, 0.84);
}

.hero .role {
    border-color: rgba(255, 255, 255, 0.36);
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin: 18px 0;
}

.metric-grid div,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metric-grid div {
    padding: 16px;
    min-height: 96px;
}

.metric-grid strong {
    display: block;
    font-size: 30px;
    line-height: 1;
}

.metric-grid span,
.muted,
small {
    color: var(--muted);
}

.panel {
    margin-top: 18px;
    padding: 20px;
    box-shadow: 0 10px 28px rgba(31, 42, 68, 0.04);
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 21px;
}

.grid-form {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.grid-form label {
    min-width: 0;
}

.grid-form button {
    align-self: end;
}

.inline-form {
    display: flex;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.inline-form label {
    min-width: min(280px, 100%);
}

.day-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(120px, 1fr));
    gap: 10px;
    align-items: end;
}

.day-grid label {
    min-height: 126px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.day-grid label span {
    font-size: 14px;
}

.day-grid label small {
    margin-top: -2px;
}

.day-grid input {
    margin-top: auto;
}

.day-grid button {
    grid-column: 1 / -1;
    justify-self: start;
}

.stack-form {
    min-width: 0;
}

.email-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
    gap: 18px;
    align-items: start;
}

.mail-preview {
    position: sticky;
    top: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    overflow: hidden;
}

.preview-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #fff;
    font-weight: 900;
}

.preview-subject {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--brand);
    font-weight: 900;
}

.preview-body {
    min-height: 190px;
    padding: 18px 14px;
    background: #fff;
    line-height: 1.55;
}

.preview-body a {
    color: var(--brand);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.preview-text {
    border-top: 1px solid var(--line);
    padding: 12px 14px;
}

.preview-text summary {
    cursor: pointer;
    font-weight: 800;
}

.preview-text pre {
    white-space: pre-wrap;
    color: var(--muted);
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
}

.table-wrap {
    margin-top: 6px;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 1220px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 12px 11px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

tbody tr:hover {
    background: #fafbfd;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 9px;
    background: #f8fafc;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    white-space: nowrap;
}

.badge.success {
    border-color: #bfe7d4;
    background: var(--ok-soft);
    color: var(--ok);
}

.badge.warning {
    border-color: #f4d48d;
    background: var(--warn-soft);
    color: var(--warn);
}

.badge.danger {
    border-color: #ffc8c1;
    background: var(--bad-soft);
    color: var(--bad);
}

td small {
    display: block;
    margin-top: 5px;
}

.row-actions {
    display: grid;
    gap: 7px;
    align-items: start;
}

.row-actions form {
    display: block;
}

.path-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 220px;
}

.path-steps span {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 3px 7px;
    background: #fff;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.tabs a {
    color: var(--ink);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
}

.tabs a.active {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.alert {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: var(--ok-soft);
    border: 1px solid #bce6d6;
    color: var(--ok);
    font-weight: 700;
}

.alert.error {
    background: var(--bad-soft);
    border-color: #ffd1cc;
    color: var(--bad);
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check input {
    width: auto;
}

.compact-check {
    gap: 6px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.voucher-code {
    display: block;
    padding: 14px;
    border: 1px dashed var(--brand);
    border-radius: 8px;
    color: var(--brand);
    background: var(--brand-soft);
    font-size: 24px;
    font-weight: 900;
    text-align: center;
    overflow-wrap: anywhere;
}

.decision-actions {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 1120px) {
    .topbar {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .campaign-switcher {
        max-width: 520px;
    }

    .topbar nav {
        justify-content: flex-start;
    }
}

@media (max-width: 900px) {
    .page-head,
    .hero {
        display: grid;
    }

    .email-editor-grid,
    .grid-form,
    .day-grid {
        grid-template-columns: 1fr 1fr;
    }

    .mail-preview {
        position: static;
    }
}

@media (max-width: 620px) {
    .wrap {
        width: min(100% - 20px, 1260px);
        margin-top: 14px;
    }

    .topbar {
        padding: 12px;
    }

    .campaign-switcher,
    .metric-grid,
    .email-editor-grid,
    .grid-form,
    .day-grid {
        grid-template-columns: 1fr;
    }

    .inline-form {
        display: grid;
    }

    .decision-actions {
        grid-template-columns: 1fr;
    }
}
