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

:root {
    --bg-primary: #0a0a14;
    --bg-secondary: #111122;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-hover: #1f1f3a;
    --bg-active: #2a2a4a;
    --accent: #6366f1;
    --accent-primary: #6366f1; /* Added for login mapping */
    --accent-hover: #818cf8;
    --accent-glow: rgba(99,102,241,.2);
    --accent-green: #34d399; /* Added for toast mapping */
    --accent-red: #f87171;   /* Added for toast mapping */
    --accent-yellow: #fbbf24;
    --green: #34d399;
    --red: #f87171;
    --yellow: #fbbf24;
    --orange: #fb923c;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255,255,255,.06);
    --border-color: rgba(255,255,255,.06); /* Added mapping */
    --border-light: rgba(255,255,255,.1);
    --radius: 10px;
    --radius-md: 8px; /* Added mapping */
    --radius-lg: 12px; /* Added mapping */
    --radius-xl: 16px; /* Added mapping */
    --glass: rgba(22,22,42,.85);
    --glass-bg: rgba(22,22,42,.85); /* Added mapping */
    --glass-border: rgba(255,255,255,.1); /* Added mapping */
    --shadow-lg: 0 10px 40px rgba(0,0,0,.3); /* Added mapping */
    --transition-fast: 0.2s ease; /* Added mapping */
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --accent: #4f46e5;
    --accent-primary: #4f46e5;
    --accent-hover: #4338ca;
    --accent-glow: rgba(79,70,229,.15);
    --accent-green: #059669;
    --accent-red: #dc2626;
    --accent-yellow: #d97706;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --orange: #f97316;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border: rgba(0,0,0,.08);
    --border-color: rgba(0,0,0,.08);
    --border-light: rgba(0,0,0,.05);
    --glass: rgba(255,255,255,.9);
    --glass-bg: rgba(255,255,255,.9);
    --glass-border: rgba(0,0,0,.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,.08);
}

/* Global Hidden Class */
.hidden { display: none !important; }


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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    display: grid;
    grid-template-columns: var(--nav-w, 200px) 4px var(--list-w, 280px) 4px 1fr 4px var(--erp-w, 300px);
    height: 100vh;
}

/* Themed background: Gmail-style wallpaper visibility */
body.themed-bg {
    background-attachment: fixed;
}
body.themed-bg .app {
    padding: 12px;
    gap: 6px;
    height: calc(100vh - 24px);
    grid-template-columns: var(--nav-w, 200px) 0px var(--list-w, 280px) 0px 1fr 0px var(--erp-w, 300px);
}
body.themed-bg .label-nav-pane {
    background: rgba(10, 10, 20, 0.4) !important;
    backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.08) !important;
}
body.themed-bg .email-list-pane {
    background: rgba(10, 10, 20, 0.35) !important;
    backdrop-filter: blur(10px);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,.08) !important;
}
body.themed-bg .email-reader-pane {
    background: transparent !important;
    backdrop-filter: none;
    border: 1px solid transparent !important;
}
body.themed-bg .email-reader-pane.has-content #email-content {
    background: rgba(10, 10, 20, 0.4) !important;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,.08) !important;
    border-radius: 12px;
}
body.themed-bg .erp-sidebar {
    background: rgba(10, 10, 20, 0.4) !important;
    border: 1px solid rgba(255,255,255,.08) !important;
    backdrop-filter: blur(10px);
}
body.themed-bg .resizer {
    background: transparent !important;
    width: 0px;
}
body.themed-bg .inbox-label {
    background: rgba(10, 10, 20, 0.2) !important;
    border-radius: 12px 12px 0 0;
}
body.themed-bg .pane-header {
    background: rgba(10, 10, 20, 0.15) !important;
}
body.themed-bg .email-item {
    background: transparent !important;
}
body.themed-bg .email-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}
body.themed-bg .email-item.unread {
    background: rgba(255, 255, 255, 0.04) !important;
}
/* Light theme wallpaper */
[data-theme="light"].themed-bg .label-nav-pane {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(12px);
}
[data-theme="light"].themed-bg .email-list-pane {
    background: rgba(255, 255, 255, 0.4) !important;
    backdrop-filter: blur(10px);
}
[data-theme="light"].themed-bg .email-reader-pane {
    background: transparent !important;
    backdrop-filter: none;
}
[data-theme="light"].themed-bg .email-reader-pane.has-content {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(12px);
}
[data-theme="light"].themed-bg .erp-sidebar {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(12px);
}
[data-theme="light"].themed-bg .inbox-label {
    background: rgba(255, 255, 255, 0.3) !important;
}
[data-theme="light"].themed-bg .pane-header {
    background: rgba(255, 255, 255, 0.2) !important;
}
[data-theme="light"].themed-bg .email-item:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

