* {
    box-sizing: border-box;
}

:root {
    --bg: #f4efe6;
    --bg-accent: #fff9ef;
    --ink: #182029;
    --muted: #5d6a73;
    --line: rgba(24, 32, 41, 0.12);
    --panel: rgba(255, 251, 244, 0.92);
    --shadow: 0 24px 60px rgba(42, 55, 69, 0.12);
    --brand: #0f766e;
    --brand-dark: #115e59;
    --warn: #b45309;
    --danger: #b91c1c;
    --ok: #166534;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: "Segoe UI Variable Text", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 34%),
        radial-gradient(circle at top right, rgba(180, 83, 9, 0.16), transparent 28%),
        linear-gradient(180deg, #fff7ea 0%, #f4efe6 52%, #ece6dc 100%);
}

code {
    font-family: Consolas, "Courier New", monospace;
    background: rgba(15, 118, 110, 0.08);
    padding: 0.1rem 0.3rem;
    border-radius: 0.35rem;
}

a {
    color: var(--brand-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
textarea {
    font: inherit;
}

.app-shell {
    width: min(1400px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.hero {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    padding: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 1.75rem;
    background:
        linear-gradient(135deg, rgba(255, 250, 241, 0.98), rgba(244, 239, 230, 0.92)),
        var(--panel);
    box-shadow: var(--shadow);
}

.eyebrow,
.panel-kicker {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--brand-dark);
}

.hero h1 {
    margin: 0;
    max-width: 16ch;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2rem, 4vw, 3.7rem);
    line-height: 0.95;
}

.hero-copy {
    max-width: 60ch;
    color: var(--muted);
    line-height: 1.65;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: center;
    padding: 1.5rem;
    border-radius: 1.4rem;
    background: rgba(15, 118, 110, 0.06);
    border: 1px solid rgba(15, 118, 110, 0.14);
}

.generated-at,
.worker-status,
.helper-note,
.table-sub,
.metric-sub,
.empty-state {
    color: var(--muted);
    font-size: 0.94rem;
}

.flash {
    margin-top: 1rem;
    padding: 0.95rem 1.1rem;
    border-radius: 1rem;
    border: 1px solid transparent;
}

.flash-success {
    background: rgba(22, 101, 52, 0.08);
    border-color: rgba(22, 101, 52, 0.2);
}

.flash-error {
    background: rgba(185, 28, 28, 0.08);
    border-color: rgba(185, 28, 28, 0.18);
}

.metric-grid,
.panel-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card,
.panel {
    border-radius: 1.35rem;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 1.4rem;
}

.metric-label {
    display: block;
    color: var(--muted);
    font-size: 0.9rem;
}

.metric-value {
    display: block;
    margin-top: 0.35rem;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    line-height: 1;
}

.panel {
    padding: 1.4rem;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.25rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.badge-ok {
    background: rgba(22, 101, 52, 0.1);
    color: var(--ok);
}

.badge-warn {
    background: rgba(180, 83, 9, 0.12);
    color: var(--warn);
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

label {
    display: grid;
    gap: 0.45rem;
    color: var(--ink);
    font-weight: 600;
}

input,
textarea {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 1px solid rgba(24, 32, 41, 0.14);
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
}

textarea {
    resize: vertical;
    min-height: 7rem;
}

.primary-button,
.secondary-button,
.secondary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.9rem;
    padding: 0.8rem 1.15rem;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    font-weight: 700;
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-button {
    background: linear-gradient(135deg, var(--brand), #138f86);
    color: #fff;
    box-shadow: 0 16px 30px rgba(15, 118, 110, 0.22);
}

.secondary-button,
.secondary-link {
    background: rgba(24, 32, 41, 0.08);
    color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover,
.secondary-link:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.toggle-row {
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
    font-weight: 600;
}

.toggle-row input {
    width: auto;
    margin: 0;
}

.variable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.variable-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-dark);
    font-size: 0.9rem;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 0.9rem 0.7rem;
    border-top: 1px solid rgba(24, 32, 41, 0.08);
    vertical-align: top;
}

thead th {
    border-top: 0;
    color: var(--muted);
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.table-compact {
    display: grid;
    gap: 0.25rem;
}

.progress-shell {
    width: 100%;
    height: 0.72rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(24, 32, 41, 0.08);
}

.progress-bar {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), #4dc0b5);
}

.progress-text {
    display: inline-block;
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: capitalize;
}

.status-pending,
.status-processing,
.status-sent {
    background: rgba(15, 118, 110, 0.08);
    color: var(--brand-dark);
}

.status-delivered {
    background: rgba(22, 101, 52, 0.12);
    color: var(--ok);
}

.status-failed,
.status-unsubscribed {
    background: rgba(185, 28, 28, 0.1);
    color: var(--danger);
}

.is-selected {
    background: rgba(15, 118, 110, 0.05);
}

.campaign-form {
    margin-top: 1rem;
}

@media (max-width: 1080px) {
    .hero,
    .panel-grid,
    .metric-grid,
    .field-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-shell {
        width: min(100% - 1rem, 1400px);
        padding: 1rem 0 2rem;
    }

    .hero,
    .panel,
    .metric-card {
        padding: 1rem;
        border-radius: 1.1rem;
    }

    th,
    td {
        padding-inline: 0.45rem;
    }
}
