/* ════════════════════════════════════════════════════════
   GHOSTMAIL — Professional UI  v2.0
   Design: Clean dark/light SaaS email client
   Font: Inter (Google Fonts)
════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
    /* Background layers */
    --bg-base: #0b0e14;
    --bg-surface: #111520;
    --bg-elevated: #181d2b;
    --bg-overlay: #1e2438;
    --bg-hover: rgba(255, 255, 255, .04);
    --bg-active: rgba(99, 130, 255, .12);

    /* Borders */
    --border: rgba(255, 255, 255, .07);
    --border-strong: rgba(255, 255, 255, .12);

    /* Text */
    --text-1: #f0f2f8;
    --text-2: rgba(240, 242, 248, .65);
    --text-3: rgba(240, 242, 248, .38);
    --text-invert: #0b0e14;

    /* Brand accent */
    --accent: #6382ff;
    --accent-hover: #7b98ff;
    --accent-dim: rgba(99, 130, 255, .15);
    --accent-glow: 0 0 24px rgba(99, 130, 255, .25);

    /* Status */
    --green: #22c55e;
    --amber: #f59e0b;
    --red: #ef4444;
    --violet: #a855f7;
    --blue: #3b82f6;

    /* Dimensions */
    --sidebar-w: 260px;
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-xs: 0 1px 3px rgba(0, 0, 0, .3);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .5);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);

    /* Motion */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --fast: .15s;
    --base: .22s;
}

[data-theme="light"] {
    --bg-base: #f4f5f9;
    --bg-surface: #ffffff;
    --bg-elevated: #f8f9fc;
    --bg-overlay: #eef0f6;
    --bg-hover: rgba(0, 0, 0, .04);
    --bg-active: rgba(99, 130, 255, .1);

    --border: rgba(0, 0, 0, .08);
    --border-strong: rgba(0, 0, 0, .14);

    --text-1: #111826;
    --text-2: rgba(17, 24, 38, .65);
    --text-3: rgba(17, 24, 38, .4);
    --text-invert: #ffffff;

    --shadow-xs: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, .1);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .14);
}

/* ── Reset ─────────────────────────────────────────────── */
*,
::before,
::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-base);
    color: var(--text-1);
    line-height: 1.5;
    min-height: 100vh;
    transition: background var(--base) var(--ease), color var(--base) var(--ease);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    outline: none
}

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

ul,
ol {
    list-style: none
}

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

/* ── Utility ───────────────────────────────────────────── */
.hidden {
    display: none !important
}

.ml-auto {
    margin-left: auto
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0)
}

/* ════════════════════════════════════════════════════════
   LOGIN SCREEN
════════════════════════════════════════════════════════ */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-base);
    z-index: 9999;
}

.login-noise {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
    opacity: .5;
    pointer-events: none;
}

.login-box {
    position: relative;
    width: 380px;
    max-width: 94vw;
    padding: 44px 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 36px
}

.login-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.logo-mark {
    width: 40px;
    height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: var(--accent-glow);
}

.logo-wordmark {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.4px;
    color: var(--text-1);
}

.login-tagline {
    font-size: 13px;
    color: var(--text-3);
    letter-spacing: .4px
}

.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 8px;
}

.field-wrap {
    position: relative;
    display: flex
}

.field-input {
    width: 100%;
    padding: 12px 48px 12px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-1);
    font-size: 15px;
    transition: border var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.field-input::placeholder {
    color: var(--text-3)
}

.field-action {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    transition: background var(--fast) var(--ease);
}

.field-action:hover {
    background: var(--accent-hover)
}

.field-error {
    min-height: 20px;
    margin-top: 10px;
    font-size: 13px;
    color: var(--red);
    text-align: center;
}

.login-footer {
    margin-top: 28px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-3);
}

/* ════════════════════════════════════════════════════════
   TOAST
════════════════════════════════════════════════════════ */
#toast-rack {
    position: fixed;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 8888;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    min-width: 220px;
    max-width: 360px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 13.5px;
    color: var(--text-1);
    animation: toastIn var(--base) var(--ease);
    pointer-events: auto;
}

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

.toast.error {
    border-left: 3px solid var(--red)
}