.resizer {
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    height: 100%;
    z-index: 10;
}
.resizer:hover, .resizer.dragging {
    background: var(--accent);
}

/* ===== PANEL 1: LABEL NAVIGATION SIDEBAR ===== */
.label-nav-pane {
    background: var(--bg-tertiary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.label-nav-pane .pane-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.label-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
}

.label-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s ease;
    text-decoration: none;
    border-radius: 0 20px 20px 0;
    margin-right: 8px;
    position: relative;
}

.label-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.label-item.active {
    background: rgba(99,102,241,.12);
    color: var(--accent-hover);
    font-weight: 600;
}

.label-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.label-item .material-icons-round {
    font-size: 18px;
    opacity: .8;
}

.label-item.active .material-icons-round {
    opacity: 1;
    color: var(--accent);
}

.label-count {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    background: var(--accent);
    color: white;
    padding: 1px 7px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.label-count:empty {
    display: none;
}


/* === EMAIL LIST PANE === */
.email-list-pane {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.pane-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon { font-size: 20px; color: var(--accent); }
.logo-text { font-size: 14px; font-weight: 700; }

.inbox-label {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    background: var(--accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

.email-list { flex: 1; overflow-y: auto; }

.email-item {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .15s;
    position: relative;
    display: flex;
    align-items: flex-start;
}

.email-item:hover { background: var(--bg-hover); }
.email-item.active { background: var(--bg-active); }
.email-item.unread { background: rgba(99,102,241,.04); }

.email-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.email-item.unread .ei-sender { font-weight: 600; color: var(--text-primary); }
.email-item.unread .ei-subject { font-weight: 500; color: var(--text-primary); }

.ei-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1px; }
.ei-sender { font-size: 12px; color: var(--text-secondary); }
.ei-date { font-size: 10px; color: var(--text-muted); }
.ei-subject { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ei-snippet { font-size: 10px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* === EMAIL READER === */
.email-reader-pane {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: transparent;
    transition: background 0.3s ease, backdrop-filter 0.3s ease;
}
.email-reader-pane.has-content {
    background: var(--bg-primary);
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    gap: 12px;
    font-size: 14px;
}

/* Email body containment — force tight sides and kill vertical gaps */
.email-body {
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.5;
}
/* Force tables to expand to full width to eliminate side margins */
.email-body table { max-width: 100% !important; width: 100% !important; }
.email-body img { max-width: 100% !important; height: auto !important; }

/* Strip side padding to make content tight to the edges */
.email-body div[style*="padding"], .email-body td[style*="padding"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
}
.email-body center { text-align: left; }

/* Aggressively kill top gaps and hide preheaders */
.email-body > *:first-child,
.email-body > *:first-child > *:first-child,
.email-body > *:first-child > *:first-child > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
.email-body [style*="max-height: 0"], 
.email-body [style*="max-height:0"] {
    display: none !important;
}

.email-subject { font-size: 15px; font-weight: 700; margin-bottom: 6px; line-height: 1.3; }

#email-content { padding: 8px 10px !important; }

.email-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
}

.sender-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sender-name { font-size: 13px; font-weight: 600; }
.sender-email { font-size: 11px; color: var(--text-muted); }
.email-date { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.email-body { font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

/* AI Action Bar */
.ai-bar {
    display: flex;
    gap: 6px;
    padding: 10px 0;
    margin-top: 12px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.ai-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
}

.ai-btn:hover { border-color: var(--accent); color: var(--accent-hover); background: rgba(99,102,241,.08); }
.ai-btn .material-icons-round { font-size: 16px; }

.ai-btn.accent {
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    font-weight: 600;
}

.ai-btn.accent:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }

.ai-result {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
    animation: fadeIn .3s ease;
}

.ai-result h4 {
    color: var(--accent-hover);
    margin-bottom: 10px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === ERP SIDEBAR === */
.erp-sidebar {
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.erp-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 16px;
    line-height: 1.8;
}

.erp-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
}

.erp-card.warning {
    border-color: var(--orange);
    background: rgba(251,146,60,.06);
}

.erp-card-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.erp-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    padding: 2px 0;
    color: var(--text-secondary);
}

.erp-row span:first-child { color: var(--text-muted); }

.tier-badge {
    background: rgba(99,102,241,.15);
    color: var(--accent-hover);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.erp-balance-card {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 6px;
}

.balance-label { font-size: 10px; opacity: .7; margin-bottom: 2px; }
.balance-value { font-size: 18px; font-weight: 700; }

.stock-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

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

.stock-ok { color: var(--green); font-weight: 600; }
.stock-low { color: var(--yellow); font-weight: 600; }
.stock-out { color: var(--red); font-weight: 600; }

.order-row {
    font-size: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Prompt button */
.ai-btn.prompt {
    background: rgba(52,211,153,.1);
    border-color: var(--green);
    color: var(--green);
}
.ai-btn.prompt:hover { background: rgba(52,211,153,.2); }

/* ERP Links */
.erp-link {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 600;
    font-size: 12px;
}
.erp-link:hover { text-decoration: underline; }

/* Email History */
.history-row {
    font-size: 11px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: baseline;
}
.history-row:last-child { border-bottom: none; }
.history-dir { font-size: 10px; }
.history-subj { color: var(--text-secondary); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-date { color: var(--text-muted); font-size: 10px; white-space: nowrap; }

/* Quick Actions */
.quick-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.qa-btn {
    padding: 6px 10px;
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    text-decoration: none;
    transition: all .15s;
    cursor: pointer;
}
.qa-btn:hover { border-color: var(--accent); color: var(--accent-hover); }

/* Toast */
.toast-msg {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background: var(--green);
    color: #000;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius);
    z-index: 200;
    animation: fadeIn .3s ease;
}

/* Mobile ERP toggle */
.mobile-erp-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: white;
    border: none;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    z-index: 50;
    box-shadow: 0 4px 20px var(--accent-glow);
}

/* Responsive */
@media (max-width: 1200px) {
    .app {
        grid-template-columns: 180px 4px 220px 4px 1fr 4px 260px;
    }
}

@keyframes slideFromRight { from { transform: translateX(100%); } to { transform: translateX(0); } }


/* ===== LOGIN SCREEN ===== */
.login-screen {
    display: flex; align-items: center; justify-content: center;
    height: 100vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(99,102,241,.15) 0%, transparent 60%),
                var(--bg-primary);
}

.login-container { text-align: center; animation: fadeInUp .6s ease; }

.login-logo { margin-bottom: 40px; }
.logo-icon { font-size: 56px; color: var(--accent-primary); filter: drop-shadow(0 0 20px var(--accent-glow)); }
.login-logo h1 { font-size: 36px; font-weight: 700; margin-top: 12px; background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }

.login-card {
    background: var(--glass-bg); border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl); padding: 40px 48px;
    backdrop-filter: blur(20px); box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.login-card > p { color: var(--text-secondary); font-size: 13px; margin-bottom: 28px; }

.btn-google {
    display: inline-flex; align-items: center; gap: 10px;
    padding: 12px 28px; border-radius: var(--radius-md);
    background: #fff; color: #333; border: none;
    font-size: 14px; font-weight: 500; cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn-google:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(255,255,255,.15); }

.login-note { color: var(--text-muted); font-size: 11px; margin-top: 20px; }





/* ===== COMPOSE MODAL ===== */
.compose-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); z-index: 2000;
    display: flex; align-items: center; justify-content: center;
}
.compose-modal.hidden { display: none !important; }

.compose-window {
    width: 650px; max-width: 90%; max-height: 90vh;
    background: var(--bg-card); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); box-shadow: 0 10px 40px rgba(0,0,0,.3);
    display: flex; flex-direction: column;
    animation: fadeInUp .2s ease;
}

.compose-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--bg-tertiary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    font-size: 13px; font-weight: 500;
}
.compose-header-actions { display: flex; gap: 2px; }

.compose-body { display: flex; flex-direction: column; flex: 1; overflow-y: auto; }
.compose-field {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 16px; border-bottom: 1px solid var(--border-color);
}
.compose-field label { font-size: 12px; color: var(--text-muted); min-width: 65px; }
.compose-input {
    flex: 1; padding: 6px 0; background: none; border: none;
    color: var(--text-primary); font-size: 13px; outline: none;
    font-family: 'Inter', sans-serif;
}
.compose-input option { background: var(--bg-tertiary); }

.compose-editor-container { flex: 1; min-height: 250px; }
.compose-editor {
    padding: 16px; min-height: 250px; font-size: 13px;
    line-height: 1.6; color: var(--text-primary); outline: none;
    overflow-y: auto;
}
.compose-editor:empty::before {
    content: attr(data-placeholder); color: var(--text-muted);
}

.compose-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-top: 1px solid var(--border-color);
}
.compose-toolbar-left { display: flex; gap: 2px; }
.btn-send {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 20px; background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: #fff; border: none; border-radius: var(--radius-md);
    font-size: 13px; font-weight: 500; cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-send:hover { transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-send .material-icons-round { font-size: 16px; }





/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius-md);
    background: var(--bg-card); border: 1px solid var(--border-light);
    color: var(--text-primary); font-size: 13px;
    box-shadow: var(--shadow-lg); animation: toastIn .3s ease;
    backdrop-filter: blur(20px);
}
.toast.success { border-color: var(--accent-green); }
.toast.error { border-color: var(--accent-red); }
.toast.fadeout { animation: toastOut .3s ease forwards; }





