/* ============================================================
   WaveDocs – Global Stylesheet (Mobile Responsive)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Syne:wght@400;600;700;800&display=swap');

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

html, body {
    height: 100%;
    background: #f0f0f0;
    color: #1a1a2e;
    font-family: 'Syne', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: #7c6ff7;
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

code, pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Impersonation Banner ──────────────────────────────────── */
.impersonation-banner {
    background: #f59e0b;
    color: #1a1a2e;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.impersonation-end-btn {
    background: #1a1a2e;
    color: #fff;
    border: none;
    padding: 4px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

    .impersonation-end-btn:hover {
        background: #333;
    }

/* ── System Message Banners ────────────────────────────────── */
.system-banner {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
}

.system-banner-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.system-banner-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

    .system-banner-text p { display: inline; margin: 0; }
    .system-banner-text ul,
    .system-banner-text ol { margin: 0; padding-left: 18px; }
    .system-banner-text a { color: inherit; text-decoration: underline; }

.system-banner-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    opacity: 0.7;
    color: inherit;
}

    .system-banner-close:hover { opacity: 1; }

.system-banner-info {
    background: #eff6ff;
    color: #1e40af;
    border-bottom: 1px solid #bfdbfe;
}

.system-banner-warning {
    background: #fef3c7;
    color: #92400e;
    border-bottom: 1px solid #fde68a;
}

.system-banner-maintenance {
    background: #fef2f2;
    color: #991b1b;
    border-bottom: 1px solid #fecaca;
}

/* ── Maintenance Page ──────────────────────────────────────── */
.maintenance-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    padding: 24px;
}

.maintenance-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 48px 40px;
    max-width: 560px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.maintenance-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.maintenance-title {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 16px;
}

.maintenance-body {
    font-size: 14px;
    color: #555;
    line-height: 1.7;
    margin-bottom: 24px;
}

    .maintenance-body p { margin: 0 0 8px; }
    .maintenance-body a { color: #7c6ff7; text-decoration: underline; }

.maintenance-eta {
    font-size: 13px;
    color: #888;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px 16px;
    margin-bottom: 24px;
}

.maintenance-logout {
    margin-bottom: 20px;
}

.maintenance-footer {
    font-size: 18px;
    font-weight: 800;
    color: #888;
    margin-top: 8px;
}

@media (max-width: 480px) {
    .maintenance-card {
        padding: 32px 24px;
    }
}

/* ── Mobile Top Bar (hidden on desktop) ────────────────────── */
.mobile-topbar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    z-index: 200;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: #555;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.mobile-topbar-logo {
    font-size: 18px;
    font-weight: 800;
}