.toast.info {
    border-left: 3px solid var(--accent)
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0
}

.toast.success .toast-dot {
    background: var(--green)
}

.toast.error .toast-dot {
    background: var(--red)
}

.toast.info .toast-dot {
    background: var(--accent)
}

@keyframes toastIn {
    from {
        transform: translateX(110%);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

@keyframes toastOut {
    to {
        transform: translateX(110%);
        opacity: 0
    }
}

/* ════════════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════════════ */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--base) var(--ease), opacity var(--base) var(--ease), transform var(--base) var(--ease);
}

.app.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}

.sidebar-top {
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 2px;
}

.brand-icon {
    font-size: 22px;
    line-height: 1
}

.brand-name {
    font-weight: 700;
    font-size: 15.5px;
    letter-spacing: -.3px;
    color: var(--text-1)
}

/* New alias button */
.new-alias-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 600;
    transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
    box-shadow: var(--accent-glow);
}

.new-alias-btn:hover {
    background: var(--accent-hover)
}

.new-alias-btn svg {
    flex-shrink: 0
}

/* Active alias card */
.active-alias-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.aac-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-3);
    margin-bottom: 6px
}

.aac-email {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    color: var(--accent);
    cursor: pointer;
    transition: border-color var(--fast) var(--ease);
    min-width: 0;
}

.aac-email:hover {
    border-color: var(--accent)
}

#current-email-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1
}

.copy-icon {
    flex-shrink: 0;
    opacity: .5;
    transition: opacity var(--fast)
}

.aac-email:hover .copy-icon {
    opacity: 1
}

.aac-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-strong);
}
.aac-avatar.lg {
    width: 56px;
    height: 56px;
    font-size: 20px;
}
.aac-avatar img,
.alias-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.aac-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
}

.aac-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 8px;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
    white-space: nowrap;
}

.aac-btn:hover {
    background: var(--bg-active);
    color: var(--accent);
    border-color: var(--accent)
}

/* Section */
.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 0 14px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 2px 6px;
}

.section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-3)
}

.section-badge {
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
}

/* Alias list */
.alias-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 8px
}

.empty-aliases {
    font-size: 13px;
    color: var(--text-3);
    padding: 12px 4px;
    text-align: center
}

.alias-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--fast) var(--ease);
    position: relative;
}

.alias-item:hover {
    background: var(--bg-hover)
}

.alias-item.active {
    background: var(--bg-active)
}

.alias-item.active .alias-item-name {
    color: var(--accent)
}

.alias-item-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.alias-item-info {
    flex: 1;
    min-width: 0
}

.alias-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alias-item-email {
    font-size: 11px;
    color: var(--text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alias-item-del {
    opacity: 0;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: var(--red);
    transition: opacity var(--fast), background var(--fast);
}

.alias-item:hover .alias-item-del {
    opacity: 1
}

.alias-item-del:hover {
    background: rgba(239, 68, 68, .12)
}

/* Nav */
.sidebar-nav {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border)
}

.nav-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
    position: relative;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1)
}

.nav-btn.active {
    background: var(--bg-active);
    color: var(--accent);
    font-weight: 600
}

.nav-btn svg {
    flex-shrink: 0;
    opacity: .7
}

.nav-btn.active svg {
    opacity: 1
}

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    color: #fff;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-badge:empty {
    display: none
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px
}

.compose-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
}

.compose-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-active)
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-3);
    transition: all var(--fast) var(--ease);
}

.logout-btn:hover {
    color: var(--red);
    background: rgba(239, 68, 68, .08)
}

/* ── Main ──────────────────────────────────────────────── */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-base);
}

/* Topbar */
.topbar {
    height: 54px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.sidebar-toggle {
    display: flex;
}

.topbar-title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--text-1);
    flex-shrink: 0;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto
}

/* Search */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-3);
    pointer-events: none;
}

.search-input {
    width: 240px;
    height: 36px;
    padding: 0 14px 0 34px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-1);
    transition: all var(--fast) var(--ease);
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
    width: 280px;
}

.search-input::placeholder {
    color: var(--text-3)
}

.search-input::-webkit-search-cancel-button {
    display: none
}

/* Icon button */
.icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1)
}

