:root {
    color-scheme: light;
    --bg: #f5f7f6;
    --surface: #ffffff;
    --line: #d9dfdc;
    --text: #161a18;
    --muted: #65716d;
    --teal: #0f8b8d;
    --teal-dark: #0a6264;
    --pink: #d83f6f;
    --yellow: #c58b00;
    --green: #197a4d;
    --red: #bc2f2f;
    --black: #101312;
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
    min-width: 0;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

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

.sidebar {
    background: var(--black);
    color: #fff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--teal);
    color: #fff;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav a,
.button {
    border-radius: var(--radius);
}

.nav a {
    padding: 11px 12px;
    color: #dce4e1;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover,
.nav a.active {
    background: #28302d;
    color: #fff;
}

.logout-form {
    margin-top: auto;
}

.main {
    min-width: 0;
}

.topbar {
    min-height: 112px;
    display: flex;
    align-items: center;
    gap: 18px;
    justify-content: space-between;
    padding: 24px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.login-panel h1,
.section h2 {
    margin: 0;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

.topbar h1 {
    font-size: 2rem;
}

.content {
    padding: 28px 32px 48px;
    display: grid;
    gap: 24px;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--teal-dark);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

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

small {
    display: block;
    overflow-wrap: anywhere;
}

.section,
.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.section {
    padding: 22px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.metric {
    padding: 18px;
}

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

.metric strong {
    display: block;
    font-size: 2rem;
    margin-top: 8px;
}

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.workflow-card {
    display: grid;
    align-content: start;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.workflow-card span {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    display: grid;
    place-items: center;
    background: var(--black);
    color: #fff;
    font-weight: 800;
}

.workflow-card h3,
.workflow-card p {
    margin: 0;
}

.status-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
    gap: 24px;
}

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

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

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 800;
    font: inherit;
    white-space: nowrap;
}

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

.button-primary:hover {
    background: var(--teal-dark);
}

.button-secondary {
    background: #fff;
    color: var(--black);
    border-color: var(--line);
}

.button-ghost {
    background: transparent;
    color: inherit;
    border-color: var(--line);
}

.action-row,
.inline-form,
.inline-upload {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.inline-upload input[type="file"] {
    max-width: 280px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

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

th {
    font-size: 0.86rem;
    color: var(--muted);
}

.status {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: var(--radius);
    background: #edf1ef;
    color: var(--black);
    font-weight: 800;
    font-size: 0.84rem;
    white-space: nowrap;
}

.status-running,
.status-work,
.status-active,
.status-success,
.status-completed,
.status-prepared {
    background: #d9f1e5;
    color: var(--green);
}

.status-preparing {
    background: #deecff;
    color: #1a5f9f;
}

.status-stopped {
    background: #ecefed;
    color: var(--muted);
}

.status-failed,
.status-fail,
.status-error,
.notice-error {
    background: #ffe1e1;
    color: var(--red);
}

.status-queued,
.status-paused,
.status-draft,
.status-new,
.notice-success {
    background: #fff4cc;
    color: var(--yellow);
}

.notice {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

.notice-success {
    border-color: #edd380;
}

.notice-error {
    border-color: #f0a0a0;
}

.code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background: #101312;
    color: #eaf2ef;
    border-radius: var(--radius);
    padding: 14px;
    overflow: auto;
}

.menu-button {
    display: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: stretch;
    background: #eef2f0;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(320px, 460px) 1fr;
}

.login-panel {
    background: var(--surface);
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 18px;
    border-right: 1px solid var(--line);
}

.login-panel h1 {
    font-size: 2.4rem;
}

.login-visual {
    min-height: 100vh;
}

.login-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.template-editor {
    display: grid;
    gap: 18px;
}

.editor-toolbar {
    display: grid;
    gap: 16px;
}

.editor-fields {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.email-builder-shell {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    height: clamp(760px, calc(100vh - 200px), 1040px);
    min-height: 760px;
    position: relative;
}

#email-builder-root {
    height: 100%;
    min-height: 760px;
    position: relative;
    width: 100%;
    overflow: hidden;
}

.email-builder-shell .MuiDrawer-root,
.email-builder-shell .MuiDrawer-paper {
    position: absolute !important;
    height: 100%;
}

.email-builder-shell .MuiDrawer-root {
    pointer-events: none;
    top: 0;
    bottom: 0;
}

.email-builder-shell .MuiDrawer-paper {
    border-color: var(--line);
    pointer-events: auto;
    max-width: none;
}

.email-builder-shell .MuiDrawer-root.MuiDrawer-anchorLeft {
    left: 0;
    right: auto;
}

.email-builder-shell .MuiDrawer-root.MuiDrawer-anchorRight {
    left: auto;
    right: 0;
}

.email-builder-shell .MuiDrawer-paperAnchorLeft {
    left: 0;
    right: auto;
}

.email-builder-shell .MuiDrawer-paperAnchorRight {
    left: auto;
    right: 0;
}

.email-builder-shell .email-builder-samples-drawer {
    left: 0 !important;
    right: auto !important;
}

.email-builder-shell .email-builder-inspector-drawer {
    left: auto !important;
    right: 0 !important;
}

.email-builder-shell .email-builder-samples-drawer .MuiDrawer-paper {
    left: 0 !important;
    right: auto !important;
}

.email-builder-shell .email-builder-inspector-drawer .MuiDrawer-paper {
    left: auto !important;
    right: 0 !important;
}

.email-builder-shell .MuiButtonBase-root,
.email-builder-shell .MuiStack-root,
.email-builder-shell .MuiBox-root {
    min-width: 0;
}

@media (max-width: 1180px) {
    .metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 860px) {
    .app-shell,
    .login-shell,
    .split,
    .grid-two,
    .editor-fields {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        width: min(82vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .topbar,
    .content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .menu-button {
        display: inline-flex;
        border: 1px solid var(--line);
        background: #fff;
        border-radius: var(--radius);
        padding: 9px 12px;
        font: inherit;
        font-weight: 800;
    }

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

    .login-visual {
        min-height: 220px;
        order: -1;
    }

    .login-panel {
        padding: 28px 20px;
        border-right: 0;
    }
}

@media (max-width: 520px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar h1,
    .login-panel h1 {
        font-size: 1.7rem;
    }

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

    .section {
        padding: 16px;
    }

    .email-builder-shell,
    #email-builder-root {
        min-height: 900px;
    }

    .button {
        width: 100%;
    }

    .action-row,
    .inline-form,
    .inline-upload {
        align-items: stretch;
    }
}
