/* ══════════════════════════════════════════════════════════════════════════
   MailFlow — Premium Minimal UI
   Font: SF Pro (system stack) + Inter fallback
   ══════════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* SF Pro system stack — loads natively on Apple devices, falls back to Inter */
:root {
    /* Typography */
    --font-sans: "SF Pro Display", "SF Pro Text", -apple-system, BlinkMacSystemFont,
        "Inter", "Helvetica Neue", Arial, sans-serif;

    /* Backgrounds — Deep Indigo base */
    --bg: #1e1b2e;                  /* Deep indigo-black */
    --bg-surface: #ffffff;
    --bg-subtle: #f7f7f9;

    /* Text Colors */
    --text-1: #1c1933;
    --text-2: #6c6a7a;
    --text-3: #a09daf;
    --text-inv: #ffffff;

    /* Accent — Full Yellow */
    --accent: #E5A500;
    --accent-hover: #cc9200;
    --accent-dim: rgba(229, 165, 0, 0.10);

    /* Sidebar — Deep Indigo */
    --sidebar-w:   224px;
    --sidebar-bg:  #1e1b2e;
    --sidebar-txt: #8a87a0;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-act-bg: var(--accent);
    --sidebar-act-txt: #ffffff;

    /* Borders */
    --border: #e8e7ed;
    --border-md: #d4d3dc;

    /* Radii */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;
    --r-xl: 20px;
    --r-full: 9999px;

    /* Semantic Colors */
    --success-bg: #f0fdf4;
    --success-fg: #166534;
    --success-bd: #bbf7d0;
    --error-bg: #fef2f2;
    --error-fg: #b91c1c;
    --error-bd: #fecaca;
    --warn-bg: #fffbeb;
    --warn-fg: #92400e;
    --warn-bd: #fde68a;
    --info-bg: #eef2ff;
    --info-fg: #4338ca;
    --info-bd: #c7d2fe;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --t-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --t-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --t-slow: 0.40s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset ─────────────────────────────────────────────────────────────── */

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

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "kern" 1, "liga" 1;
}

#app {
    width: 100%;
    min-height: 100vh;
}

/* ─── Login ──────────────────────────────────────────────────────────────── */

.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #ffffff;
}

.login-card {
    background: var(--bg-surface);
    width: 100%;
    max-width: 400px;
    padding: 2.75rem 2.5rem;
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    margin: 1rem;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

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

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

.nav-icon i {
    width: 16px;
    height: 16px;
    stroke-width: 1.8; /* Leaner, more premium stroke */
}

.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.75rem;
}

.login-logo-icon {
    width: 36px;
    height: 36px;
    background: var(--text-1);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #ffffff;
}

.login-logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.02em;
}

.login-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.025em;
    color: var(--text-1);
    margin-bottom: 0.375rem;
}

.login-card .subtitle {
    font-size: 0.875rem;
    color: var(--text-2);
    text-align: center;
    margin-bottom: 2rem;
    font-weight: 400;
}

/* ─── Shell ──────────────────────────────────────────────────────────────── */

#shell {
    display: flex;
    min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

#sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    overflow: hidden;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    transition: width var(--t-base), min-width var(--t-base);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 1.5rem 1.25rem 1.125rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    color: var(--sidebar-txt);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: all var(--t-fast);
}

.sidebar-collapse-btn:hover {
    opacity: 1;
    color: #fff;
    transform: scale(1.05);
}

.sidebar-logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: var(--sidebar-bg);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-icon i {
    width: 14px;
    height: 14px;
}

.sidebar-app-name {
    font-size: 1rem; /* Slightly smaller for premium feel */
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.04em;
    font-family: inherit;
}

.sidebar-nav {
    flex: 1;
    padding: 0.875rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.125rem; /* Tighter padding for premium pill feel */
    border-radius: var(--r-sm);
    color: var(--sidebar-txt);
    text-decoration: none;
    font-size: 0.8125rem; /* Smaller text for premium feel (13px) */
    font-weight: 500;
    transition: all var(--t-base);
    cursor: pointer;
    margin-bottom: 0.5rem; /* Better spacing between items */
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
    transform: translateX(4px); /* Interactive slide effect */
}