/* ── Sidebar Overlay ───────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 150;
}

    @media (max-width: 768px) {
        .sidebar-overlay.open {
            display: block;
        }
    }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: 240px;
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.25s ease;
    z-index: 160;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-wave {
    color: #7c6ff7;
}

.logo-docs {
    color: #1a1a2e;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    min-width: 36px;
    min-height: 36px;
    align-items: center;
    justify-content: center;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px 9px 9px;
    border-radius: 4px;
    color: #555;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    border-left: 3px solid transparent;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-decoration: none;
    min-height: 44px;
}

    .nav-item:hover {
        background: #f8f8f8;
        color: #1a1a2e;
        text-decoration: none;
    }

    .nav-item.active, .nav-item:global(.active) {
        background: #ede9ff;
        color: #7c6ff7;
        border-left-color: #7c6ff7;
    }

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #e0e0e0;
}

.nav-item-logout {
    color: #888;
}

    .nav-item-logout:hover {
        color: #f05560;
        background: rgba(240,85,96,0.08);
    }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    flex: 1;
    overflow-y: auto;
    background: #f0f0f0;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 24px;
    font-weight: 800;
    color: #1a1a2e;
    letter-spacing: -0.5px;
}

.page-sub {
    color: #888;
    margin-top: 4px;
    font-size: 14px;
}

.page-narrow {
    max-width: 720px;
    margin: 0 auto;
}

.page-content {
    padding: 16px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 4px;
    font-family: 'Syne', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
}

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.btn-primary {
    background: #7c6ff7;
    color: #fff;
    border-color: #7c6ff7;
}

    .btn-primary:hover:not(:disabled) {
        background: #6b5ce6;
        border-color: #6b5ce6;
        text-decoration: none;
    }

.btn-outline {
    background: transparent;
    color: #7c6ff7;
    border-color: #7c6ff7;
}

    .btn-outline:hover:not(:disabled) {
        background: rgba(124,111,247,0.08);
        text-decoration: none;
    }

.btn-ghost {
    background: transparent;
    color: #555;
    border-color: transparent;
}

    .btn-ghost:hover:not(:disabled) {
        background: #f8f8f8;
        color: #1a1a2e;
        text-decoration: none;
    }

.btn-outline {
    background: #fff;
    color: #555;
    border: 1px solid #d1d1d1;
}

    .btn-outline:hover:not(:disabled) {
        background: #f8f8f8;
        color: #1a1a2e;
        border-color: #b0b0b0;
    }

.btn-outline.text-danger {
    color: #f05560;
    border-color: #f0556040;
}

    .btn-outline.text-danger:hover:not(:disabled) {
        background: rgba(240,85,96,0.08);
        border-color: #f05560;
    }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    min-height: 32px;
}

.btn-full {
    width: 100%;
}

.btn-danger, .text-danger {
    color: #f05560;
}

.btn-ghost.text-danger:hover {
    background: rgba(240,85,96,0.08);
}

.ml-2 {
    margin-left: 8px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

    .form-group label, .form-label {
        font-size: 12px;
        font-weight: 600;
        color: #555;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

.form-control {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #1a1a2e;
    font-family: 'Syne', sans-serif;
    font-size: 16px; /* prevents iOS auto-zoom */
    padding: 9px 12px;
    width: 100%;
    transition: border-color 0.15s;
    outline: none;
    min-height: 44px;
}

    .form-control:focus {
        border-color: #7c6ff7;
    }

    .form-control::placeholder {
        color: #888;
    }

.form-control-sm {
    padding: 6px 10px;
    font-size: 14px;
    min-height: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-size: 14px;
}

select.form-control {
    cursor: pointer;
}

.code-input {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.card-section {
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

    .card-section:last-child {
        border-bottom: none;
    }

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
}

.section-heading {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-pdf {
    background: rgba(79,158,255,0.15);
    color: #7c6ff7;
}

.badge-email {
    background: rgba(124,92,252,0.15);
    color: #7c5cfc;
}

.badge-plan {
    background: #ede9ff;
    color: #555;
}

.badge-owner {
    background: rgba(240,192,64,0.15);
    color: #f0c040;
}

.badge-active {
    background: rgba(40,200,64,0.15);
    color: #1a9a3a;
}

.badge-invited {
    background: rgba(124,111,247,0.15);
    color: #7c6ff7;
}

.badge-editor {
    background: rgba(56,152,236,0.15);
    color: #2a8ad4;
}

.badge-viewer {
    background: rgba(136,136,136,0.15);
    color: #666;
}

.row-muted {
    opacity: 0.7;
}

.confirm-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-sm {
    font-size: 10px;
    padding: 2px 6px;
}

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-pending {
    background: rgba(240,192,64,0.15);
    color: #f0c040;
}

.status-processing {
    background: rgba(79,158,255,0.12);
    color: #7c6ff7;
}

.status-completed {
    background: rgba(61,214,140,0.12);
    color: #3dd68c;
}

.status-failed {
    background: rgba(240,85,96,0.10);
    color: #f05560;
}

.status-cancelled {
    background: rgba(122,132,153,0.10);
    color: #888;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

    .data-table th {
        padding: 10px 14px;
        text-align: left;
        font-size: 11px;
        font-weight: 700;
        color: #888;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        border-bottom: 1px solid #e0e0e0;
        background: #ffffff;
        white-space: nowrap;
    }

    .data-table td {
        padding: 12px 14px;
        border-bottom: 1px solid #e0e0e0;
        color: #1a1a2e;
        vertical-align: middle;
    }

.table-row {
    transition: background 0.1s;
}

.table-row-clickable {
    cursor: pointer;
}

    .table-row:hover td {
        background: #f8f8f8;
    }

    .table-row:last-child td {
        border-bottom: none;
    }

/* ── Job progress cell (inline mini progress bar in table) ── */
.job-progress-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.job-progress-track {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.job-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c6ff7, #8b5cf6);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.font-medium {
    font-weight: 600;
}

.text-muted {
    color: #888;
}

.text-sm {
    font-size: 12px;
}

.ml-auto {
    margin-left: auto;
}

/* ── Template Grid ─────────────────────────────────────────── */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.template-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

    .template-card:hover {
        border-color: #6b5ce6;
        transform: translateY(-2px);
        box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    }

    .template-card.selected {
        border-color: #7c6ff7;
        background: #faf9ff;
    }

.bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
}

.card-type-badge {
    margin-bottom: 12px;
    padding: 10px;
}

.card-type-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #888;
    margin-bottom: 8px;
}

.card-desc {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 4px;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #e0e0e0;
    padding-top: 14px;
}

/* ── Search / Pagination ───────────────────────────────────── */
.search-bar {
    margin-bottom: 20px;
    max-width: 360px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 0;
    font-size: 13px;
    color: #888;
}

/* ── Stats Grid ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-icon-purple { background: #ede9ff; color: #7c6ff7; }
.stat-icon-blue   { background: #e8f0fe; color: #4285f4; }
.stat-icon-green  { background: #e6f7ed; color: #1a9d56; }
.stat-icon-red    { background: #fde8e8; color: #f05560; }
.stat-icon-orange { background: #fff3e0; color: #e8871e; }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: #1a1a2e;
    letter-spacing: -1px;
}

.stat-value-danger {
    color: #f05560;
}

/* ── Dashboard Grid ────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.dashboard-panel {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px 24px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.panel-heading {
    font-size: 15px;
    font-weight: 700;
}

.text-link {
    font-size: 12px;
    color: #7c6ff7;
}

.list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    font-size: 13px;
}

    .list-item:last-child {
        border-bottom: none;
    }

.list-item-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── PDF Editor Layout ─────────────────────────────────────── */
.editor-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
}

