:root {
    --bg: #222a30;
    --card: #2b353c;
    --card-2: #344149;
    --card-3: #1d252a;

    --ink: #f0f4f5;
    --muted: #a9b5bc;
    --muted-2: #7f8d95;

    --line: #43515a;
    --line-soft: #37444c;

    --accent: #22948b;
    --accent-dark: #197a73;
    --accent-soft: #244a48;

    --warn: #e2ad52;
    --danger: #dc7f78;
    --success: #78bf94;

    --shadow: 0 18px 45px rgba(0, 0, 0, .16);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

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

a {
    color: #61c8be;
    text-decoration: none;
}

a:hover {
    color: #7bd8cf;
    text-decoration: underline;
}

.shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}


/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
    background: #172125;
    color: white;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 1px solid #314047;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
}

.topbar-inner {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -.02em;
}

.brand:hover {
    color: white;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav > a:not(.button) {
    color: #dce7e8;
}

.nav > a:not(.button):hover {
    color: white;
}

.inline-form {
    display: inline;
    margin: 0;
}


/* =========================================================
   PAGE STRUCTURE
   ========================================================= */

.main {
    padding: 34px 0 50px;
}

.footer {
    padding: 10px 0 34px;
    color: var(--muted);
    font-size: 13px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-head h1 {
    color: var(--ink);
    font-size: 36px;
    line-height: 1.05;
    letter-spacing: -.035em;
    margin: 4px 0 8px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    font-size: 12px;
    font-weight: 800;
    color: #45b9ae;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 13px;
}

.tiny {
    font-size: 11px;
}

.head-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


/* =========================================================
   BUTTONS
   ========================================================= */

.button {
    appearance: none;
    border: 1px solid var(--line);
    background: var(--card-2);
    color: var(--ink);
    border-radius: 9px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition:
        background .15s ease,
        border-color .15s ease,
        transform .08s ease;
}

.button:hover {
    color: white;
    text-decoration: none;
    background: #3d4b54;
    border-color: #52636d;
}

.button:active {
    transform: translateY(1px);
}

.button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.button-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.button-warn {
    background: #554525;
    border-color: #7e6737;
    color: #f4d999;
}

.button-warn:hover {
    background: #66522b;
    border-color: #947843;
    color: #ffe4a7;
}

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

.button-ghost:hover {
    background: rgba(255, 255, 255, .045);
    color: white;
}

.button-small {
    padding: 7px 10px;
    font-size: 13px;
}

.button-wide {
    width: 100%;
}


/* =========================================================
   GENERIC CARDS
   ========================================================= */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}


/* =========================================================
   DASHBOARD STATS
   ========================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 17px 18px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .10);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 700;
}

.stat strong {
    display: block;
    color: white;
    font-size: 30px;
    letter-spacing: -.04em;
    margin-top: 4px;
}


/* =========================================================
   BATCH LIST
   ========================================================= */

.batch-list {
    display: grid;
    gap: 12px;
}

.batch-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.batch-card > summary {
    list-style: none;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    transition: background .15s ease;
}

.batch-card > summary:hover {
    background: rgba(255, 255, 255, .025);
}

.batch-card > summary::-webkit-details-marker {
    display: none;
}

.batch-summary-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
}

.status-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #7f8c92;
    flex: 0 0 auto;
}

.status-running {
    background: #5fc98c;
    box-shadow: 0 0 0 4px rgba(95, 201, 140, .14);
}

.status-paused {
    background: #e7ae49;
}

.status-completed {
    background: #8c9ba2;
}

.status-draft {
    background: #75838a;
}

.batch-summary-stats {
    display: flex;
    gap: 20px;
    color: var(--muted);
    font-size: 13px;
}

.batch-summary-stats b {
    color: var(--ink);
}

.batch-body {
    border-top: 1px solid var(--line);
    padding: 17px 20px 20px;
    background: rgba(0, 0, 0, .055);
}

.progress {
    height: 7px;
    background: #1c2429;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 18px;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--accent);
}

.batch-meta {
    display: grid;
    grid-template-columns: 2fr repeat(3, 1fr);
    gap: 18px;
    margin-bottom: 18px;
}

.batch-meta span {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin-bottom: 4px;
}

.batch-meta strong {
    color: var(--ink);
    font-size: 14px;
}


/* =========================================================
   PILLS / BADGES
   ========================================================= */

.pill,
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-weight: 700;
    white-space: nowrap;
}

.pill {
    padding: 7px 10px;
    font-size: 12px;
    background: #39464d;
    color: #d9e1e4;
}