.nav-item.active {
    background: var(--sidebar-act-bg) !important;
    color: var(--sidebar-act-txt) !important;
    font-weight: 700;
    transform: translateX(4px);
}

.nav-item.active .nav-icon {
    color: var(--sidebar-act-txt) !important;
    opacity: 1;
}

.nav-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
    width: 1.125rem;
    text-align: center;
    opacity: 0.8;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: var(--accent);
    color: var(--sidebar-bg); /* Dark text on lime badge for high contrast */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--sidebar-txt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    width: 100%;
    padding: 0.625rem;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: var(--r-sm);
    color: var(--sidebar-txt);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--t-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.logout-btn i {
    width: 14px;
    height: 14px;
}

.logout-btn:hover {
    border-color: rgba(255, 255, 255, 0.20);
    color: #fff;
    background: var(--sidebar-hover);
}

/* ─── Sidebar Collapsed State ────────────────────────────────────────────── */

body.sidebar-collapsed {
    --sidebar-w: 80px;
}

body.sidebar-collapsed .sidebar-app-name,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .user-name,
body.sidebar-collapsed .logout-text {
    display: none;
}

body.sidebar-collapsed .sidebar-header {
    padding: 1.5rem 0.5rem 1.125rem;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-header > div {
    display: none !important; /* Hide the logo block entirely in collapsed mode to avoid crowding */
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 0.625rem 0;
}

body.sidebar-collapsed .nav-icon {
    margin: 0;
}

body.sidebar-collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
}

body.sidebar-collapsed .sidebar-user {
    justify-content: center;
}

.collapse-icon {
    transition: transform var(--t-base);
}

body.sidebar-collapsed .collapse-icon {
    transform: rotate(180deg);
}

/* ─── Main Content ───────────────────────────────────────────────────────── */

#main-content {
    margin: 1.25rem 1.25rem 1.25rem var(--sidebar-w);
    flex: 1;
    min-height: calc(100vh - 2.5rem);
    background: var(--bg-surface);
    border-radius: var(--r-xl);
    overflow: hidden; /* Prevent scrolls on shell */
    display: flex;
    flex-direction: column;
    transition: margin var(--t-base);
}

.shell-view {
    flex: 1;
    overflow-y: auto; /* Scroll only inside the view container */
}

/* ─── Animation ──────────────────────────────────────────────────────────── */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* ─── Page Layout ────────────────────────────────────────────────────────── */

.page-container {
    width: 100%;
    max-width: none; /* No width cap — fill the full available space */
    padding: 16px 24px; /* Reduced from 24px 32px */
    margin: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    margin-bottom: 0.5rem; /* Tightening */
    gap: 0;
    flex-direction: column;
    animation: fadeIn 0.3s var(--t-base) both;
}

.page-title {
    font-size: 1.25rem; /* Reduced from 1.5rem */
    font-weight: 800;
    color: var(--text-1);
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.page-subtitle {
    font-size: 0.8125rem; /* Reduced from 0.9rem */
    margin-top: 0.125rem;
    font-weight: 400;
    letter-spacing: -0.005em;
}

/* ─── Form Elements ──────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 0.875rem; /* Ultra compact for one-screen view */
}

.form-group label,
.settings-label,
.form-group > label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.form-group input,
.form-input,
.form-textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-1);
    background: #fcfcfc;
    transition: all var(--t-fast);
    -webkit-appearance: none;
    appearance: none;
    line-height: 1.4;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 0.875rem;
    color: var(--text-3);
    width: 18px;
    height: 18px;
    pointer-events: none;
}

.form-input.has-icon {
    padding-left: 2.75rem;
}

.password-toggle {
    position: absolute;
    right: 0.875rem;
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color var(--t-fast);
}

.password-toggle:hover {
    color: var(--text-1);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.form-group input::placeholder,
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-3);
    font-weight: 400;
}

.form-group input:hover,
.form-input:hover,
.form-textarea:hover {
    border-color: rgba(0, 0, 0, 0.20);
}

.form-group input:focus,
.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.form-textarea {
    resize: none;
    flex: 1; /* Allow textarea to grow and balance the left column */
    min-height: 80px; /* Reduced from 100px */
    line-height: 1.5;
}

