@font-face {
    font-family: "Museo Sans";
    src: url("fonts/MuseoSans_300.otf") format("opentype");
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: "Museo Sans";
    src: url("fonts/MuseoSans_500.otf") format("opentype");
    font-weight: 500;
    font-style: normal;
}

@font-face {
    font-family: "Museo Sans";
    src: url("fonts/MuseoSans_700.otf") format("opentype");
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: "Museo Sans";
    src: url("fonts/MuseoSans_900.otf") format("opentype");
    font-weight: 900;
    font-style: normal;
}

@font-face {
    font-family: "Museo Slab";
    src: url("fonts/Museo_Slab_700.otf") format("opentype");
    font-weight: 700;
    font-style: normal;
}

:root {
    --oa-red: #e31837;
    --oa-red-dark: #c6132f;
    --oa-charcoal: #36454F;
    --oa-white: #ffffff;

    --bg: #f3f4f6;
    --card: #ffffff;
    --border: #e2e5e9;
    --border-strong: #cfd4da;
    --text: #1d2730;
    --text-muted: #5d6973;
    --text-faint: #8a949c;
    --field: #ffffff;
    --hover: #f6f7f9;

    --sidebar: #2f3c45;
    --sidebar-text: rgba(255, 255, 255, 0.78);
    --sidebar-active: rgba(255, 255, 255, 0.1);

    --series-1: #2a78d6;
    --grid: #eceef1;

    --good: #12805c;
    --good-bg: #e6f4ee;
    --warn: #9a5b00;
    --warn-bg: #fdf1dc;
    --info: #1f5fae;
    --info-bg: #e7f0fb;
    --bad: #b42318;
    --bad-bg: #fdecea;
    --neutral-bg: #eef0f2;

    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: "Museo Sans", system-ui, sans-serif;
    font-weight: 500;
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

h1, h2 {
    margin: 0;
}

h1 {
    font-family: "Museo Slab", serif;
    font-size: 26px;
    line-height: 1.15;
}

h2 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
}

.cardHeader h2 {
    margin-bottom: 0;
}

code {
    background: var(--neutral-bg);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}

.brandMail {
    color: var(--oa-red);
}

/* ---------- Layout ---------- */

.app {
    display: grid;
    grid-template-columns: 220px 1fr;
    height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    color: var(--oa-white);
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 22px;
    font-family: "Museo Slab", serif;
    font-size: 22px;
}

.brand img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.navItem {
    background: transparent;
    border: 0;
    color: var(--sidebar-text);
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.navItem:hover {
    background: var(--sidebar-active);
    color: var(--oa-white);
}

.navItem.active {
    background: var(--sidebar-active);
    color: var(--oa-white);
    box-shadow: inset 3px 0 0 var(--oa-red);
}

.sidebarFooter {
    margin-top: auto;
    padding: 12px 8px 0;
    font-size: 12px;
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.connection {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
}

.connection .dot {
    flex: 0 0 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-faint);
}

.connection.ok .dot {
    background: #3ccf91;
}

.connection.error .dot {
    background: #ff6b5e;
}

.credit {
    color: rgba(255, 255, 255, 0.45);
}

.main {
    overflow-y: auto;
    position: relative;
}

.view {
    display: none;
    padding: 28px 32px 40px;
    max-width: 1280px;
    margin: 0 auto;
    flex-direction: column;
    gap: 16px;
}

.view.active {
    display: flex;
}

#view-compose.active {
    padding-bottom: 0;
    min-height: 100%;
}

.viewHeader {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.sub {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 300;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    min-width: 0;
}

.cardHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.row > input {
    flex: 1;
    min-width: 160px;
}

.row.spread {
    justify-content: space-between;
}

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

.inlineControls input[type="text"] {
    width: auto;
    flex: 1;
    min-width: 200px;
}

.row.spread > .inlineControls:first-child:not(:only-child) {
    flex: 1;
}

.pushRight {
    margin-left: auto;
    justify-content: flex-end;
}

.hint + .fieldLabel {
    margin-top: 14px;
}

.hint + div > table {
    margin-top: 12px;
}

#campaignTiles {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.twoColumn {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.hint {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 300;
    line-height: 1.5;
}

.empty {
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 300;
    padding: 18px 0;
    text-align: center;
}

/* ---------- Controls ---------- */

button {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    border: 1px solid transparent;
    white-space: nowrap;
}

button:disabled {
    opacity: 0.55;
    cursor: default;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--series-1);
    outline-offset: 1px;
}