/* ── Views ─────────────────────────────────────────────── */
.view {
    flex: 1;
    overflow: hidden;
    display: none;
    flex-direction: column;
}

.view.active {
    display: flex
}

/* ── Inbox ─────────────────────────────────────────────── */
.inbox-pane {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Email list */
.email-list-pane {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-surface);
    overflow: hidden;
}

.list-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.list-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-3)
}

.text-btn {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px
}

.text-btn:hover {
    background: var(--accent-dim)
}

#email-items {
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent
}

.email-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--fast) var(--ease);
    position: relative;
}

.email-row:hover {
    background: var(--bg-hover)
}

.email-row.selected {
    background: var(--bg-active)
}

.email-row.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.email-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px
}

.email-sender {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.email-row.unread .email-sender {
    font-weight: 700
}

.email-date {
    font-size: 11.5px;
    color: var(--text-3);
    flex-shrink: 0
}

.email-subject {
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-row.unread .email-subject {
    color: var(--text-1);
    font-weight: 500
}

.email-snippet {
    font-size: 12px;
    color: var(--text-3);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Skeleton */
.list-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0
}

.sk-item {
    height: 74px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    from {
        background-position: 200% 0
    }

    to {
        background-position: -200% 0
    }
}

/* Empty state */
.list-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px;
    text-align: center;
}

.empty-icon {
    color: var(--text-3);
    margin-bottom: 4px
}

.list-empty p {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-2)
}

.list-empty span {
    font-size: 13px;
    color: var(--text-3);
    max-width: 220px
}

/* Email view pane */
.email-view-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
    overflow: hidden;
}

.view-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-3);
}

.placeholder-icon {
    opacity: .35
}

.view-placeholder p {
    font-size: 15px;
    font-weight: 500
}

/* Email content */
.email-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 36px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.ec-header {
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.ec-subject {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--text-1);
    margin-bottom: 16px;
    line-height: 1.3;
}

.ec-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ec-meta-row {
    display: flex;
    gap: 8px;
    font-size: 13px
}

.ec-meta-lbl {
    color: var(--text-3);
    font-weight: 600;
    width: 44px;
    flex-shrink: 0
}

.ec-meta-val {
    color: var(--text-2)
}

.ec-body {
    font-size: 14.5px;
    line-height: 1.75;
    color: var(--text-2);
    overflow-wrap: break-word;
}

/* email HTML content isolation */
.email-iframe-wrap {
    background: #fff;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-top: 8px;
}

.email-iframe-wrap iframe {
    width: 100%;
    border: none;
    min-height: 200px;
    display: block;
}

.ec-attachments {
    margin-top: 24px
}

.ec-attachments h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 10px
}

.attachment-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
}

.attachment-chip:hover {
    border-color: var(--accent);
    color: var(--accent)
}

.attachment-chip-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.attachment-chip-size {
    color: var(--text-3)
}

.ec-actions {
    display: flex;
    gap: 8px;
    padding: 16px 36px;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    flex-shrink: 0;
}

/* ── Stats ─────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px;
}

.stat-tile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.stat-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm)
}

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue {
    background: rgba(59, 130, 246, .12);
    color: var(--blue)
}

.stat-icon.green {
    background: rgba(34, 197, 94, .12);
    color: var(--green)
}

.stat-icon.violet {
    background: rgba(168, 85, 247, .12);
    color: var(--violet)
}

.stat-icon.amber {
    background: rgba(245, 158, 11, .12);
    color: var(--amber)
}

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 2px
}

.stat-val {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--text-1)
}

.stat-name {
    font-size: 12px;
    color: var(--text-3)
}

.stats-panel {
    margin: 0 24px 24px;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 16px
}

.top-senders {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.sender-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.sender-email {
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.sender-count {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--accent-dim);
    color: var(--accent);
    flex-shrink: 0;
}

/* ── Templates ─────────────────────────────────────────── */
.view {
    overflow-y: auto
}

.view-toolbar {
    padding: 20px 24px;
    display: flex;
    gap: 10px;
    flex-shrink: 0
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    padding: 0 24px 24px;
}

.template-card {
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--fast) var(--ease);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.template-card:hover {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent)
}

.template-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1)
}