/* WYSIWYG Editor */
.wysiwyg-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fcfcfc;
    overflow: hidden;
    transition: all var(--t-fast);
    display: flex;
    flex-direction: column;
    flex: 1;
}
.wysiwyg-container:focus-within {
    border-color: var(--accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}
.wysiwyg-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.wysiwyg-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 6px;
    color: var(--text-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
}
.wysiwyg-btn:hover {
    background: var(--bg-subtle);
    color: var(--accent);
}
.wysiwyg-btn i, .wysiwyg-btn svg {
    width: 15px;
    height: 15px;
    stroke-width: 2.2px;
}
.wysiwyg-select {
    padding: 0.35rem;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    cursor: pointer;
    outline: none;
    font-weight: 500;
}
.wysiwyg-select:hover {
    color: var(--text-1);
}
.wysiwyg-separator {
    width: 1px;
    height: 1rem;
    background: var(--border);
    margin: 0 0.125rem;
}
.wysiwyg-editor {
    flex: 1;
    min-height: 110px; /* Reduced from 140px */
    padding: 0.875rem;
    outline: none;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    color: var(--text-1);
    overflow-y: auto;
}
.wysiwyg-editor:empty:before {
    content: attr(placeholder);
    color: var(--text-3);
    pointer-events: none;
    display: block; 
}

/* Custom select arrow */
select.form-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.6875rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    border: 1.5px solid transparent;
    border-radius: var(--r-md);
    cursor: pointer;
    transition: all var(--t-fast);
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08); /* Neutral subtle shadow, no yellow glow */
    font-weight: 700;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); /* Increase neutral depth on hover */
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.btn-accent {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-accent:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(136, 218, 28, 0.35);
    /* Updated glow with lime accent */
}

.btn-sm {
    width: auto;
    padding: 0.5rem 0.9375rem;
    font-size: 0.8125rem;
    border-radius: var(--r-sm);
}

.btn-outline {
    background: transparent;
    color: var(--text-1);
    border-color: var(--border-md);
}

.btn-outline:hover {
    background: var(--bg-subtle);
    border-color: var(--text-2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    color: var(--text-1);
}

.btn-danger-outline {
    background: transparent;
    color: var(--error-fg);
    border-color: var(--error-bd);
}

.btn-danger-outline:hover {
    background: var(--error-bg);
    border-color: var(--error-fg);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(190, 18, 60, 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-2);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--accent-dim);
    /* Subtle lime background on ghost hover */
    color: var(--accent-hover);
}

/* ─── Dashboard — Flat Linear/Stripe Layout ──────────────────────────────── */

.dash-header {
    display: flex;
    align-items: center; /* Center vertically for density */
    justify-content: space-between;
    margin-bottom: 0.75rem; /* Reduced from 1rem */
    gap: 1rem;
}

.dash-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.dash-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    align-items: stretch;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    width: 100%;
}

.dash-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform var(--t-base), box-shadow var(--t-base);
}

.dash-card:hover {
    box-shadow: var(--shadow-md);
}

.dash-card-header {
    padding: 0.5rem 0.875rem; /* Reduced from 0.75rem 1rem */
    background: #fafafb;
    border-bottom: 1px solid var(--border);
}

.dash-card-body {
    padding: 0.75rem; /* Reduced from 1rem */
}

/* ─── Upload Zones ────────────────────────────────────────────────────────── */

.upload-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem; /* Reduced from 1.5rem 1rem */
    background: #fffdf9;
    border: 2px dashed #f1e0c5;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--t-base);
    text-align: center;
}

.upload-drop-zone:hover {
    background: #fff9f0;
    border-color: #d4881a;
    transform: translateY(-2px);
}

.upload-drop-zone--sm {
    padding: 0.875rem 1rem;
    flex-direction: row;
    gap: 0.625rem;
    border-width: 1.5px;
}

.upload-zone-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-1);
    margin: 0.5rem 0 0.125rem;
}

.upload-zone-sub {
    font-size: 0.75rem;
    color: var(--text-3);
    font-weight: 500;
}

/* ─── File Pills & Stats ─────────────────────────────────────────────────── */