.pill-good,
.status-pill-running {
    background: #274b39;
    color: #8bdbab;
}

.status-pill-paused {
    background: #554624;
    color: #f0c96d;
}

.status-pill-completed {
    background: #39454b;
    color: #bdc7cc;
}

.status-pill-draft {
    background: #39444a;
    color: #bdc7cc;
}


/* =========================================================
   LAYOUT
   ========================================================= */

.two-col {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    gap: 20px;
}

.three-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.batch-kpis {
    margin-bottom: 20px;
}

.batch-kpis .card {
    padding: 17px 18px;
}

.batch-kpis span,
.batch-kpis strong {
    display: block;
}

.batch-kpis span {
    color: var(--muted);
}

.batch-kpis strong {
    color: white;
    font-size: 22px;
    margin-top: 4px;
}


/* =========================================================
   FORMS
   ========================================================= */

.form-card,
.side-card {
    padding: 22px;
}

.stack {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 7px;
}

.field label,
.test-send label {
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 10px 11px;
    font: inherit;
    background: var(--card-2);
    color: var(--ink);
    outline: none;
    transition:
        border-color .15s ease,
        background .15s ease,
        box-shadow .15s ease;
}

input::placeholder,
textarea::placeholder {
    color: #85939b;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #48aaa2;
    background: #38464e;
    box-shadow: 0 0 0 3px rgba(42, 161, 152, .12);
}

select {
    color-scheme: dark;
}

textarea {
    resize: vertical;
}

.field input[type=checkbox] {
    width: auto;
    accent-color: var(--accent);
}

.field:has(input[type=checkbox]) {
    display: flex;
    align-items: center;
    gap: 9px;
}

.field:has(input[type=checkbox]) label {
    order: 2;
}

.field:has(input[type=checkbox]) .help {
    order: 3;
}

.help {
    font-size: 12px;
    color: var(--muted);
}

.field-error,
.error-text {
    color: #f09a93;
}

.side-card h2,
.section-head h2 {
    color: var(--ink);
    font-size: 18px;
    margin: 0 0 12px;
}

.side-card h2:not(:first-child) {
    margin-top: 25px;
}


/* =========================================================
   CODE / READ BOXES
   ========================================================= */

pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: #20292f;
    color: #dce5e8;
    border: 1px solid var(--line-soft);
    padding: 12px;
    border-radius: 9px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 12px;
}

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.token-list code {
    background: #244441;
    color: #8edbd3;
    padding: 5px 7px;
    border-radius: 6px;
}

.readbox {
    border: 1px solid var(--line);
    background: #253037;
    border-radius: 9px;
    padding: 11px;
    color: var(--ink);
}

.mail-body {
    min-height: 210px;
    background: var(--card-2);
}


/* =========================================================
   SECTIONS / PREVIEW
   ========================================================= */

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

.preview-mail {
    border: 1px solid var(--line);
    border-radius: 9px;
    margin-bottom: 9px;
    overflow: hidden;
    background: #263138;
}

.preview-mail summary {
    padding: 10px 12px;
    cursor: pointer;
    font-weight: 700;
}

.preview-mail summary:hover {
    background: rgba(255, 255, 255, .025);
}

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

.preview-content pre {
    background: transparent;
    border: 0;
    padding: 8px 0;
    margin-bottom: 0;
}

.test-send {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
    margin-top: 14px;
}


/* =========================================================
   TABLES
   ========================================================= */

.table-card {
    margin-top: 20px;
    overflow: visible;
}

.table-card > .section-head {
    padding: 18px 18px 0;
}

.table-scroll {
    overflow-x: auto;
    scrollbar-color: #55646d #20282e;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    color: var(--ink);
}

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

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .055em;
    color: #aebbc1;
    background: #20292f;
}

tbody tr {
    transition: background .12s ease;
}

tbody tr:hover {
    background: rgba(255, 255, 255, .025);
}

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

.badge {
    padding: 5px 8px;
    font-size: 11px;
    background: #39454b;
    color: #c5cfd3;
}

.badge-sent {
    background: #2a4054;
    color: #91b9e0;
}

.badge-replied {
    background: #274b39;
    color: #91d9ae;
}

.badge-bounced {
    background: #563431;
    color: #ef9d97;
}

.badge-skipped {
    background: #433e3a;
    color: #c9bbb1;
}

.badge-queued {
    background: #39454b;
    color: #b9c5ca;
}

.badge-followup {
    background: #594823;
    color: #f1cb72;
}