/* ===== LOADING ===== */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; gap: 16px; color: var(--text-muted); }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--border-light);
    border-top-color: var(--accent-primary); border-radius: 50%;
    animation: spin .8s linear infinite;
}
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; gap: 12px; color: var(--text-muted); }
.empty-state .material-icons-round { font-size: 48px; opacity: .3; }

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

/* ===== NEW CUSTOMER FORM ===== */
.nc-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.nc-field label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
}
.nc-field input,
.nc-field select,
.nc-field textarea {
    padding: 6px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color .15s;
}
.nc-field input:focus,
.nc-field select:focus,
.nc-field textarea:focus {
    border-color: var(--accent-primary);
}
.nc-field textarea { resize: vertical; min-height: 40px; }

.nc-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    border: none;
}
.nc-btn-save {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    flex: 1;
    justify-content: center;
}
.nc-btn-save:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }
.nc-btn-save:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.nc-btn-external {
    background: var(--bg-hover);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.nc-btn-external:hover { border-color: var(--accent-primary); color: var(--accent-hover); }

/* Tier color classes */
.tier-gold { color: #fbbf24; }
.tier-silver { color: #94a3b8; }
.tier-standard { color: var(--text-secondary); }
.tier-platinum { color: #a78bfa; }

/* ===== GMAIL-STYLE CATEGORY TABS ===== */
.category-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    overflow-x: auto;
}
.category-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}
.category-tab .material-icons-round { font-size: 16px; }
.category-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.category-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
    font-weight: 600;
}
.category-tab.active .material-icons-round { color: var(--accent-primary); }

/* ===== MULTI-ACCOUNT SECTION ===== */
.account-section {
    margin-top: auto;
    padding-top: 4px;
}
.account-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 14px;
}
.account-section-title {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: .5px;
    padding: 4px 14px;
}
.account-avatar-sm {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}
.account-email-text {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-item {
    padding: 6px 14px !important;
}
.add-account-item {
    opacity: .6;
    font-size: 12px !important;
    padding: 8px 14px !important;
}
.add-account-item:hover {
    opacity: 1;
}

/* ===== EMAIL HISTORY ROWS ===== */
.history-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 11px;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: background .1s;
}
.history-row:hover {
    background: var(--bg-hover);
    padding-left: 4px;
    padding-right: 4px;
    margin-left: -4px;
    margin-right: -4px;
}
.history-subj {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-date {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ERP clickable product links */
.erp-link {
    color: var(--accent-hover);
    text-decoration: none;
    transition: color .15s;
}
.erp-link:hover {
    color: var(--accent-primary);
    text-decoration: underline;
}

/* ===== COMPOSE TOOLBAR DIVIDER ===== */
.toolbar-divider {
    width: 1px;
    height: 18px;
    background: var(--border-light);
    margin: 0 2px;
    display: inline-block;
    vertical-align: middle;
}

/* ===== BULK EMAIL SELECTION ===== */
.email-checkbox {
    width: 18px;
    height: 18px;
    min-width: 18px;
    accent-color: var(--accent-primary);
    cursor: pointer;
    flex-shrink: 0;
    margin-right: 6px;
}

/* Always show checkboxes (like Gmail) */
.email-item .email-checkbox {
    opacity: 1;
}

/* Bulk action bar */
.bulk-action-bar {
    display: none;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}
.bulk-action-bar.visible {
    display: flex;
}
.bulk-action-bar .bulk-count {
    color: var(--accent-primary);
    font-weight: 600;
    margin-right: 6px;
}
.bulk-action-bar button {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all .15s;
}
.bulk-action-bar button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.bulk-action-bar button .material-icons-round {
    font-size: 14px;
}

/* Select-all row in inbox header */
.select-all-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

/* ========================================
   MOBILE RESPONSIVE LAYOUT
   ======================================== */

/* Hamburger button - hidden on desktop */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    align-items: center;
}

/* Mobile overlay - hidden on desktop */
.mobile-overlay {
    display: none;
}

@media (max-width: 900px) {
    /* --- Force single column: only show email-list-pane --- */
    .app {
        display: flex !important;
        flex-direction: column !important;
        height: 100vh;
    }

    /* --- Hide resizers --- */
    .resizer { display: none !important; }

    /* --- PANEL 1: Sidebar → off-screen drawer --- */
    .label-nav-pane {
        position: fixed !important;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
        background: var(--bg-tertiary);
    }
    .label-nav-pane.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.4);
    }

    /* Sidebar internals */
    .label-nav-pane .pane-header { padding: 10px 12px; }
    .label-nav-pane .logo-icon { font-size: 20px !important; }
    .label-nav-pane .logo-text { font-size: 15px !important; }

    /* Overlay backdrop */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,.5);
        z-index: 999;
    }
    .mobile-overlay.visible { display: block; }

    /* Show hamburger */
    .mobile-menu-btn { display: flex; }

    /* --- PANEL 2: Email list → full screen --- */
    .email-list-pane {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-right: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden;
    }

    /* Tighter header */
    .inbox-label {
        padding: 6px 8px !important;
        gap: 4px !important;
        min-height: auto !important;
    }
    .inbox-label #current-folder-name { font-size: 16px !important; }
    .inbox-label .badge { font-size: 11px !important; padding: 2px 6px !important; }
    #current-account-indicator { font-size: 12px !important; }

    /* Compact search */
    .email-list-pane > div:nth-child(3) {
        padding: 4px 8px !important;
    }
    #email-search-input {
        padding: 8px 24px 8px 32px !important;
        font-size: 14px !important;
    }

    /* Compact bulk bar */
    .bulk-action-bar {
        padding: 6px 10px !important;
        gap: 6px !important;
        flex-wrap: wrap;
    }
    .bulk-action-bar button {
        padding: 5px 10px !important;
        font-size: 12px !important;
    }
    .bulk-count { font-size: 12px !important; }

    /* Mobile email items */
    .email-item {
        padding: 10px 12px !important;
    }
    .email-checkbox {
        width: 20px !important;
        height: 20px !important;
        min-width: 20px !important;
        margin-right: 8px !important;
    }
    .ei-sender { font-size: 14px !important; }
    .ei-date { font-size: 12px !important; }
    .ei-subject { font-size: 14px !important; margin-bottom: 2px !important; }
    .ei-snippet { font-size: 13px !important; line-height: 1.3 !important; }
    .email-star .material-icons-round { font-size: 18px !important; }

    /* Mobile back button - show only on mobile */
    .mobile-back-bar { display: flex !important; }

    /* --- PANEL 3: Reader → HIDDEN by default, fullscreen overlay when open --- */
    .email-reader-pane {
        display: none !important;
    }
    .email-reader-pane.mobile-reading {
        display: flex !important;
        position: fixed !important;
        top: 0; left: 0; right: 0; bottom: 0;
        z-index: 800;
        width: 100% !important;
        height: 100% !important;
        background: var(--bg-primary);
        flex-direction: column;
        overflow-y: auto;
    }

    /* --- PANEL 4: ERP Sidebar → HIDDEN --- */
    .erp-sidebar {
        display: none !important;
    }

    /* --- Compose → full width bottom sheet --- */
    .compose-modal {
        width: 100% !important;
        max-width: 100% !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        border-radius: 12px 12px 0 0 !important;
        max-height: 90vh !important;
    }

    /* Folder actions */
    #folder-actions-bar { padding: 6px 10px !important; }
    #folder-actions-bar button { font-size: 13px !important; }

    /* Larger touch targets for header action buttons */
    .inbox-label .btn-icon,
    .inbox-label #search-toggle-btn {
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 8px !important;
    }
    .inbox-label .btn-icon .material-icons-round,
    .inbox-label #search-toggle-btn .material-icons-round {
        font-size: 22px !important;
    }

    /* Category tabs touch-friendly on mobile */
    .category-tab { padding: 12px 6px !important; font-size: 12px !important; }
    .category-tab .material-icons-round { font-size: 18px !important; }
}

/* Extra small screens */
@media (max-width: 400px) {
    .label-nav-pane { width: 220px; }
    .inbox-label { padding: 6px 8px !important; }
    .email-item { padding: 8px 10px !important; }
    .ei-sender { font-size: 13px !important; }
    .ei-subject { font-size: 13px !important; }
    .ei-snippet { font-size: 12px !important; }
}

/* Find similar: show search icon on hover */
.email-item:hover .ei-find-similar { opacity: 1 !important; }

/* Highlight selected email row */
.email-item.selected-email {
    background: var(--accent-glow) !important;
    border-left: 4px solid var(--accent-primary) !important;
}