.file-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.75rem;
}

.file-pill-icon {
    width: 32px;
    height: 32px;
    background: #fefce8;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-pill-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.file-pill-name {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-pill-count {
    font-size: 0.75rem;
    color: var(--text-3);
    font-weight: 500;
}

.file-pill-remove {
    background: #f1f5f9;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #475569;
    transition: all var(--t-fast);
}

.file-pill-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

.file-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.file-stat-box {
    padding: 0.625rem 0.875rem;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.file-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.file-stat-val {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-1);
}

.file-stat-ok {
    color: #10b981;
}

/* ─── Timing Toggle ─────────────────────────────────────────────────────── */

.timing-toggle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.timing-toggle-opt {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #fcfcfd;
    border: 1.5px solid #edf0f5;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-2);
    transition: all var(--t-fast);
    user-select: none;
}

.timing-toggle-opt:hover {
    border-color: #d4d3dc;
    background: #fff;
}

.timing-toggle-opt.active {
    background: #fff;
    border-color: #d4881a;
    color: var(--text-1);
    box-shadow: 0 4px 12px rgba(212, 136, 26, 0.08);
}

.timing-radio-ring {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--t-fast);
}

.timing-toggle-opt.active .timing-radio-ring {
    border-color: #d4881a;
}

.timing-radio-fill {
    width: 10px;
    height: 10px;
    background: #d4881a;
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.timing-toggle-opt.active .timing-radio-fill {
    transform: scale(1);
}

.send-summary-box {
    margin-top: 1.25rem;
    padding: 0.875rem 1.125rem;
    background: #fffbf0;
    border: 1px solid #f9ebc8;
    border-radius: 10px;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

#send-summary-text {
    font-size: 0.75rem;
    color: #4b3a1d;
    line-height: 1.5;
    font-weight: 500;
}

#send-summary-text strong {
    font-weight: 800;
    color: #000;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */

@keyframes mf-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.dash-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Reduced from 0.75rem */
    height: 100%;
}

.dash-col .form-group:has(> .form-textarea),
.dash-col .form-group:has(> .wysiwyg-container) {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.timing-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.125rem;
}

/* Right column — subtle card differentiation */
.dash-col:last-child {
    background: #f8f9fa;
    padding: 1rem; /* Reduced from 1.25rem */
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.06);
    box-sizing: border-box;
}

.timing-options label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-2);
}

/* Remove old compose-card box entirely */
.compose-card,
.compose-main,
.compose-sidebar,
.compose-row,
.compose-header-grid {
    all: unset;
    display: contents;
}

.compose-divider { display: none; }

.compose-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.compose-toast {
    margin-top: 1rem;
    padding: 0.625rem 1rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-align: center;
}

/* ─── Field helpers ──────────────────────────────────────────────────────── */

.required-star {
    color: var(--accent);
    font-weight: 700;
}

.optional-label {
    color: var(--text-2);
    font-weight: 400;
    font-size: 0.8125rem;
}

.field-hint {
    font-size: 0.875rem;
    color: var(--text-2);
    margin-top: 0.3rem;
    margin-bottom: 0.6rem;
    line-height: 1.5;
    letter-spacing: -0.005em;
}

.field-error {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--error-fg);
    margin-top: 0.375rem;
    letter-spacing: -0.005em;
}

/* ─── Error / Toast messages ─────────────────────────────────────────────── */

.error-message {
    color: var(--error-fg);
    background: var(--error-bg);
    border: 1px solid var(--error-bd);
    font-size: 0.8125rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: var(--r-md);
    margin-bottom: 1.25rem;
    text-align: center;
}

.compose-toast {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    border-radius: var(--r-md);
    font-size: 0.8125rem;
    font-weight: 500;
    text-align: center;
    letter-spacing: -0.005em;
}

.toast-success {
    background: var(--success-bg);
    color: var(--success-fg);
    border: 1px solid var(--success-bd);
}

.toast-error {
    background: var(--error-bg);
    color: var(--error-fg);
    border: 1px solid var(--error-bd);
}

/* ─── Attachment chips ───────────────────────────────────────────────────── */