.template-subject {
    font-size: 13px;
    color: var(--accent)
}

.template-preview {
    font-size: 12.5px;
    color: var(--text-3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px
}

/* ── Settings ──────────────────────────────────────────── */
.settings-cols {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 24px;
}

.settings-card {
    padding: 22px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.card-heading {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-1);
    margin-bottom: 16px
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-2);
}

.select {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
}

.select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim)
}

.select option {
    background: var(--bg-elevated)
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute
}

.toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: var(--border-strong);
    cursor: pointer;
    transition: background var(--base) var(--ease);
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--base) var(--ease);
}

.toggle input:checked+.toggle-track {
    background: var(--accent)
}

.toggle input:checked+.toggle-track::after {
    transform: translateX(18px)
}

/* Shortcuts */
.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 8px
}

.shortcut {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-2);
}

kbd {
    padding: 2px 7px;
    border-radius: 5px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    font-size: 11.5px;
    font-family: inherit;
    color: var(--text-2);
}

/* Sessions */
.sessions-list {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.session-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--text-2);
}

.session-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0
}

/* ════════════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 7000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(6px);
}

.modal-box {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 520px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    animation: modalIn var(--base) var(--ease);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box.modal-sm {
    max-width: 380px
}

.modal-box.modal-lg {
    max-width: 640px
}

@keyframes modalIn {
    from {
        transform: translateY(16px);
        opacity: 0
    }

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

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-1)
}

.modal-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-3);
    transition: all var(--fast) var(--ease);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-1)
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px
}

.modal-body.center {
    align-items: center
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* Tabs */
.tab-row {
    display: flex;
    gap: 2px;
    padding: 4px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    width: fit-content
}

.tab {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
}

.tab.active {
    background: var(--bg-surface);
    color: var(--text-1);
    box-shadow: var(--shadow-xs)
}

.tab-panel {
    display: none;
    flex-direction: column;
    gap: 12px
}

.tab-panel.active {
    display: flex
}

.tab-desc {
    font-size: 13px;
    color: var(--text-3)
}

/* Address preview */
.preview-address {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 13px;
}

.preview-local {
    color: var(--accent);
    font-weight: 600
}

.preview-at {
    color: var(--text-3);
    margin: 0 2px
}

.preview-domain {
    color: var(--text-2)
}

/* Combo input */
.combo-input {
    display: flex;
    align-items: center;
    gap: 0
}

.combo-input .field-input {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    padding-right: 14px
}

.combo-suffix {
    padding: 0 12px;
    height: 42px;
    display: flex;
    align-items: center;
    background: var(--bg-overlay);
    border: 1px solid var(--border-strong);
    border-left: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-size: 12.5px;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Field groups */
.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px
}

.field-textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 14px;
    resize: vertical;
    min-height: 80px;
    transition: border var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
    line-height: 1.6;
}

.field-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim)
}

.field-textarea::placeholder {
    color: var(--text-3)
}

/* QR */
.qr-box {
    padding: 16px;
    background: #fff;
    border-radius: var(--radius);
    display: inline-block
}

.qr-box img {
    width: 200px;
    height: 200px;
    display: block
}

.qr-label {
    font-size: 13px;
    color: var(--text-3);
    margin-top: 12px;
    font-family: monospace
}

/* ── Buttons ───────────────────────────────────────────── */
.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.primary-btn:hover {
    background: var(--accent-hover);
    box-shadow: var(--accent-glow)
}

.primary-btn:active {
    transform: scale(.98)
}

.primary-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    box-shadow: none
}

.primary-btn.sm {
    padding: 8px 14px;
    font-size: 13px
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
}

.secondary-btn:hover {
    background: var(--bg-hover);
    color: var(--text-1)
}

.icon-sm-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    transition: all var(--fast) var(--ease);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
}

.icon-sm-btn:hover {
    border-color: var(--accent);
    color: var(--accent)
}

.danger-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    background: rgba(239, 68, 68, .1);
    border: 1px solid rgba(239, 68, 68, .25);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--red);
    transition: all var(--fast) var(--ease);
}