.primary {
    background: var(--oa-red);
    color: var(--oa-white);
}

.primary:hover:not(:disabled) {
    background: var(--oa-red-dark);
}

.secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border-strong);
}

.secondary:hover:not(:disabled),
.ghost:hover:not(:disabled) {
    background: var(--hover);
}

.ghost {
    background: transparent;
    color: var(--text-muted);
}

.danger {
    background: var(--bad);
    color: var(--oa-white);
}

.ghostDanger {
    background: transparent;
    color: var(--bad);
}

.ghostDanger:hover {
    background: var(--bad-bg);
}

.linkButton {
    background: none;
    border: 0;
    padding: 0;
    color: var(--info);
    font-weight: 500;
    font-size: 13px;
}

.linkButton:hover {
    text-decoration: underline;
}

.linkButton.back {
    margin-bottom: 6px;
}

.chip {
    background: var(--neutral-bg);
    color: var(--text);
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 999px;
}

.chip:hover {
    background: var(--border);
}

input,
select,
textarea {
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: var(--field);
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    padding: 9px 11px;
}

input[type="text"],
input[type="email"],
textarea {
    width: 100%;
}

#listSelect {
    width: 100%;
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

.fieldLabel {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin: 0 0 6px;
}

.fieldLabel ~ .fieldLabel,
input + .fieldLabel,
textarea + .fieldLabel {
    margin-top: 14px;
}

.labelRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 14px 0 6px;
}

.labelRow .fieldLabel {
    margin: 0;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
}

.segmented {
    display: inline-flex;
    background: var(--neutral-bg);
    border-radius: 8px;
    padding: 3px;
}