.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3125rem 0.625rem 0.3125rem 0.75rem;
    background: var(--info-bg);
    border: 1px solid var(--info-bd);
    border-radius: var(--r-full);
    font-size: 0.78125rem;
    font-weight: 500;
    color: var(--info-fg);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--info-fg);
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--t-fast), color var(--t-fast);
}

.chip-remove:hover {
    opacity: 1;
    color: var(--error-fg);
}

/* ─── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 1rem;
}

.modal-card {
    background: var(--bg-surface);
    border-radius: var(--r-xl);
    padding: 1.75rem;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.25rem;
    color: var(--text-1);
}

/* ─── Template List (Minimal Rows) ───────────────────────────────────────── */

.tpl-list-wrap {
    margin-top: 0.25rem;
}

.tpl-list {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs);
}

.tpl-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
    gap: 1rem;
}

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

.tpl-row:hover {
    background: var(--bg-subtle);
}

.tpl-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.tpl-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 200px;
}

.tpl-sep {
    color: var(--text-3);
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.tpl-subject {
    font-size: 0.875rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.tpl-date {
    font-size: 0.8125rem;
    color: var(--text-3);
    white-space: nowrap;
    flex-shrink: 0;
}

.tpl-actions {
    display: flex;
    gap: 0.125rem;
    flex-shrink: 0;
}

/* ─── Inline Text Link Buttons ───────────────────────────────────────────── */

.btn-link {
    background: none;
    border: none;
    padding: 0.25rem 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    border-radius: var(--r-sm);
    transition: color var(--t-fast), background var(--t-fast);
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
}

.btn-link i,
.btn-link svg {
    width: 14px;
    height: 14px;
    stroke-width: 2.2px;
}

.btn-link:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

.btn-link--danger:hover {
    color: var(--error-fg);
    background: var(--error-bg);
}

.empty-hint {
    color: var(--text-2);
    font-size: 0.8125rem;
    padding: 2rem 0;
    text-align: center;
}

/* ─── Inline template form card ──────────────────────────────────────────── */

.template-form-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-xs);
    animation: fadeIn 0.2s var(--t-base) both;
}

.form-actions {
    display: flex;
    gap: 0.625rem;
    justify-content: flex-start; /* Left-aligned */
    margin-top: 1rem;
}

/* ─── Loading / Empty states ─────────────────────────────────────────────── */

.loading-text,
.empty-state {
    color: var(--text-2);
    font-size: 0.875rem;
    padding: 1rem 0;
}

/* ─── History ────────────────────────────────────────────────────────────── */

.history-table-wrap {
    overflow-x: auto;
    border-radius: var(--r-lg);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    box-shadow: var(--shadow-xs);
}

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

.history-th {
    text-align: left;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-subtle);
}

.history-row {
    transition: background var(--t-fast);
}

.history-row:hover {
    background: var(--bg-subtle);
}

.history-row:not(:last-child) .history-cell {
    border-bottom: 1px solid var(--border);
}

.history-cell {
    padding: 0.7rem 1rem;
    color: var(--text-1);
    vertical-align: middle;
    font-size: 0.875rem;
}

.history-cell--subject {
    max-width: 340px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    color: var(--text-1);
}

.history-cell--recipients,
.history-cell--date {
    white-space: nowrap;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

/* ─── Status Badges ──────────────────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--r-full);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.status-badge--sent {
    background: var(--success-bg);
    color: var(--success-fg);
    border: 1px solid var(--success-bd);
}

.status-badge--scheduled {
    background: var(--info-bg);
    color: var(--info-fg);
    border: 1px solid var(--info-bd);
}

.status-badge--failed {
    background: var(--error-bg);
    color: var(--error-fg);
    border: 1px solid var(--error-bd);
}

.status-badge--cancelled {
    background: var(--bg-subtle);
    color: var(--text-2);
    border: 1px solid var(--border-md);
}

.status-badge--draft {
    background: #fff;
    color: var(--text-2);
    border: 1px solid var(--border-md);
}

/* ─── History Empty ──────────────────────────────────────────────────────── */

.history-empty {
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-2);
}

.history-empty-icon {
    font-size: 2.25rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.history-empty-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-1);
    letter-spacing: -0.01em;
    margin-bottom: 0.3rem;
}