.editor-sidebar {
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-heading {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.sidebar-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
}

    .sidebar-hint code {
        background: #ede9ff;
        padding: 1px 5px;
        border-radius: 3px;
        color: #7c6ff7;
    }

.field-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-chip {
    display: flex;
    align-items: center;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #7c6ff7;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    width: 100%;
    text-align: left;
    min-height: 44px;
}

    .field-chip:hover {
        background: #ede9ff;
        border-color: #6b5ce6;
    }

.editor-main {
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
}

.toolbar-label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
}

.field-count-badge {
    font-size: 11px;
    font-weight: 600;
    color: #7c6ff7;
    background: rgba(124,111,247,0.1);
    padding: 3px 8px;
    border-radius: 100px;
}

.pdf-editor-textarea {
    flex: 1;
    background: #f0f0f0;
    border: none;
    color: #1a1a2e;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.7;
    padding: 24px;
    resize: none;
    outline: none;
    width: 100%;
}

    .pdf-editor-textarea::placeholder {
        color: #888;
    }

/* ── Email Editor Layout ───────────────────────────────────── */
.email-editor-layout {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    height: 100vh;
}

.block-palette {
    background: #ffffff;
    border-right: 1px solid #e0e0e0;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.palette-heading {
    font-size: 11px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.palette-hint {
    font-size: 11px;
    color: #888;
    margin-bottom: 10px;
}

.palette-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 4px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    color: #555;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 6px;
    transition: all 0.15s;
    width: 100%;
    text-align: left;
    min-height: 44px;
}

    .palette-block:hover {
        background: #ede9ff;
        border-color: #6b5ce6;
        color: #1a1a2e;
    }

.palette-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.sidebar-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 14px 0;
}

.email-canvas-wrapper {
    display: flex;
    flex-direction: column;
    background: #f0f0f0;
    overflow: hidden;
}

.canvas-toolbar {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
    gap: 8px;
    flex-wrap: wrap;
}

.preview-tabs {
    display: flex;
    gap: 4px;
}

.preview-tab {
    padding: 5px 14px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #888;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 36px;
}

    .preview-tab:hover {
        color: #1a1a2e;
        background: #f8f8f8;
    }