.danger-btn:hover {
    background: rgba(239, 68, 68, .18)
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .email-view-pane {
        display: none
    }

    .email-list-pane {
        width: 100%
    }

    .email-view-pane.open {
        display: flex;
        position: fixed;
        inset: 0;
        z-index: 500;
        background: var(--bg-base)
    }
}

@media (max-width: 680px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 600;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

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

    .sidebar-toggle {
        display: flex
    }

    .topbar-title {
        font-size: 15px
    }

    .search-input {
        width: 160px
    }

    .search-input:focus {
        width: 200px
    }

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

@media (max-width: 420px) {
    .login-box {
        padding: 32px 24px
    }

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

    .settings-cols {
        grid-template-columns: 1fr
    }
}

/* ── Scrollbar polish ──────────────────────────────────── */
::-webkit-scrollbar {
    width: 5px;
    height: 5px
}

::-webkit-scrollbar-track {
    background: transparent
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 20px
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-3)
}

/* ── Animations ────────────────────────────────────────── */
@keyframes spin {
    from {
        transform: rotate(0deg)
    }

    to {
        transform: rotate(360deg)
    }
}

.spinning {
    animation: spin .5s linear infinite
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0)
    }

    20%,
    60% {
        transform: translateX(-8px)
    }

    40%,
    80% {
        transform: translateX(8px)
    }
}


/* ════════════════════════════════════════════════════════
   BULK MARKETING & CAMPAIGNS UI
   ════════════════════════════════════════════════════════ */
#campaigns-view,
#automations-view,
#contacts-view,
#dns-view {
    padding: 24px 28px;
}

.mkt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.mkt-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-1);
    margin: 0 0 4px 0;
}
.mkt-sub {
    font-size: 13px;
    color: var(--text-2);
    margin: 0;
}
.mkt-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.mkt-kpi {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mkt-kpi-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-2);
}
.mkt-kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
}
.mkt-kpi-sub {
    font-size: 11px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
}
.mkt-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.mkt-table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.mkt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.mkt-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-3);
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    white-space: nowrap;
}
.mkt-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-1);
    vertical-align: middle;
}
.mkt-table tr:last-child td {
    border-bottom: none;
}
.mkt-table tr:hover td {
    background: var(--bg-hover);
}
.mkt-empty {
    text-align: center;
    color: var(--text-3) !important;
    padding: 32px 16px !important;
}
.mkt-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.mkt-badge.ok       { background: rgba(34, 197, 94, .14);  color: #22c55e; }
.mkt-badge.info     { background: rgba(59, 130, 246, .14); color: #3b82f6; }
.mkt-badge.warn     { background: rgba(245, 158, 11, .14); color: #f59e0b; }
.mkt-badge.bad      { background: rgba(239, 68, 68, .14);  color: #ef4444; }
.mkt-badge.neutral  { background: var(--bg-elevated);      color: var(--text-2); border: 1px solid var(--border); }

.mkt-progress {
    width: 90px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 4px;
}
.mkt-progress-fill {
    height: 100%;
    background: var(--accent);
    transition: width .25s ease;
}

.modal-xl {
    max-width: 920px !important;
    width: 94vw !important;
}
.modal-full {
    max-width: 1180px !important;
    width: 96vw !important;
}
.mkt-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.mkt-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.mkt-summary-bar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-2);
}
.mkt-builder-grid {
    display: grid;
    grid-template-columns: 1.05fr .95fr;
    gap: 18px;
    max-height: 74vh;
    overflow-y: auto;
}
.mkt-builder-left, .mkt-builder-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.mkt-tag-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-3);
}
.mkt-tag {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-2);
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 11px;
    font-family: monospace;
    cursor: pointer;
}
.mkt-tag:hover {
    border-color: var(--accent);
    color: var(--text-1);
}
.mkt-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.mkt-preview-frame-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #f3f4f6;
    height: 360px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}
#camp-preview-iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
    transition: width .2s ease;
}
.mkt-spam-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
}
.mkt-spam-list {
    margin: 0;
    padding-left: 16px;
    font-size: 12px;
    color: var(--text-2);
    display: grid;
    gap: 3px;
}
@media (max-width: 900px) {
    .mkt-builder-grid, .mkt-grid-2, .mkt-grid-3 {
        grid-template-columns: 1fr;
    }
}