.segmented button {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.segmented button.active {
    background: var(--card);
    color: var(--text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.segmented.small button {
    padding: 4px 10px;
    font-size: 12px;
}

/* ---------- Stat tiles ---------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
}

.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}

.tileLabel {
    font-size: 13px;
    color: var(--text-muted);
}

.tileValue {
    font-size: 28px;
    font-weight: 700;
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.tileDetail {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 300;
    margin-top: 2px;
}

/* ---------- Chart ---------- */

.chart {
    position: relative;
    height: 240px;
}

.chart svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart .gridLine {
    stroke: var(--grid);
    stroke-width: 1;
}

.chart .baseline {
    stroke: var(--border-strong);
    stroke-width: 1;
}

.chart .axisLabel {
    fill: var(--text-muted);
    font-size: 11px;
    font-family: inherit;
}

.chart .bar {
    fill: var(--series-1);
}

.chart .hit {
    fill: transparent;
    cursor: default;
}

.chart .hit:hover + .hoverBand,
.chart .hoverBand.on {
    fill: rgba(42, 120, 214, 0.08);
}

.chart .hoverBand {
    fill: transparent;
    pointer-events: none;
}

.chartTooltip {
    position: absolute;
    pointer-events: none;
    background: var(--text);
    color: var(--oa-white);
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 10px));
    z-index: 2;
}

.chartTooltip strong {
    display: block;
    margin-bottom: 2px;
}

/* ---------- Tables ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    padding: 0 10px 10px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

th:first-child,
td:first-child {
    padding-left: 0;
}

th:last-child,
td:last-child {
    padding-right: 0;
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

tr.clickable {
    cursor: pointer;
}

tr.clickable:hover td {
    background: var(--hover);
}

.cellTitle {
    font-weight: 700;
}

.cellSub {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 300;
}

.pill {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--neutral-bg);
    color: var(--text-muted);
}

.pill.sent { background: var(--good-bg); color: var(--good); }
.pill.sending { background: var(--info-bg); color: var(--info); }
.pill.scheduled { background: var(--info-bg); color: var(--info); }
.pill.paused { background: var(--warn-bg); color: var(--warn); }
.pill.canceled { background: var(--neutral-bg); color: var(--text-muted); }

.notice {
    background: var(--warn-bg);
    color: var(--warn);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 14px;
}

.progress {
    height: 8px;
    border-radius: 999px;
    background: var(--info-bg);
    overflow: hidden;
}

.progressFill {
    height: 100%;
    width: 0;
    background: var(--series-1);
    border-radius: 999px;
    transition: width 0.4s ease;
}

/* ---------- Compose ---------- */

.composeGrid {
    display: grid;
    grid-template-columns: minmax(380px, 1fr) minmax(380px, 1fr);
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.composeForm {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.composeForm .card.grow {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.codeEditor {
    flex: 1;
    min-height: 280px;
    font-family: Consolas, "Cascadia Mono", monospace;
    font-size: 13px;
    tab-size: 2;
    white-space: pre;
    resize: none;
}

.previewCard {
    display: flex;
    flex-direction: column;
    min-height: 520px;
}

.previewStage {
    flex: 1;
    display: flex;
    justify-content: center;
    background: var(--neutral-bg);
    border-radius: 8px;
    padding: 12px;
    min-height: 0;
}

.previewFrame {
    width: 100%;
    height: 100%;
    min-height: 460px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #ffffff;
    transition: width 0.2s ease;
}

.previewStage.mobile .previewFrame {
    width: 375px;
}

.sendBar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 0 -32px;
    padding: 14px 32px;
    background: rgba(255, 255, 255, 0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(6px);
}

.sendBar #testAddress {
    width: 240px;
}

/* ---------- Toast and dialog ---------- */

.toast {
    position: fixed;
    right: 24px;
    bottom: 84px;
    max-width: 420px;
    background: var(--text);
    color: var(--oa-white);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.45;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 50;
}

.toast.error {
    background: var(--bad);
}

.toast.success {
    background: var(--good);
}

dialog {
    border: 0;
    border-radius: 12px;
    padding: 22px 24px;
    width: min(440px, 90vw);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
    color: var(--text);
}

dialog::backdrop {
    background: rgba(20, 28, 34, 0.45);
}

dialog p {
    color: var(--text-muted);
    line-height: 1.5;
    font-size: 14px;
}

/* ---------- Startup splash ---------- */

.startupSplash {
    position: fixed;
    inset: 0;
    background: var(--oa-charcoal);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 100;
    pointer-events: none;
    animation: splashSlideAway 0.9s ease-in-out 2.7s forwards;
}

.startupSplash,
.startupSplash .splashTitle,
.startupSplash .splashLogo {
    animation-play-state: paused;
}

.startupSplash.splashReady,
.startupSplash.splashReady .splashTitle,
.startupSplash.splashReady .splashLogo {
    animation-play-state: running;
}

.splashRow {
    --splash-gap: clamp(20px, 3.5vmin, 44px);
    --logo-shift: -180px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--splash-gap);
}

.splashTitle {
    margin: 0;
    font-family: "Museo Slab";
    font-size: clamp(3.2rem, 11vmin, 7.8rem);
    color: var(--oa-white);
    letter-spacing: 0.01em;
    animation: splashTitleFadeOut 0.4s ease-in 1.72s forwards;
}

.splashLogo {
    width: clamp(120px, 18vmin, 230px);
    height: clamp(120px, 18vmin, 230px);
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
    backface-visibility: hidden;
    object-fit: contain;
    animation: splashLogoToCenter 0.68s cubic-bezier(0.22, 0.61, 0.36, 1) 1.72s forwards, splashLogoFadeOut 0.6s ease-in 2.64s forwards;
}

@keyframes splashLogoToCenter {
    from {
        transform: translate3d(0, 0, 0);
    }
    to {
        transform: translate3d(var(--logo-shift), 0, 0);
    }
}

@keyframes splashTitleFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes splashLogoFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

@keyframes splashSlideAway {
    from {
        transform: translateX(0) skewX(0deg);
    }
    to {
        transform: translateX(100%) skewX(-5deg);
        visibility: hidden;
        pointer-events: none;
    }
}

/* ---------- Narrow windows ---------- */

@media (max-width: 1000px) {
    .composeGrid,
    .twoColumn {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }

    .brand {
        padding: 0 8px;
        font-size: 18px;
    }

    .sidebarFooter {
        display: none;
    }

    .view {
        padding: 20px 16px 32px;
    }

    .sendBar {
        margin: 0 -16px;
        padding: 12px 16px;
    }
}

/* List editor: welcome email */
.welcomeBox { border-top: 1px solid #e5e7eb; margin-top: 16px; padding-top: 14px; }
#welcomeFields { margin-top: 8px; }

.signOut { display: block; margin: 8px 0 4px; color: inherit; opacity: 0.8; }

/* Lodge tables: a small bar beside the count (single series, same blue as the chart) */
.lodgeBar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: #2a78d6; margin-right: 8px; vertical-align: middle; min-width: 2px; }

/* Lodge tables: a small bar beside the count (single series, same blue as the chart) */
.lodgeBar { display: inline-block; height: 8px; border-radius: 0 4px 4px 0; background: #2a78d6; margin-right: 8px; vertical-align: middle; min-width: 2px; }