.preview-tab-active {
    background: #ede9ff;
    color: #1a1a2e;
    border-color: #e0e0e0;
}

.email-canvas {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.canvas-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 14px;
    border: 2px dashed #e0e0e0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
}

.canvas-block {
    position: relative;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.15s;
}

    .canvas-block:hover {
        border-color: #d1d1d1;
    }

.block-selected {
    border-color: #7c6ff7 !important;
}

.block-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    gap: 4px;
    z-index: 10;
}

.canvas-block:hover .block-controls, .block-selected .block-controls {
    display: flex;
}

.block-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: #ede9ff;
    border: 1px solid #e0e0e0;
    color: #555;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

    .block-btn:hover {
        background: #f8f8f8;
        color: #1a1a2e;
    }

    .block-btn:disabled {
        opacity: 0.3;
        cursor: not-allowed;
    }

.block-btn-danger:hover {
    background: rgba(240,85,96,0.15);
    color: #f05560;
}

.block-preview-inner {
    padding: 4px;
}

.preview-frame-wrapper {
    flex: 1;
    overflow: hidden;
    padding: 20px;
}

.preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
    background: #fff;
}

.preview-desktop {
    max-width: 100%;
}

.preview-mobile {
    max-width: 375px;
    margin: 0 auto;
}

/* ── Block Editor Panel ────────────────────────────────────── */
.block-editor-panel {
    background: #ffffff;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
}

.block-editor {
    padding: 16px;
}

.editor-panel-heading {
    font-size: 13px;
    font-weight: 700;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.panel-empty {
    padding: 24px 16px;
    text-align: center;
    color: #888;
    font-size: 13px;
}

/* ── Color Picker / Align ──────────────────────────────────── */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-swatch {
    width: 40px;
    height: 40px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 2px;
    background: #f8f8f8;
    cursor: pointer;
    flex-shrink: 0;
}

.align-select {
    display: flex;
    gap: 4px;
}

.align-btn {
    flex: 1;
    padding: 8px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: capitalize;
    min-height: 36px;
}

    .align-btn:hover {
        background: #ede9ff;
        color: #1a1a2e;
    }

.align-btn-active {
    background: #ede9ff;
    border-color: #7c6ff7;
    color: #7c6ff7;
}

/* ── Team Page ─────────────────────────────────────────────── */
.section-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.invite-form {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background: #f8f8f8;
    border-radius: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    backdrop-filter: blur(2px);
}

.modal {
    background: #ffffff;
    border: 1px solid #d1d1d1;
    border-radius: 12px;
    width: 440px;
    max-width: calc(100vw - 32px);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    flex-shrink: 0;
}

.modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.12s;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #1a1a2e;
}

.modal-body {
    padding: 18px;
    flex: 1;
}

