:root {
    color-scheme: dark;
    --background: #111217;
    --surface: #1b1d25;
    --surface-raised: #262936;
    --border: #343847;
    --foreground: #f5f7fc;
    --muted: #9da4b5;
    --primary: #377dff;
    --primary-hover: #5a96ff;
    --danger: #ff7777;
    --success: #73daa9;
    font-family: InterVariable, Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--foreground)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: var(--background)
}

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

button {
    cursor: pointer
}

button:disabled {
    cursor: not-allowed;
    opacity: .5
}

button,
input,
select,
textarea {
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #171922;
    color: inherit;
    padding: .62rem .72rem
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--primary) 45%, transparent);
    border-color: var(--primary)
}

.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff
}

.primary:hover {
    background: var(--primary-hover)
}

.hidden {
    display: none !important
}

.quiet,
.subtitle {
    color: var(--muted)
}

.error {
    color: var(--danger);
    margin-top: .75rem
}

.success {
    color: var(--success);
    margin-top: .75rem
}

#login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem
}

.login-card {
    width: min(500px, 100%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem
}

.login-logo {
    width: 151px;
    height: 71px;
    object-fit: contain
}

.login-title {
    margin: 1.25rem 0 0;
    font-size: clamp(1.5rem, 4vw, 1.75rem);
    letter-spacing: -.04em
}

.login-copy {
    margin: 0;
    color: var(--muted)
}

.google-button {
    width: min(348px, 100%);
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    background: #fff;
    color: #171717;
    border-color: #d8d8d8;
    font-weight: 600
}

.google-mark {
    width: 1.3rem;
    height: 1.3rem
}

.shell {
    min-height: 100vh;
    padding-left: 248px
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 5;
    width: 248px;
    display: flex;
    flex-direction: column;
    padding: 1.35rem 1rem;
    background: #171921;
    border-right: 1px solid var(--border)
}

.brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    font-weight: 700
}

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

.icon-button {
    margin-left: auto;
    display: none;
    padding: .3rem .55rem;
    font-size: 1.3rem;
    line-height: 1;
    background: transparent
}

.nav {
    display: grid;
    gap: .35rem;
    margin-top: 3rem
}

.nav small {
    color: #6f7687;
    padding: 0 .7rem .5rem;
    font-size: .68rem;
    letter-spacing: .08em
}

.nav a {
    color: var(--muted);
    padding: .7rem;
    text-decoration: none;
    border-radius: 8px
}

.nav a:hover,
.nav a.active {
    color: var(--foreground);
    background: var(--surface-raised)
}

.account {
    display: grid;
    gap: .35rem;
    margin-top: auto;
    padding: .9rem .7rem 0;
    border-top: 1px solid var(--border);
    font-size: .86rem
}

.account button {
    margin-top: .45rem;
    text-align: left;
    background: transparent;
    border: 0;
    padding: .35rem 0;
    color: var(--muted)
}

.main {
    width: 100%;
    max-width: 1550px;
    margin: auto;
    padding: 2rem
}

.topbar {
    display: flex;
    align-items: flex-start;
    gap: 1rem
}

.menu-button {
    display: none;
    margin: .15rem 0 0
}

h1 {
    margin: 0;
    font-size: 1.8rem;
    letter-spacing: -.04em
}

.subtitle {
    margin: .35rem 0 0
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    scroll-margin-top: 1rem
}

.metric,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.1rem
}

.metric b {
    display: block;
    margin-top: .4rem;
    font-size: 1.65rem
}

.metric small {
    color: var(--muted)
}

.panel {
    margin-top: 1rem;
    scroll-margin-top: 1rem
}

.panel-title {
    margin: 0
}

.filters {
    display: grid;
    grid-template-columns: 2fr repeat(4, 1fr) auto;
    gap: .6rem;
    align-items: end
}

.filters label,
.campaign label {
    display: grid;
    gap: .35rem;
    color: var(--muted);
    font-size: .78rem
}

.toolbar,
.actions,
.campaign-intro,
.dialog-heading,
.dialog-actions {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: center
}

.toolbar {
    margin: .9rem 0
}

.table-wrap {
    overflow: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem
}

th {
    color: var(--muted);
    font-weight: 500;
    font-size: .76rem;
    text-align: left
}

td,
th {
    padding: .8rem .6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap
}

.user-row {
    cursor: pointer
}

.user-row:hover {
    background: color-mix(in srgb, var(--primary) 10%, transparent)
}