.history-empty-sub {
    font-size: 0.8125rem;
    color: var(--text-2);
}

/* ─── History Error State ────────────────────────────────────────────────── */

.history-error {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--error-bg);
    border: 1px solid var(--error-bd);
    border-radius: var(--r-md);
    padding: 1rem 1.25rem;
    color: var(--error-fg);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ─── Pagination ─────────────────────────────────────────────────────────── */

.history-pagination {
    margin-top: 1.5rem;
}

.history-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.history-pager-info {
    font-size: 0.8125rem;
    color: var(--text-2);
    font-weight: 500;
    letter-spacing: -0.005em;
    font-variant-numeric: tabular-nums;
}

/* ─── Settings ───────────────────────────────────────────────────────────── */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 2rem;
    align-items: start;
}

.settings-col {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-xs);
    animation: fadeIn 0.3s var(--t-base) both;
}

.settings-card--danger {
    border-color: var(--error-bd);
}

.settings-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-1);
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.settings-section-desc {
    font-size: 0.875rem;
    color: var(--text-2);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.settings-field {
    margin-bottom: 1.25rem;
}

.settings-field:last-child {
    margin-bottom: 0;
}

.settings-readonly-input {
    background: #f5f5f5 !important;
    color: var(--text-2) !important;
    cursor: not-allowed;
    border-color: var(--border) !important;
}

.settings-form-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 1.5rem;
}

/* ─── Schedule Toggle ────────────────────────────────────────────────────── */

.timing-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.schedule-toggle-row {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.875rem 0 0.375rem;
}

.schedule-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
    letter-spacing: 0.02em;
}

.schedule-toggle-label .custom-radio {
    display: none;
}

.radio-box {
    width: 20px;
    height: 20px;
    border: 1px solid var(--border-md);
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--t-fast);
    background: var(--bg-surface);
}

.schedule-toggle-label:hover .radio-box {
    border-color: var(--accent);
}

.custom-radio:checked + .radio-box {
    background: #fff;
    border-color: var(--border-md);
}

.custom-radio:checked + .radio-box::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--text-2);
    border-radius: 3px;
}

.schedule-datetime-row {
    padding: 1rem 0 0.25rem;
}

.schedule-datetime-input {
    max-width: 280px;
    margin-top: 0.4rem;
}

/* ─── Mobile: Bottom Tab Bar ─────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .dash-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .dash-col:last-child {
        background: transparent;
        padding: 0;
        border: none;
    }

    .page-container {
        padding: 30px;
    }
}

@media (max-width: 767px) {
    #sidebar {
        width: 100%;
        height: 58px;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        flex-direction: row;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
        border-right: none;
        padding: 0;
    }

    .sidebar-header,
    .sidebar-footer {
        display: none;
    }

    .sidebar-nav {
        flex: 1;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        padding: 0;
        gap: 0;
        overflow: visible;
    }

    .nav-item {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.5rem;
        border-radius: 0;
        font-size: 0.65rem;
        flex: 1;
        justify-content: center;
        text-align: center;
        border-left: none !important;
        padding-left: 0 !important;
        margin-bottom: 0;
    }

    .nav-item::before {
        display: none;
    }

    .nav-item.active {
        border-top: 2px solid var(--accent);
        background: rgba(229, 163, 13, 0.10) !important;
    }

    .nav-icon {
        width: auto;
        height: auto;
    }

    #main-content {
        margin: 0;
        padding-bottom: 58px;
        border-radius: 0;
    }

    .page-container {
        padding: 24px;
        padding-top: 32px;
    }

    .dash-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .dash-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

/* ─── Toast Notifications ────────────────────────────────────────────────── */
.compose-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -40%) scale(0.95);
    padding: 1.5rem 2.5rem;
    background: var(--bg-surface);
    color: var(--text-1);
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--r-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
}

.compose-toast.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.compose-toast.toast-success {
    background: #10b981; /* Vibrant Emerald Green */
    color: #ffffff;
    border: none;
}

.compose-toast.toast-error {
    background: #ef4444; /* Vibrant Red */
    color: #ffffff;
    border: none;
}