.modal-footer {
    padding: 12px 18px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.modal-md { width: 520px; }

.modal-footer-split {
    padding: 12px 18px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

/* ── Merge field chips ────────────────────────────────────── */
.et-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.et-field-chip {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #7c6ff7;
    background: #ede9ff;
    border: 1px solid #c4b5fd;
    border-radius: 4px;
    padding: 3px 9px;
    user-select: all;
}

.et-save-ok {
    display: inline-flex;
    align-items: center;
    margin-left: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #16a34a;
}

/* ── Auth Shell ────────────────────────────────────────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    position: relative;
    overflow: hidden;
}

.auth-background {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 60% 50% at 20% 40%, rgba(124,111,247,0.10) 0%, transparent 70%), radial-gradient(ellipse 50% 40% at 80% 60%, rgba(124,111,247,0.07) 0%, transparent 70%);
    pointer-events: none;
}

.auth-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 400px;
    padding: 24px;
}

.auth-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-logo {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 24px;
}

.auth-heading {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 6px;
}

.auth-sub {
    font-size: 14px;
    color: #888;
    margin-bottom: 24px;
}

.auth-footer {
    text-align: center;
    font-size: 13px;
    color: #888;
    margin-top: 20px;
}

.auth-legal-links {
    text-align: center;
    font-size: 12px;
    color: #888;
    margin-top: 8px;
}

    .auth-legal-links a {
        color: #888;
    }

        .auth-legal-links a:hover {
            color: #7c6ff7;
        }

.auth-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    color: #888;
}

/* ── Alerts / Toasts ───────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(240,85,96,0.1);
    border: 1px solid rgba(240,85,96,0.3);
    color: #f05560;
}

.alert-success {
    background: rgba(46,184,92,0.1);
    border: 1px solid rgba(46,184,92,0.3);
    color: #1a8a4a;
}

.validation-message {
    color: #f05560;
    font-size: 12px;
    margin-top: 4px;
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 9999;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    animation: slideUp 0.2s ease;
}

.toast-error {
    background: #fee2e2;
    border: 1px solid #f05560;
    color: #f05560;
}

@keyframes slideUp {
    from {
        transform: translateY(12px);
        opacity: 0;
    }

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

/* ── Loading / Empty States ────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: #888;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

.loading-state {
    padding: 40px;
    text-align: center;
    color: #888;
}

.loading-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.skeleton-card {
    height: 160px;
    background: linear-gradient(90deg, #e0e0e0 25%, #f0f0f0 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    border-radius: 12px;
    animation: shimmer 1.5s infinite;
}

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

    100% {
        background-position: -200% 0;
    }
}

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(124,111,247,0.3);
    border-top-color: #7c6ff7;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: #ede9ff;
    border-radius: 3px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: #d1d1d1;
    }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* ── Tablet ≤1024px ────────────────────────────────────────── */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

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

    .email-editor-layout {
        grid-template-columns: 200px 1fr 220px;
    }
}

/* ── Mobile ≤768px ─────────────────────────────────────────── */
@media (max-width: 768px) {

    /* Show topbar */
    .mobile-topbar {
        display: flex;
    }

    .sidebar-close {
        display: flex;
    }

    /* Sidebar becomes slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    }

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

    /* Push content below topbar */
    .app-shell {
        flex-direction: column;
        height: 100dvh;
    }

    .main-content {
        padding-top: 52px;
    }

    /* Page layout */
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 20px;
    }

    .page-title {
        font-size: 20px;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .page-narrow {
        max-width: 100%;
    }

    .search-bar {
        max-width: 100%;
    }

    /* Stats */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-value {
        font-size: 26px;
    }

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .dashboard-panel {
        padding: 16px;
    }

    /* Grids */
    .template-grid {
        grid-template-columns: 1fr;
    }

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

    /* Cards */
    .card-section {
        padding: 14px 16px;
    }

    .card-header-row {
        padding: 14px 16px;
    }

    /* Table: hide lower-priority columns */
    .data-table .col-hide-mobile {
        display: none;
    }

    /* PDF Editor stacks vertically */
    .editor-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: calc(100dvh - 52px);
        margin: -52px 0 0;
    }

    .editor-sidebar {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        max-height: 260px;
        overflow-y: auto;
    }

    .pdf-editor-textarea {
        padding: 16px;
    }

    /* Email editor stacks */
    .email-editor-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: calc(100dvh - 52px);
        margin: -52px 0 0;
    }

    /* Block palette becomes horizontal scroll strip */
    .block-palette {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding: 8px 12px;
        gap: 6px;
        max-height: 60px;
        align-items: center;
    }

    .palette-heading, .palette-hint, .sidebar-divider {
        display: none;
    }

    .palette-block {
        flex-shrink: 0;
        width: auto;
        margin-bottom: 0;
        padding: 6px 10px;
        font-size: 12px;
        min-height: 38px;
    }

    /* Block editor panel: bottom sheet */
    .block-editor-panel {
        border-left: none;
        border-top: 1px solid #e0e0e0;
        max-height: 250px;
    }

    /* Auth */
    .auth-content {
        padding: 16px;
    }

    .auth-card {
        padding: 24px 20px;
    }

    /* Team invite form */
    .invite-form {
        flex-direction: column;
        align-items: stretch;
    }

    /* Toast */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
    }
}

/* ── Small mobile ≤480px ───────────────────────────────────── */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-value {
        font-size: 22px;
    }

    .auth-card {
        padding: 20px 16px;
    }

    .auth-heading {
        font-size: 20px;
    }

    .template-card {
        padding: 14px;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
    }
}