.filters {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(4, minmax(130px, 1fr)) auto auto;
    gap: 9px;
    padding: 14px;
    margin-bottom: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.report-table {
    margin-top: 0;
}

.report-table td {
    min-width: 110px;
}

.report-table td:nth-child(2) {
    min-width: 210px;
}

.report-table td:nth-child(9) {
    min-width: 210px;
}

.inline-edit select {
    min-width: 105px;
    padding: 7px;
}

.notes-form {
    display: flex;
    gap: 5px;
}

.notes-form input {
    min-width: 160px;
    padding: 7px;
}

.mini-save {
    border: 1px solid var(--line);
    background: var(--card-2);
    color: var(--ink);
    border-radius: 7px;
    cursor: pointer;
}

.mini-save:hover {
    background: #40505a;
}

.row-muted {
    opacity: .52;
}


/* =========================================================
   ROW MENU
   ========================================================= */

.row-menu {
    position: relative;
}

.row-menu summary {
    cursor: pointer;
    list-style: none;
    font-weight: 900;
    color: var(--muted);
}

.row-menu summary:hover {
    color: white;
}

.menu-pop {
    position: absolute;
    right: 0;
    top: 24px;
    background: #2e3940;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 9px;
    padding: 6px;
    min-width: 160px;
    z-index: 10;
}

.menu-pop button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--ink);
    text-align: left;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
}

.menu-pop button:hover {
    background: rgba(255, 255, 255, .06);
}

.table-note {
    padding: 10px 14px;
    color: var(--muted);
    font-size: 12px;
}


/* =========================================================
   MESSAGES
   ========================================================= */

.messages {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
}

.message {
    padding: 11px 13px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
}

.message.success {
    background: #244536;
    border-color: #3f7256;
    color: #9fdeb6;
}

.message.warning {
    background: #514321;
    border-color: #766231;
    color: #efd083;
}

.message.error {
    background: #543330;
    border-color: #774742;
    color: #f0a19a;
}


/* =========================================================
   EMPTY STATES
   ========================================================= */

.empty {
    padding: 34px;
    text-align: center;
}

.empty h1,
.empty h2,
.empty h3 {
    color: var(--ink);
}

.empty-cell {
    text-align: center;
    padding: 34px;
    color: var(--muted);
}


/* =========================================================
   AUTH
   ========================================================= */

.auth-wrap {
    min-height: 65vh;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(420px, 100%);
    padding: 30px;
}

.auth-card h1 {
    color: var(--ink);
    font-size: 36px;
    margin: 4px 0;
}

.auth-card form p {
    display: grid;
    gap: 6px;
    margin: 0;
}

.auth-card label {
    color: var(--ink);
    font-weight: 700;
    font-size: 13px;
}


/* =========================================================
   PAGINATION
   ========================================================= */

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--line);
    background: rgba(0, 0, 0, .06);
}

.pagination > div {
    display: flex;
    gap: 7px;
}


/* =========================================================
   SCROLLBARS
   ========================================================= */

* {
    scrollbar-width: thin;
    scrollbar-color: #52616a #20282e;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #20282e;
}

::-webkit-scrollbar-thumb {
    background: #52616a;
    border-radius: 10px;
    border: 2px solid #20282e;
}

::-webkit-scrollbar-thumb:hover {
    background: #65757e;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media(max-width:900px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .two-col {
        grid-template-columns: 1fr;
    }

    .batch-summary-stats {
        display: none;
    }

    .batch-meta {
        grid-template-columns: 1fr 1fr;
    }

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

    .filters input[type=search] {
        grid-column: 1/-1;
    }

    .page-head {
        align-items: flex-start;
    }

    .three-col {
        grid-template-columns: 1fr;
    }

    .nav > a:not(.button) {
        display: none;
    }
}

@media(max-width:600px) {
    .shell {
        width: min(100% - 20px, 1240px);
    }

    .main {
        padding-top: 22px;
    }

    .page-head {
        display: grid;
    }

    .page-head h1 {
        font-size: 30px;
    }

    .topbar-inner {
        height: 58px;
    }

    .nav {
        gap: 7px;
    }

    .nav .button {
        padding: 7px 9px;
    }

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

    .stat strong {
        font-size: 25px;
    }

    .batch-card > summary {
        padding: 15px;
    }

    .batch-body {
        padding: 15px;
    }

    .batch-meta {
        grid-template-columns: 1fr;
    }

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

    .filters input[type=search] {
        grid-column: auto;
    }

    .test-send {
        grid-template-columns: 1fr;
    }

    .test-send label {
        display: block;
    }
}