.pill {
    padding: .22rem .48rem;
    border-radius: 999px;
    background: var(--surface-raised);
    color: var(--muted);
    font-size: .72rem
}

.campaign-intro {
    padding: 1.25rem
}

.detail {
    position: fixed;
    z-index: 7;
    top: 0;
    right: 0;
    width: min(460px, 100vw);
    height: 100vh;
    overflow: auto;
    padding: 1.5rem;
    background: var(--surface);
    box-shadow: -8px 0 24px rgb(0 0 0/.35)
}

.detail-header {
    display: flex;
    gap: 1rem;
    align-items: flex-start
}

.detail-header h2 {
    margin: 0
}

.detail-header .icon-button,
.dialog-heading .icon-button {
    display: block
}

.detail-header p {
    margin: .4rem 0 0
}

.detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .65rem;
    margin: 1.5rem 0
}

.detail-stats div {
    display: grid;
    gap: .25rem;
    padding: .85rem;
    border-radius: 10px;
    background: var(--surface-raised)
}

.detail-stats b {
    font-size: 1.35rem
}

.detail-stats span {
    color: var(--muted);
    font-size: .75rem
}

.detail section {
    padding-top: .6rem;
    border-top: 1px solid var(--border)
}

.detail ul {
    padding-left: 1.1rem
}

code {
    font-family: "Fira Code", ui-monospace, monospace
}

dialog {
    width: min(760px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    color: var(--foreground);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: 0 20px 60px rgb(0 0 0/.55)
}

dialog::backdrop,
.sidebar-backdrop.open {
    background: rgb(0 0 0/.55)
}

.campaign {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem
}

.campaign .dialog-heading,
.campaign textarea,
.campaign p,
.campaign .dialog-actions {
    grid-column: span 2
}

.campaign h2,
.preview-dialog h2 {
    margin: 0
}

.campaign textarea {
    min-height: 220px;
    resize: vertical
}

#email-preview {
    width: 100%;
    height: 360px;
    margin: 1rem 0;
    background: #fff;
    border: 0;
    border-radius: 8px
}

@media(max-width:980px) {
    .shell {
        padding-left: 0
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease
    }

    .sidebar.open {
        transform: translateX(0)
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 4;
        display: none
    }

    .sidebar-backdrop.open {
        display: block
    }

    .brand .icon-button,
    .menu-button {
        display: block
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr)
    }

    .filters {
        grid-template-columns: 1fr 1fr
    }
}

@media(max-width:576px) {
    .main {
        padding: 1rem
    }

    .metrics,
    .filters,
    .campaign {
        grid-template-columns: 1fr
    }

    .campaign .dialog-heading,
    .campaign textarea,
    .campaign p,
    .campaign .dialog-actions {
        grid-column: auto
    }

    .toolbar,
    .campaign-intro {
        align-items: flex-start;
        flex-direction: column
    }

    .actions {
        flex-wrap: wrap
    }

    .detail-stats {
        grid-template-columns: 1fr
    }
}

.toast-container {
    position: fixed;
    inset: 1.25rem 1.25rem auto auto;
    top: 1.25rem;
    right: 1.25rem;
    bottom: auto;
    left: auto;
    margin: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: min(440px, calc(100vw - 2.5rem));
    pointer-events: none;
    background: transparent;
    border: none;
    padding: 0;
    overflow: visible
}

.toast-container:popover-open {
    display: flex;
    inset: 1.25rem 1.25rem auto auto;
    top: 1.25rem;
    right: 1.25rem;
    bottom: auto;
    left: auto;
    margin: 0
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1rem;
    border-radius: 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgb(0 0 0/.5);
    color: var(--foreground);
    font-size: .85rem;
    line-height: 1.4;
    animation: toast-in .2s cubic-bezier(.16, 1, .3, 1);
    word-break: break-word
}

.toast-error {
    border-left: 4px solid var(--danger)
}

.toast-success {
    border-left: 4px solid var(--success)
}

.toast-icon {
    font-size: 1rem;
    line-height: 1.2;
    flex-shrink: 0
}

.toast-error .toast-icon {
    color: var(--danger)
}

.toast-success .toast-icon {
    color: var(--success)
}

.toast-message {
    flex: 1
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 0;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 4px
}

.toast-close:hover {
    color: var(--foreground);
    background: color-mix(in srgb, var(--foreground) 10%, transparent)
}

.toast-leave {
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    transition: opacity .2s ease, transform .2s ease
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(.96)
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1)
    }
}