/* =============================================
   FastEmail - Professional Webmail CSS
   Modern Gmail-like design with animations
   ============================================= */

/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-rgb: 37, 99, 235;
    --primary-light: #eff6ff;
    --primary-dark: #1e40af;
    --accent: #1e40af;
    --accent-light: #eff6ff;
    --gradient: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #eff6ff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --red: #ef4444;
    --green: #22c55e;
    --yellow: #eab308;
    --orange: #f97316;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --radius: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-width: 256px;
    --header-height: 64px;
    --transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Theme */
[data-theme="dark"],
html[data-theme="dark"] {
    --bg: #0f172a;
    --bg-white: #1e293b;
    --bg-hover: #283548;
    --bg-active: #1e3a5f;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-light: #64748b;
    --border: #334155;
    --border-light: #1e293b;
    --primary-light: #1e3a5f;
    --accent-light: #1e3a5f;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Ocean Theme */
[data-theme="ocean"],
html[data-theme="ocean"] {
    --primary: #0891b2;
    --primary-rgb: 8, 145, 178;
    --primary-light: #ecfeff;
    --primary-dark: #0e7490;
    --accent: #0e7490;
    --accent-light: #ecfeff;
    --gradient: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
    --bg: #f0fdfa;
    --bg-white: #ffffff;
    --bg-hover: #e6fffa;
    --bg-active: #ccfbf1;
    --text: #134e4a;
    --text-secondary: #2d6a6a;
    --text-light: #5f9ea0;
    --border: #b2dfdb;
    --border-light: #e0f2f1;
}

/* Ocean Dark Theme */
[data-theme="ocean-dark"],
html[data-theme="ocean-dark"] {
    --primary: #22d3ee;
    --primary-rgb: 34, 211, 238;
    --primary-light: #164e63;
    --primary-dark: #06b6d4;
    --accent: #06b6d4;
    --accent-light: #164e63;
    --gradient: linear-gradient(135deg, #0891b2 0%, #164e63 100%);
    --bg: #0c1e2b;
    --bg-white: #132f42;
    --bg-hover: #1a3a50;
    --bg-active: #164e63;
    --text: #cffafe;
    --text-secondary: #67e8f9;
    --text-light: #3b8ea5;
    --border: #1e4d5e;
    --border-light: #132f42;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Emerald Theme */
[data-theme="emerald"],
html[data-theme="emerald"] {
    --primary: #059669;
    --primary-rgb: 5, 150, 105;
    --primary-light: #ecfdf5;
    --primary-dark: #047857;
    --accent: #047857;
    --accent-light: #ecfdf5;
    --gradient: linear-gradient(135deg, #059669 0%, #047857 100%);
    --bg: #f0fdf4;
    --bg-white: #ffffff;
    --bg-hover: #dcfce7;
    --bg-active: #d1fae5;
    --text: #14532d;
    --text-secondary: #3f6b52;
    --text-light: #6b9e82;
    --border: #bbf7d0;
    --border-light: #ecfdf5;
}

/* Emerald Dark Theme */
[data-theme="emerald-dark"],
html[data-theme="emerald-dark"] {
    --primary: #34d399;
    --primary-rgb: 52, 211, 153;
    --primary-light: #064e3b;
    --primary-dark: #10b981;
    --accent: #10b981;
    --accent-light: #064e3b;
    --gradient: linear-gradient(135deg, #059669 0%, #064e3b 100%);
    --bg: #0a1f16;
    --bg-white: #122e22;
    --bg-hover: #1a3d2e;
    --bg-active: #064e3b;
    --text: #d1fae5;
    --text-secondary: #6ee7b7;
    --text-light: #3b7a5e;
    --border: #1a4435;
    --border-light: #122e22;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Sunset Theme */
[data-theme="sunset"],
html[data-theme="sunset"] {
    --primary: #ea580c;
    --primary-rgb: 234, 88, 12;
    --primary-light: #fff7ed;
    --primary-dark: #c2410c;
    --accent: #c2410c;
    --accent-light: #fff7ed;
    --gradient: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    --bg: #fffbf5;
    --bg-white: #ffffff;
    --bg-hover: #fff1e0;
    --bg-active: #fed7aa;
    --text: #431407;
    --text-secondary: #7c4a2d;
    --text-light: #b87d5e;
    --border: #fed7aa;
    --border-light: #fff7ed;
}

/* Sunset Dark Theme */
[data-theme="sunset-dark"],
html[data-theme="sunset-dark"] {
    --primary: #fb923c;
    --primary-rgb: 251, 146, 60;
    --primary-light: #5c2d0e;
    --primary-dark: #f97316;
    --accent: #f97316;
    --accent-light: #5c2d0e;
    --gradient: linear-gradient(135deg, #ea580c 0%, #5c2d0e 100%);
    --bg: #1c0f05;
    --bg-white: #2e1a0d;
    --bg-hover: #3d2415;
    --bg-active: #5c2d0e;
    --text: #fed7aa;
    --text-secondary: #fb923c;
    --text-light: #8a5c3a;
    --border: #4a2816;
    --border-light: #2e1a0d;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Rose Theme */
[data-theme="rose"],
html[data-theme="rose"] {
    --primary: #e11d48;
    --primary-rgb: 225, 29, 72;
    --primary-light: #fff1f2;
    --primary-dark: #be123c;
    --accent: #be123c;
    --accent-light: #fff1f2;
    --gradient: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --bg: #fff5f6;
    --bg-white: #ffffff;
    --bg-hover: #ffe4e6;
    --bg-active: #fecdd3;
    --text: #4c0519;
    --text-secondary: #7c3043;
    --text-light: #b06078;
    --border: #fecdd3;
    --border-light: #fff1f2;
}

/* Rose Dark Theme */
[data-theme="rose-dark"],
html[data-theme="rose-dark"] {
    --primary: #fb7185;
    --primary-rgb: 251, 113, 133;
    --primary-light: #5c1030;
    --primary-dark: #f43f5e;
    --accent: #f43f5e;
    --accent-light: #5c1030;
    --gradient: linear-gradient(135deg, #e11d48 0%, #5c1030 100%);
    --bg: #1a0812;
    --bg-white: #2d1220;
    --bg-hover: #3d1a2d;
    --bg-active: #5c1030;
    --text: #fecdd3;
    --text-secondary: #fb7185;
    --text-light: #8a4058;
    --border: #4a1630;
    --border-light: #2d1220;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Purple Theme */
[data-theme="purple"],
html[data-theme="purple"] {
    --primary: #7c3aed;
    --primary-rgb: 124, 58, 237;
    --primary-light: #f5f3ff;
    --primary-dark: #6d28d9;
    --accent: #6d28d9;
    --accent-light: #f5f3ff;
    --gradient: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    --bg: #faf5ff;
    --bg-white: #ffffff;
    --bg-hover: #f3e8ff;
    --bg-active: #e9d5ff;
    --text: #2e1065;
    --text-secondary: #553c8b;
    --text-light: #8b7ab0;
    --border: #ddd6fe;
    --border-light: #f5f3ff;
}

/* Purple Dark Theme */
[data-theme="purple-dark"],
html[data-theme="purple-dark"] {
    --primary: #a78bfa;
    --primary-rgb: 167, 139, 250;
    --primary-light: #3b1f7e;
    --primary-dark: #8b5cf6;
    --accent: #8b5cf6;
    --accent-light: #3b1f7e;
    --gradient: linear-gradient(135deg, #7c3aed 0%, #3b1f7e 100%);
    --bg: #13082b;
    --bg-white: #1e1040;
    --bg-hover: #2a1855;
    --bg-active: #3b1f7e;
    --text: #e9d5ff;
    --text-secondary: #a78bfa;
    --text-light: #6b5899;
    --border: #2e1a5e;
    --border-light: #1e1040;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Slate Theme */
[data-theme="slate"],
html[data-theme="slate"] {
    --primary: #475569;
    --primary-rgb: 71, 85, 105;
    --primary-light: #f8fafc;
    --primary-dark: #334155;
    --accent: #334155;
    --accent-light: #f8fafc;
    --gradient: linear-gradient(135deg, #64748b 0%, #475569 100%);
    --bg: #f8fafc;
    --bg-white: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-active: #e2e8f0;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-light: #94a3b8;
    --border: #cbd5e1;
    --border-light: #f1f5f9;
}

/* Midnight Theme */
[data-theme="midnight"],
html[data-theme="midnight"] {
    --primary: #818cf8;
    --primary-rgb: 129, 140, 248;
    --primary-light: #1e1b4b;
    --primary-dark: #6366f1;
    --accent: #6366f1;
    --accent-light: #1e1b4b;
    --gradient: linear-gradient(135deg, #6366f1 0%, #1e1b4b 100%);
    --bg: #020617;
    --bg-white: #0f172a;
    --bg-hover: #1e293b;
    --bg-active: #1e1b4b;
    --text: #e0e7ff;
    --text-secondary: #a5b4fc;
    --text-light: #6366f1;
    --border: #1e293b;
    --border-light: #0f172a;
    --shadow: 0 1px 3px rgba(0,0,0,0.6);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.7);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.8);
}

/* Nord Theme */
[data-theme="nord"],
html[data-theme="nord"] {
    --primary: #5e81ac;
    --primary-rgb: 94, 129, 172;
    --primary-light: #eceff4;
    --primary-dark: #4c6a8e;
    --accent: #4c6a8e;
    --accent-light: #eceff4;
    --gradient: linear-gradient(135deg, #5e81ac 0%, #4c6a8e 100%);
    --bg: #eceff4;
    --bg-white: #ffffff;
    --bg-hover: #e5e9f0;
    --bg-active: #d8dee9;
    --text: #2e3440;
    --text-secondary: #4c566a;
    --text-light: #7b88a1;
    --border: #d8dee9;
    --border-light: #eceff4;
}

/* Nord Dark Theme */
[data-theme="nord-dark"],
html[data-theme="nord-dark"] {
    --primary: #88c0d0;
    --primary-rgb: 136, 192, 208;
    --primary-light: #2e3440;
    --primary-dark: #81a1c1;
    --accent: #81a1c1;
    --accent-light: #2e3440;
    --gradient: linear-gradient(135deg, #5e81ac 0%, #2e3440 100%);
    --bg: #242933;
    --bg-white: #2e3440;
    --bg-hover: #3b4252;
    --bg-active: #434c5e;
    --text: #eceff4;
    --text-secondary: #d8dee9;
    --text-light: #7b88a1;
    --border: #3b4252;
    --border-light: #2e3440;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Sakura Theme */
[data-theme="sakura"],
html[data-theme="sakura"] {
    --primary: #d946a8;
    --primary-rgb: 217, 70, 168;
    --primary-light: #fdf2f8;
    --primary-dark: #be185d;
    --accent: #be185d;
    --accent-light: #fdf2f8;
    --gradient: linear-gradient(135deg, #ec4899 0%, #d946a8 100%);
    --bg: #fdf2f8;
    --bg-white: #ffffff;
    --bg-hover: #fce7f3;
    --bg-active: #fbcfe8;
    --text: #500724;
    --text-secondary: #8b3a60;
    --text-light: #c07898;
    --border: #f9a8d4;
    --border-light: #fce7f3;
}

/* Coffee Theme */
[data-theme="coffee"],
html[data-theme="coffee"] {
    --primary: #92400e;
    --primary-rgb: 146, 64, 14;
    --primary-light: #fef3c7;
    --primary-dark: #78350f;
    --accent: #78350f;
    --accent-light: #fef3c7;
    --gradient: linear-gradient(135deg, #b45309 0%, #92400e 100%);
    --bg: #fffbeb;
    --bg-white: #ffffff;
    --bg-hover: #fef3c7;
    --bg-active: #fde68a;
    --text: #451a03;
    --text-secondary: #6b4423;
    --text-light: #a07850;
    --border: #fbbf24;
    --border-light: #fef3c7;
}

/* Coffee Dark Theme */
[data-theme="coffee-dark"],
html[data-theme="coffee-dark"] {
    --primary: #d97706;
    --primary-rgb: 217, 119, 6;
    --primary-light: #3d1f04;
    --primary-dark: #b45309;
    --accent: #b45309;
    --accent-light: #3d1f04;
    --gradient: linear-gradient(135deg, #92400e 0%, #3d1f04 100%);
    --bg: #1a1006;
    --bg-white: #2a1c0e;
    --bg-hover: #3a2818;
    --bg-active: #3d1f04;
    --text: #fde68a;
    --text-secondary: #d97706;
    --text-light: #7a5c2e;
    --border: #3d2a12;
    --border-light: #2a1c0e;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.6);
}

/* Forest Theme */
[data-theme="forest"],
html[data-theme="forest"] {
    --primary: #16653a;
    --primary-rgb: 22, 101, 58;
    --primary-light: #f0fdf4;
    --primary-dark: #14532d;
    --accent: #14532d;
    --accent-light: #f0fdf4;
    --gradient: linear-gradient(135deg, #15803d 0%, #14532d 100%);
    --bg: #f0fdf4;
    --bg-white: #ffffff;
    --bg-hover: #dcfce7;
    --bg-active: #bbf7d0;
    --text: #052e16;
    --text-secondary: #2d5f3e;
    --text-light: #5f9670;
    --border: #86efac;
    --border-light: #dcfce7;
}

/* Dracula Theme */
[data-theme="dracula"],
html[data-theme="dracula"] {
    --primary: #bd93f9;
    --primary-rgb: 189, 147, 249;
    --primary-light: #2c2042;
    --primary-dark: #a06cff;
    --accent: #ff79c6;
    --accent-light: #342040;
    --gradient: linear-gradient(135deg, #bd93f9 0%, #6272a4 100%);
    --bg: #1e1f29;
    --bg-white: #282a36;
    --bg-hover: #343746;
    --bg-active: #44475a;
    --text: #f8f8f2;
    --text-secondary: #c0c0d0;
    --text-light: #6272a4;
    --border: #44475a;
    --border-light: #282a36;
    --shadow: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.6);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.7);
}

/* Solarized Light Theme */
[data-theme="solarized"],
html[data-theme="solarized"] {
    --primary: #268bd2;
    --primary-rgb: 38, 139, 210;
    --primary-light: #fdf6e3;
    --primary-dark: #2176b5;
    --accent: #2176b5;
    --accent-light: #fdf6e3;
    --gradient: linear-gradient(135deg, #268bd2 0%, #2176b5 100%);
    --bg: #fdf6e3;
    --bg-white: #ffffff;
    --bg-hover: #eee8d5;
    --bg-active: #e4ddc8;
    --text: #073642;
    --text-secondary: #586e75;
    --text-light: #93a1a1;
    --border: #d3cbb7;
    --border-light: #eee8d5;
}

/* Solarized Dark Theme */
[data-theme="solarized-dark"],
html[data-theme="solarized-dark"] {
    --primary: #268bd2;
    --primary-rgb: 38, 139, 210;
    --primary-light: #073642;
    --primary-dark: #2176b5;
    --accent: #2aa198;
    --accent-light: #073642;
    --gradient: linear-gradient(135deg, #268bd2 0%, #073642 100%);
    --bg: #002b36;
    --bg-white: #073642;
    --bg-hover: #0a4050;
    --bg-active: #0d4f60;
    --text: #fdf6e3;
    --text-secondary: #93a1a1;
    --text-light: #586e75;
    --border: #0a4050;
    --border-light: #073642;
    --shadow: 0 1px 3px rgba(0,0,0,0.5);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.6);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.7);
}

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

html {
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    max-width: 100%;
    background: var(--bg);
}

body {
    background: var(--bg);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100dvh;
    width: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow-x: hidden;
}

#app {
    height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

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

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

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideDown {
    from { max-height: 0; opacity: 0; }
    to { max-height: 500px; opacity: 1; }
}

.animate-fadeIn { animation: fadeIn 0.15s ease; }
.animate-fadeInUp { animation: fadeInUp 0.2s ease; }
.animate-slideInRight { animation: slideInRight 0.15s ease; }
.animate-scaleIn { animation: scaleIn 0.1s ease; }
.animate-bounceIn { animation: bounceIn 0.3s ease; }

/* ==================== LOGIN/REGISTER ==================== */
.auth-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.auth-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    color: var(--text);
}

.auth-left h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-left p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 400px;
    text-align: center;
    line-height: 1.6;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    background: var(--gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(var(--primary-rgb), 0.2);
}

.auth-logo-icon svg {
    width: 32px;
    height: 32px;
}

.auth-logo-text {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 40px;
    max-width: 500px;
}

.auth-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.auth-feature:hover {
    background: var(--bg-hover);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.auth-feature .material-icons-outlined {
    font-size: 24px;
    color: var(--primary);
}

.auth-feature span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.auth-right {
    width: 480px;
    max-width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 40px;
    overflow-y: auto;
    max-height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: color-mix(in srgb, var(--bg-white) 90%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 32px;
    box-shadow: var(--shadow-xl);
    animation: fadeInUp 0.5s ease;
    margin: auto 0;
}

.auth-card h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.auth-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 14px;
    position: relative;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-white);
    transition: var(--transition);
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-white);
    transition: var(--transition);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235f6368' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    white-space: nowrap;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 10%, transparent 10%);
    transform: scale(0);
    opacity: 0;
    transition: transform 0.5s, opacity 0.3s;
}

.btn:active::after {
    transform: scale(4);
    opacity: 1;
    transition: 0s;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

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

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--red);
    color: white;
}

.btn-danger:hover {
    background: #d32f2f;
}

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

.btn-ghost:hover {
    background: var(--bg-hover);
}

.btn-sm {
    padding: 6px 16px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 1.1rem;
    border-radius: var(--radius-lg);
}

.btn-full {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.auth-card .btn-full {
    margin-top: 10px;
}

.auth-switch {
    text-align: center;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    animation: fadeInDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
    animation: fadeInDown 0.3s ease;
}

/* ==================== MAIN APP LAYOUT ==================== */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100vw;
}

/* Header */
.app-header {
    height: var(--header-height);
    background: color-mix(in srgb, var(--bg-white) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    padding: 0 8px 0 16px;
    gap: 16px;
    z-index: 100;
    flex-shrink: 0;
}

.header-menu-btn {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    cursor: pointer;
}

.header-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.header-logo:hover .header-logo-icon {
    transform: scale(1.05);
}

.header-logo-icon svg {
    width: 22px;
    height: 22px;
}

.header-logo-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.header-logo-text span {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Search */
.search-container {
    flex: 1;
    max-width: 720px;
    position: relative;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg);
    border-radius: var(--radius-xl);
    padding: 0 16px;
    height: 48px;
    transition: var(--transition);
    border: 2px solid transparent;
}

.search-bar:focus-within {
    background: var(--bg-white);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.1);
}

.search-bar .material-icons-outlined {
    color: var(--text-light);
    font-size: 22px;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    padding: 0 12px;
}

.search-bar input::placeholder {
    color: var(--text-light);
}

.search-clear {
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
}

.search-bar input:not(:placeholder-shown) ~ .search-clear {
    opacity: 1;
}

.search-filters-toggle {
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: var(--transition);
    color: var(--text-light);
    font-size: 22px;
}

.search-filters-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    z-index: 1000;
    overflow: hidden;
    display: none;
}

.search-dropdown.open {
    display: block;
    animation: fadeInDown 0.15s ease;
}

.search-filter-chips {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.search-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.search-chip:hover {
    background: var(--bg-hover);
    border-color: var(--text-light);
}

.search-chip.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.custom-date-picker {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--bg);
}

.date-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-picker-row label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 36px;
}

.date-picker-row input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

.date-picker-row input[type="date"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.12);
}

.date-picker-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.date-picker-cancel,
.date-picker-apply {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.date-picker-cancel {
    background: var(--bg);
    color: var(--text-secondary);
}

.date-picker-cancel:hover {
    background: var(--bg-hover);
}

.date-picker-apply {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.date-picker-apply:hover {
    background: var(--primary-hover);
}

.search-suggestions {
    max-height: 340px;
    overflow-y: auto;
}

.search-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.1s;
}

.search-suggestion-item:hover,
.search-suggestion-item.active {
    background: var(--bg-hover);
}

.search-suggestion-content {
    flex: 1;
    min-width: 0;
}

.search-suggestion-subject {
    font-size: 0.9rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-suggestion-meta {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.search-suggestion-meta span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-suggestion-date {
    font-size: 0.8rem;
    color: var(--text-light);
    white-space: nowrap;
    flex-shrink: 0;
}

.search-suggestion-item mark {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--primary);
    border-radius: 2px;
    padding: 0 1px;
}

.search-no-results {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.search-dropdown-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-dropdown-footer:hover {
    background: var(--bg-hover);
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

.header-actions .btn-icon {
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.header-actions .btn-icon:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.avatar:hover {
    box-shadow: 0 0 0 3px var(--primary-light);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1.2rem;
}

/* Main content area */
.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: var(--transition-slow);
    z-index: 50;
}

.sidebar-compose {
    padding: 16px;
}

.compose-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 24px;
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.compose-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.4);
}

.compose-btn:active {
    transform: translateY(0);
}

.compose-btn .material-icons-outlined {
    font-size: 22px;
}

/* Folder list */
.folder-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
    user-select: none;
}

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

.folder-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.folder-item .material-icons-outlined {
    font-size: 20px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.folder-item.active .material-icons-outlined {
    color: var(--primary);
}

.folder-item .folder-name {
    flex: 1;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.folder-item .folder-shared-icon {
    font-size: 14px !important;
    color: var(--text-light) !important;
    opacity: 0.7;
    margin-left: -4px;
}

.folder-item.active .folder-shared-icon {
    color: var(--primary) !important;
    opacity: 0.8;
}

.folder-item .folder-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    min-width: 24px;
    text-align: right;
}

.folder-item.active .folder-count {
    color: var(--primary);
}

.folder-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 16px;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-light);
}

.sidebar-footer-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
}

.sidebar-footer-item:hover {
    background: var(--bg-hover);
    color: var(--text);
}

/* ==================== EMAIL LIST ==================== */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin: 0;
    will-change: opacity;
}

/* Toolbar */
.email-toolbar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 4px;
    flex-shrink: 0;
    min-height: 52px;
}

.toolbar-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    margin-right: 8px;
}

.toolbar-checkbox:hover {
    border-color: var(--primary);
}

.toolbar-checkbox.checked {
    background: var(--primary);
    border-color: var(--primary);
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.toolbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

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

.toolbar-btn .material-icons-outlined {
    font-size: 20px;
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-pagination {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 8px;
    white-space: nowrap;
}

/* Email list */
.email-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.email-list::-webkit-scrollbar {
    width: 8px;
}

.email-list::-webkit-scrollbar-track {
    background: transparent;
}

.email-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.email-list::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.email-row {
    display: flex;
    align-items: center;
    padding: 4px 16px;
    min-height: 44px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    animation: fadeIn 0.1s ease;
    will-change: transform;
}

.email-row:hover {
    background: var(--bg-hover);
    box-shadow: inset 3px 0 0 var(--primary);
}

.email-row.unread {
    background: var(--bg-white);
    font-weight: 600;
}

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

.email-row.selected {
    background: var(--primary-light);
}

.email-row.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.email-select-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 8px 8px 0;
    cursor: pointer;
    flex-shrink: 0;
}

.email-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.email-checkbox:hover, .email-checkbox.checked {
    border-color: var(--primary);
}

.email-checkbox.checked {
    background: var(--primary);
}

.email-checkbox.checked::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.email-star {
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
    flex-shrink: 0;
    margin-right: 8px;
    font-size: 20px;
}

.email-star:hover {
    color: var(--yellow);
}

.email-star.starred {
    color: var(--yellow);
}

.email-favicon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 6px;
    border-radius: 2px;
}

.email-sender {
    width: 200px;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    color: var(--text);
}

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

/* Thread conversation view */
.thread-messages {
    flex: 1;
    overflow-y: auto;
}

.thread-message.collapsed {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.1s;
}

.thread-message.collapsed:hover {
    background: var(--bg-hover);
}

.thread-message.expanded {
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 4px;
}

.thread-message.expanded .email-view-meta {
    border-bottom: none;
    padding-bottom: 4px;
}

.thread-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-hover);
    border-radius: 9px;
    vertical-align: middle;
    border: 1px solid var(--border-light);
}

.email-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
    min-width: 0;
}

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

.email-snippet {
    font-size: 0.9rem;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-subject-separator {
    color: var(--text-light);
    margin: 0 4px;
    flex-shrink: 0;
}

.email-attachment-icon {
    color: var(--text-light);
    font-size: 18px;
    flex-shrink: 0;
    margin-left: 4px;
}

.email-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 12px;
    min-width: 70px;
    text-align: right;
}

.email-row.unread .email-date {
    font-weight: 700;
    color: var(--text);
}

/* Email row hover actions */
.email-row-actions {
    display: none;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-hover);
    border-radius: var(--radius);
    padding: 2px;
    gap: 2px;
    z-index: 5;
}

.email-row:hover .email-row-actions {
    display: flex;
}

.email-row:hover .email-date {
    display: none;
}

/* ==================== EMAIL VIEW ==================== */
.email-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

.email-view-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-white);
    position: relative;
    z-index: 60;
    overflow: visible;
}

.email-view-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.email-view-reply-bar {
    padding: 12px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-white);
}

.email-view-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
}

.email-view-back {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.email-view-subject {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.4;
}

.email-view-meta {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
}

.email-view-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.email-view-meta-info {
    flex: 1;
    min-width: 0;
}

.email-view-from {
    font-weight: 600;
    font-size: 1rem;
}

.email-view-from-email {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.85rem;
}

.email-copyable {
    cursor: pointer;
    border-radius: 4px;
    padding: 1px 4px;
    margin: -1px -4px;
    transition: background 0.12s ease, color 0.12s ease;
}

.email-copyable:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.email-view-to {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.email-view-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.email-view-actions {
    display: flex;
    gap: 4px;
}

/* Email images banner */
.email-images-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.email-view-body {
    overflow-x: hidden;
    padding: 24px;
    word-break: break-word;
    overflow-wrap: break-word;
}

.email-view-body iframe {
    width: 100%;
    border: none;
    min-height: 300px;
}

.email-view-attachments {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.attachment-chip:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.attachment-chip .material-icons-outlined {
    font-size: 20px;
    color: var(--primary);
}

.attachment-size {
    color: var(--text-light);
    font-size: 0.8rem;
}

/* ==================== COMPOSE WINDOW ==================== */
.compose-window {
    position: fixed;
    bottom: 0;
    right: 80px;
    width: 580px;
    max-height: 600px;
    background: var(--bg-white);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    z-index: 200;
    animation: slideInUp 0.3s ease;
    border: 1px solid var(--border);
    border-bottom: none;
}

.compose-window.minimized {
    max-height: 48px;
    overflow: hidden;
}

.compose-window.fullscreen {
    position: fixed;
    top: 5%;
    left: 10%;
    right: 10%;
    bottom: 0;
    width: auto;
    max-height: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.compose-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--gradient);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    color: white;
    cursor: pointer;
    user-select: none;
}

.compose-header-title {
    flex: 1;
    font-size: 0.95rem;
    font-weight: 500;
}

.compose-header-actions {
    display: flex;
    gap: 4px;
}

.compose-header-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 50%;
    transition: var(--transition);
}

.compose-header-btn:hover {
    background: rgba(255,255,255,0.2);
}

.compose-header-btn .material-icons-outlined {
    font-size: 18px;
}

.compose-fields {
    padding: 0 16px;
    border-bottom: 1px solid var(--border-light);
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
}

.compose-field:last-child {
    border-bottom: none;
}

.compose-field label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 50px;
    flex-shrink: 0;
}

.compose-field input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    padding: 4px 0;
}

.compose-field .cc-bcc-toggle {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.compose-field .cc-bcc-toggle span {
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.compose-field .cc-bcc-toggle span:hover {
    background: var(--bg-hover);
    color: var(--primary);
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 300;
    animation: fadeInDown 0.15s ease;
}

.autocomplete-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: var(--transition);
}

.autocomplete-item:hover, .autocomplete-item.active {
    background: var(--primary-light);
}

.autocomplete-item .email {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.autocomplete-item .name {
    font-weight: 500;
    font-size: 0.9rem;
}

/* Rich text editor area */
.compose-editor-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 12px;
    gap: 2px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}

.editor-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 18px;
}

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

.editor-btn.active {
    background: var(--primary-light);
    color: var(--primary);
}

.editor-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 4px;
}

.editor-select {
    height: 30px;
    padding: 0 22px 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.78rem;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--bg-white);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%235f6368' d='M4 6L0 2h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
    outline: none;
    max-width: 110px;
    transition: var(--transition);
}

.editor-select:hover { border-color: var(--primary); }
.editor-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb),0.1); }

.color-picker-popup {
    animation: fadeInDown 0.15s ease;
}

.compose-body {
    flex: 1;
    min-height: 200px;
    overflow-y: auto;
}

.compose-body-editor {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    border: none;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    color: var(--text);
    resize: none;
}

.compose-body-editor[contenteditable] {
    overflow-y: auto;
}

.compose-body-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-light);
}

/* Compose attachments */
.compose-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border-light);
}

.compose-attachment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg);
    border-radius: var(--radius);
    font-size: 0.85rem;
    animation: fadeIn 0.2s ease;
}

.compose-attachment .remove {
    cursor: pointer;
    color: var(--text-light);
    transition: var(--transition);
}

.compose-attachment .remove:hover {
    color: var(--red);
}

.compose-attachment.loading {
    opacity: 0.7;
}

.attach-progress-track {
    width: 60px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.attach-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    transition: width 0.15s ease;
}

/* Compose footer */
.compose-footer {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 8px;
    border-top: 1px solid var(--border-light);
}

.compose-footer .btn-primary {
    border-radius: var(--radius-xl);
    padding: 10px 28px;
}

.compose-footer-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
}

/* Drop zone indicator */
.compose-dropzone {
    display: none;
    position: absolute;
    inset: 48px 0 0 0;
    background: rgba(var(--primary-rgb), 0.05);
    border: 3px dashed var(--primary);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    z-index: 10;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.compose-dropzone.active {
    display: flex;
}

.compose-dropzone .material-icons-outlined {
    font-size: 48px;
    color: var(--primary);
}

.compose-dropzone p {
    color: var(--primary);
    font-weight: 600;
}

/* ==================== SETTINGS PAGE ==================== */
.settings-page {
    padding: 32px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    animation: fadeInUp 0.3s ease;
}

.settings-page h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
}

.settings-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-card h3 .material-icons-outlined {
    color: var(--primary);
    font-size: 22px;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.ctx-menu-item:hover { background: var(--bg-hover); }

.ctx-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.ctx-has-sub { position: relative; }
.ctx-has-sub .ctx-submenu {
    display: none;
    position: absolute;
    left: calc(100% + 2px);
    top: -1px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    max-height: 320px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 401;
}
.ctx-has-sub:hover .ctx-submenu { display: block; }
.ctx-has-sub .ctx-submenu .ctx-menu-item { padding: 9px 14px; font-size: 0.875rem; }

.signature-editor-toolbar {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    gap: 2px;
    border: 2px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--bg);
    flex-wrap: wrap;
}

.signature-editor {
    width: 100%;
    min-height: 120px;
    max-height: 250px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg-white);
    outline: none;
    overflow-y: auto;
    line-height: 1.6;
    box-sizing: border-box;
}

.signature-editor:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.signature-editor:empty::before {
    content: attr(data-placeholder);
    color: var(--text-light);
}

/* ==================== ADMIN / USER MANAGER ==================== */
.admin-page {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    animation: fadeInUp 0.3s ease;
}

.admin-page h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 24px;
}

.users-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
}

.users-table th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.users-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.users-table tr:hover td {
    background: var(--bg-hover);
}

.users-table .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-green {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green);
}

.badge-red {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red);
}

.badge-blue {
    background: var(--primary-light);
    color: var(--primary);
}

/* ==================== SECURITY DASHBOARD ==================== */
.security-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.sec-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    border-radius: var(--radius) var(--radius) 0 0;
    position: relative;
}

.sec-tab .material-icons-outlined { font-size: 20px; }

.sec-tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.sec-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.sec-tab-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    background: var(--red);
    color: white;
    border-radius: 9px;
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.sec-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sec-stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius-lg);
    background: var(--bg-white);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.sec-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.sec-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sec-stat-icon .material-icons-outlined { font-size: 26px; }

.sec-stat-danger .sec-stat-icon { background: rgba(239,68,68,0.1); color: var(--red); }
.sec-stat-warning .sec-stat-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.sec-stat-success .sec-stat-icon { background: rgba(34,197,94,0.1); color: var(--green); }
.sec-stat-info .sec-stat-icon { background: var(--primary-light); color: var(--primary); }

.sec-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.sec-stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.sec-panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 16px;
}

.sec-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.sec-panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sec-panel-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.sec-panel-header h3 .material-icons-outlined { font-size: 20px; color: var(--primary); }

.sec-panel-body {
    padding: 16px 20px;
}

.sec-panel-body .users-table { border: none; }
.sec-panel-body .users-table th { background: transparent; border-bottom: 1px solid var(--border-light); }

.sec-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 0.9rem;
}

.sec-country-list { display: flex; flex-direction: column; gap: 8px; }

.sec-country-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sec-country-name {
    min-width: 100px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
}

.sec-country-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
}

.sec-country-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #6366f1);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.sec-country-count {
    min-width: 40px;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Security Alerts */
.sec-alerts-list { display: flex; flex-direction: column; gap: 8px; }

.sec-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-white);
    transition: background 0.2s;
}

.sec-alert-item:hover { background: var(--bg-hover); }

.sec-alert-resolved { opacity: 0.55; }

.sec-alert-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sec-alert-icon .material-icons-outlined { font-size: 20px; }

.sec-alert-high .sec-alert-icon { background: rgba(239,68,68,0.1); color: var(--red); }
.sec-alert-medium .sec-alert-icon { background: rgba(245,158,11,0.1); color: #f59e0b; }
.sec-alert-info .sec-alert-icon { background: var(--primary-light); color: var(--primary); }

.sec-alert-content { flex: 1; min-width: 0; }

.sec-alert-msg {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
}

.sec-alert-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-light);
}

.sec-alert-meta span { display: flex; align-items: center; gap: 3px; }

.sec-alert-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.sec-row-expired { opacity: 0.5; }

/* Security responsive */
@media (max-width: 768px) {
    .sec-stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sec-panels { grid-template-columns: 1fr; }
    .security-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .sec-tab { white-space: nowrap; padding: 8px 12px; font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .sec-stats-grid { grid-template-columns: 1fr; }
    .sec-stat-card { padding: 14px; }
}

/* ==================== CHAT WIDGET ==================== */
.chat-widget {
    position: fixed;
    bottom: 16px;
    right: 20px;
    z-index: 300;
}

.chat-toggle {
    width: 56px;
    height: 56px;
    background: var(--gradient);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.35);
    transition: var(--transition);
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(var(--primary-rgb), 0.45);
}

.chat-toggle .material-icons-outlined {
    font-size: 26px;
}

.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    animation: bounceIn 0.5s ease;
}

.chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 500px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: scaleIn 0.2s ease;
    border: 1px solid var(--border);
}

.chat-panel.open {
    display: flex;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--gradient);
    color: white;
    gap: 12px;
}

.chat-panel-header h3 {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
}

.chat-panel-header .btn-icon {
    color: white;
    background: rgba(255,255,255,0.15);
    border: none;
    width: 32px;
    height: 32px;
    backdrop-filter: blur(4px);
}
.chat-panel-header .btn-icon:hover {
    background: rgba(255,255,255,0.3);
}

/* Chat user list */
.chat-users {
    flex: 1;
    overflow-y: auto;
}

.chat-user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-light);
}

.chat-user-item:hover {
    background: var(--bg-hover);
}

.chat-user-item .online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-light);
    flex-shrink: 0;
}

.chat-user-item .online-dot.online {
    background: var(--green);
    box-shadow: 0 0 6px rgba(52, 168, 83, 0.5);
}

.chat-user-item .user-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.95rem;
}

.chat-user-item .unread-badge {
    background: var(--red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* Chat conversation */
.chat-conversation {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-conv-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--gradient);
    color: white;
    gap: 12px;
}

.chat-conv-header .back-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.chat-conv-header .user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-conv-header .online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    flex-shrink: 0;
}

.chat-conv-header .online-dot.online {
    background: #34d399;
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}

.chat-typing-bubble {
    background: var(--bg) !important;
    padding: 10px 14px !important;
    min-width: 50px;
    align-self: flex-start;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 16px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
    animation: fadeInUp 0.2s ease;
    word-break: break-word;
}

.chat-message.sent {
    align-self: flex-end;
    background: var(--gradient);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.received {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-message .time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.chat-message.file-message {
    padding: 8px;
}

.chat-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.chat-file-preview:hover {
    background: rgba(255,255,255,0.2);
}

.received .chat-file-preview {
    background: rgba(0,0,0,0.05);
}

.received .chat-file-preview:hover {
    background: rgba(0,0,0,0.1);
}

.chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid var(--border-light);
}

.chat-input-area input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 10px 16px;
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
    color: var(--text);
    background: var(--bg);
}

.chat-input-area input:focus {
    border-color: var(--primary);
}

.chat-input-area .send-btn {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: var(--transition);
}

.chat-input-area .send-btn:hover {
    background: var(--primary-dark);
}

.chat-input-area .file-btn {
    width: 38px;
    height: 38px;
    background: transparent;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.chat-input-area .file-btn:hover {
    background: var(--bg-hover);
}

/* ==================== AI ASSISTANT WIDGET ==================== */
.ai-assistant-widget {
    position: fixed;
    bottom: 82px;
    right: 20px;
    z-index: 300;
}

.ai-assistant-toggle {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
    transition: var(--transition);
    position: relative;
}

.ai-assistant-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(16, 185, 129, 0.45);
}

.ai-assistant-toggle .material-icons-outlined {
    font-size: 26px;
}

.ai-assistant-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 420px;
    height: 550px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: scaleIn 0.2s ease;
    border: 1px solid var(--border);
    z-index: 500;
}

.ai-assistant-panel.open {
    display: flex;
}

.ai-assistant-header {
    display: flex;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    gap: 10px;
}

.ai-assistant-header h3 {
    flex: 1;
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.ai-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-msg {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-msg.assistant {
    align-self: flex-start;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border-light);
    border-bottom-left-radius: 4px;
}

.ai-msg.assistant p { margin: 0 0 8px; }
.ai-msg.assistant p:last-child { margin: 0; }
.ai-msg.assistant ul, .ai-msg.assistant ol { margin: 4px 0; padding-left: 18px; }
.ai-msg.assistant code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; font-size: 0.85em; }
.ai-msg.assistant strong { font-weight: 600; }

.ai-msg.typing {
    align-self: flex-start;
    background: var(--bg-light);
    color: var(--text-light);
    font-style: italic;
}

.ai-assistant-input {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 8px;
    border-top: 1px solid var(--border-light);
    background: var(--bg-white);
}

.ai-assistant-input input {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.9rem;
    outline: none;
    background: var(--bg-light);
    transition: var(--transition);
}

.ai-assistant-input input:focus {
    border-color: #10b981;
    background: var(--bg-white);
}

.ai-assistant-input .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.ai-assistant-input .send-btn:hover {
    transform: scale(1.1);
}

.ai-assistant-input .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 12px;
}

.ai-suggestion-chip {
    background: var(--bg-light);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.ai-suggestion-chip:hover {
    background: #10b9811a;
    border-color: #10b981;
    color: #059669;
}

@media (max-width: 768px) {
    .ai-assistant-widget {
        bottom: 72px;
        right: 12px;
    }
    .ai-assistant-toggle {
        width: 48px;
        height: 48px;
    }
    .ai-assistant-toggle .material-icons-outlined {
        font-size: 22px;
    }
    .ai-assistant-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 400;
    }
}

/* ==================== LOADING / EMPTY STATES ==================== */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.empty-state .material-icons-outlined {
    font-size: 64px;
    color: var(--border);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    max-width: 400px;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg) 25%, var(--bg-hover) 50%, var(--bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
}

.skeleton-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.skeleton-circle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

.skeleton-line {
    height: 12px;
    border-radius: 6px;
}

/* ==================== NOTIFICATIONS / TOASTS ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-white);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.3s ease;
    pointer-events: auto;
    max-width: 500px;
}

.toast.error {
    background: var(--red);
    color: white;
    border-color: var(--red);
}

.toast.success {
    background: var(--green);
    color: white;
    border-color: var(--green);
}

.toast.error .toast-undo-btn,
.toast.success .toast-undo-btn {
    color: white;
}

.toast-action {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.toast-undo-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    white-space: nowrap;
}

.toast-undo-btn:hover {
    background: rgba(255,255,255,0.2);
}

@keyframes shrinkWidth {
    from { width: 100%; }
    to { width: 0%; }
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 500px;
    width: 90%;
    animation: scaleIn 0.2s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    flex: 1;
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-body {
    padding: 24px;
}

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

/* ==================== KEYBOARD SHORTCUTS HELP ==================== */
.shortcuts-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 600;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.shortcuts-modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

.shortcuts-modal h2 {
    font-size: 1.3rem;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shortcuts-group {
    margin-bottom: 20px;
}

.shortcuts-group h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    padding: 6px 0;
}

.shortcut-item .keys {
    min-width: 100px;
}

.shortcut-item kbd {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: 'Inter', monospace;
    margin-right: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.shortcut-item .desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== DRAG AND DROP ==================== */
.drag-over {
    background: var(--primary-light) !important;
    border: 2px dashed var(--primary) !important;
}

.email-row.drag-ghost {
    opacity: 0.4;
}

.folder-item.drag-target {
    background: var(--primary-light);
    transform: scale(1.02);
}

.folder-item.sidebar-drag-target {
    border-top: 2px solid var(--primary);
    margin-top: -2px;
}

.folder-item.dragging {
    opacity: 0.4;
}

.folder-item .folder-drag-handle {
    position: absolute;
    left: 2px;
    font-size: 16px;
    color: var(--text-light);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
}

.folder-item:hover .folder-drag-handle {
    opacity: 0.6;
}

.folder-item .folder-drag-handle:hover {
    opacity: 1;
}

/* ==================== TOUCH DEVICE OPTIMIZATIONS ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Disable hover-only actions on touch — show via swipe/long-press instead */
    .email-row:hover .email-row-actions {
        display: none;
    }
    .email-row:hover .email-date {
        display: block;
    }
    .email-row:hover {
        box-shadow: none;
    }
    /* Disable tooltips on touch */
    .toolbar-btn[data-tooltip]:hover::after,
    .toolbar-btn[data-tooltip]:hover::before,
    .btn-icon[data-tooltip]:hover::after,
    .btn-icon[data-tooltip]:hover::before,
    .btn[data-tooltip]:hover::after,
    .btn[data-tooltip]:hover::before {
        display: none !important;
    }
    /* Remove tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
    }
    /* Bigger touch targets for checkboxes */
    .email-checkbox, .toolbar-checkbox {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }
    /* Active states for touch feedback */
    .email-row:active {
        background: var(--bg-hover);
    }
    .toolbar-btn:active, .btn-icon:active, .btn:active {
        opacity: 0.7;
    }
    .folder-item:active {
        background: var(--bg-hover);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: var(--header-height);
        bottom: 0;
        width: 280px;
        z-index: 150;
        transition: var(--transition-slow);
        box-shadow: none;
    }

    .sidebar.open {
        left: 0;
        box-shadow: var(--shadow-xl);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-height);
        background: rgba(0,0,0,0.3);
        z-index: 140;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .header-menu-btn {
        display: flex !important;
    }

    .email-sender {
        width: 120px;
    }

    .compose-window {
        width: 100%;
        right: 0;
        left: 0;
        z-index: 250;
    }

    .chat-panel {
        width: 100%;
        height: 60vh;
        right: 0;
        bottom: 60px;
    }
}

@media (max-width: 768px) {
    /* Prevent iOS input zoom */
    .form-input, .form-select,
    .search-bar input,
    .compose-field input,
    .compose-body-editor,
    .chat-input-area input {
        font-size: 16px !important;
    }

    .auth-container {
        flex-direction: column;
        min-height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
    }

    .auth-left {
        flex: 0 0 auto;
        justify-content: flex-start;
        padding: max(32px, env(safe-area-inset-top) + 16px) 20px 12px;
        min-height: auto;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .auth-logo {
        gap: 10px;
        margin-bottom: 36px;
    }

    .auth-logo-icon {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .auth-logo-icon svg {
        width: 24px;
        height: 24px;
    }

    .auth-logo-text {
        font-size: 1.4rem;
    }

    .auth-left h1 {
        font-size: 1.5rem;
        margin-bottom: 4px;
        line-height: 1.2;
        text-align: center;
    }

    .auth-left p {
        font-size: 0.85rem;
        max-width: 30ch;
        margin-bottom: 0;
        line-height: 1.3;
    }

    .auth-features {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
        margin-top: 12px;
        max-width: 100%;
    }

    .auth-feature {
        padding: 6px 10px;
        border-radius: 10px;
        gap: 6px;
        font-size: 0.8rem;
    }

    .auth-feature .material-icons-outlined {
        font-size: 16px;
    }

    .auth-right {
        width: 100%;
        max-width: 100%;
        padding: 40px 16px 0;
        max-height: none;
        overflow-y: visible;
        box-sizing: border-box;
        flex: 1;
    }

    .auth-card {
        max-width: none;
        margin: 0;
        box-sizing: border-box;
        border-radius: 20px;
        padding: 24px 24px max(24px, env(safe-area-inset-bottom));
        background: color-mix(in srgb, var(--bg-white) 90%, transparent);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border-light);
        box-shadow: var(--shadow-xl);
        min-height: auto;
        margin-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .auth-card h2 {
        font-size: 1.4rem;
        margin-bottom: 4px;
    }

    .auth-card .subtitle {
        margin-bottom: 20px;
    }

    .email-sender {
        width: 80px;
    }

    .email-snippet {
        display: none;
    }

    .email-subject-separator {
        display: none;
    }

    .header-logo-text {
        display: none;
    }

    .header-logo {
        min-width: auto;
        gap: 8px;
    }

    /* Header tighter on mobile */
    .app-header {
        padding: 0 8px;
        gap: 6px;
        height: 56px;
    }

    :root {
        --header-height: 56px;
    }

    /* Hide non-essential header actions on mobile */
    #notifBtn,
    #shortcutsBtn,
    #themeBtn,
    .header-actions .btn-icon[title="Security"],
    .header-actions .btn-icon[title="User Manager"] {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
    }

    .header-actions {
        gap: 2px;
    }

    .header-actions .btn-icon {
        width: 36px;
        height: 36px;
    }

    .search-container {
        flex: 1;
        min-width: 0;
        max-width: calc(100% - 140px);
    }

    .search-filters-toggle {
        display: none;
    }

    .search-bar {
        height: 40px;
        padding: 0 10px;
    }

    .search-bar input {
        padding: 0 6px;
    }

    .search-bar input::placeholder {
        font-size: 0.85rem;
    }

    .search-dropdown {
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        border-radius: 0;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    /* Email list tighter */
    .email-row {
        padding: 6px 12px;
        gap: 6px;
    }

    .email-favicon {
        display: inline-block;
    }

    .email-date {
        font-size: 0.75rem;
        min-width: 55px;
        margin-left: 8px;
    }

    .email-attachment-icon {
        font-size: 16px !important;
    }

    /* Email view */
    .email-view-meta {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .email-view-date {
        width: 100%;
        margin-top: 4px;
    }

    .email-view-actions {
        width: 100%;
        justify-content: flex-start;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--border-light);
    }

    .email-view-body {
        padding: 16px;
    }

    .email-view-body iframe {
        min-height: 200px;
    }

    .email-view-attachments {
        padding: 12px 16px;
    }

    /* Compose mobile - force fullscreen */
    .compose-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100dvh;
        height: 100dvh;
        border-radius: 0;
        border: none;
        z-index: 300;
    }

    .compose-window.fullscreen {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: 100dvh;
        border-radius: 0;
    }

    .compose-header {
        border-radius: 0;
    }

    .compose-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .compose-footer {
        flex-shrink: 0;
        padding: 8px 12px;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .compose-footer .btn-primary {
        padding: 8px 20px;
        font-size: 0.85rem;
        flex-shrink: 0;
    }

    .compose-footer-actions {
        flex-shrink: 0;
    }

    /* Chat mobile */
    .chat-widget {
        bottom: 12px;
        right: 12px;
    }

    .chat-toggle {
        width: 48px;
        height: 48px;
    }

    .chat-toggle .material-icons-outlined {
        font-size: 22px;
    }

    .chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 400;
    }

    /* Settings */
    .settings-page {
        padding: 12px;
    }

    .settings-page h2 {
        font-size: 1.3rem;
        margin-bottom: 16px;
    }

    .settings-card {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: var(--radius);
    }

    .settings-card h3 {
        font-size: 1rem;
        margin-bottom: 14px;
        padding-bottom: 10px;
    }

    .settings-actions {
        flex-direction: column;
    }

    .settings-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .signature-editor-toolbar {
        flex-wrap: wrap;
    }

    /* Toolbar */
    .email-toolbar {
        padding: 6px 12px;
        min-height: 44px;
    }

    .toolbar-pagination {
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 20px 16px max(16px, env(safe-area-inset-bottom));
        border-radius: 16px;
    }

    .auth-left {
        padding: max(28px, env(safe-area-inset-top) + 12px) 16px 8px;
    }

    .auth-logo {
        gap: 8px;
        margin-bottom: 28px;
    }

    .auth-logo-icon {
        width: 36px;
        height: 36px;
        border-radius: 10px;
    }

    .auth-logo-icon svg {
        width: 20px;
        height: 20px;
    }

    .auth-logo-text {
        font-size: 1.2rem;
    }

    .auth-left h1 {
        font-size: 1.25rem;
        margin-bottom: 4px;
    }

    .auth-left p {
        font-size: 0.8rem;
        line-height: 1.3;
        margin-bottom: 0;
    }

    .auth-features {
        gap: 5px;
        margin-top: 10px;
    }

    .auth-feature {
        padding: 5px 8px;
        gap: 5px;
    }

    .auth-feature .material-icons-outlined {
        font-size: 14px;
    }

    .auth-feature span {
        font-size: 0.7rem;
    }

    .auth-right {
        padding: 36px 16px 0;
        flex: 0;
    }

    .settings-page {
        padding: 8px;
    }

    .settings-card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .settings-card h3 {
        font-size: 0.95rem;
        gap: 6px;
    }

    .settings-card h3 .material-icons-outlined {
        font-size: 18px;
    }

    .form-group label {
        font-size: 0.78rem;
    }

    .form-input, .form-select {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    /* Toolbar: only key actions */
    .email-toolbar .toolbar-btn:not(:first-child):not(:last-child) {
        display: none;
    }

    .email-toolbar .toolbar-separator {
        display: none;
    }

    .email-view-header {
        padding: 10px 12px;
    }

    .email-view-subject {
        font-size: 1.05rem;
    }

    .email-view-back .toolbar-btn {
        width: 32px;
        height: 32px;
    }

    .email-view-body {
        padding: 12px;
    }

    /* Email row: slim for small screens */
    .email-row {
        padding: 6px 8px;
        gap: 4px;
    }

    .email-sender {
        width: 70px;
        font-size: 0.8rem;
    }

    .email-subject {
        font-size: 0.85rem;
    }

    .email-date {
        min-width: 45px;
        font-size: 0.7rem;
    }

    .email-select-zone {
        padding: 4px 4px 4px 0;
    }

    .email-star {
        margin-right: 2px;
        font-size: 14px;
    }

    .email-checkbox,
    .toolbar-checkbox {
        width: 14px;
        height: 14px;
        min-width: 14px;
        border-width: 1.5px;
        border-radius: 3px;
        margin-right: 0;
    }

    .email-checkbox.checked::after,
    .toolbar-checkbox.checked::after {
        width: 3px;
        height: 7px;
        border-width: 0 1.5px 1.5px 0;
        margin-bottom: 1px;
    }

    .toolbar-checkbox {
        margin-right: 4px;
    }

    /* Compose */
    .compose-field label {
        min-width: 36px;
        font-size: 0.8rem;
    }

    /* Header */
    .app-header {
        gap: 4px;
        padding: 0 4px;
    }

    .header-actions .btn-icon {
        width: 32px;
        height: 32px;
    }

    .header-actions .btn-icon .material-icons-outlined {
        font-size: 20px;
    }

    /* Hide non-essential actions on small screens */
    #notifBtn,
    #shortcutsBtn,
    #themeBtn,
    .header-actions .btn-icon[title="Settings"],
    .header-actions .btn-icon[title="Security"],
    .header-actions .btn-icon[title="User Manager"] {
        display: none !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        padding: 0 !important;
        margin: 0 !important;
        border: 0 !important;
    }

    .header-actions {
        gap: 1px;
    }

    .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    .search-container {
        max-width: calc(100vw - 180px);
    }

    /* Search */
    .search-bar {
        height: 36px;
        padding: 0 8px;
    }

    .search-bar .material-icons-outlined {
        font-size: 20px;
    }

    .search-filters-toggle {
        display: none;
    }

    .search-chip {
        padding: 5px 10px;
        font-size: 0.8rem;
    }

    /* Sidebar full-width on smallest devices */
    .sidebar {
        width: 100% !important;
        left: -100% !important;
    }

    .sidebar.open {
        left: 0 !important;
    }
}

/* Utility classes */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.p-16 { padding: 16px; }
.text-center { text-align: center; }
.text-sm { font-size: 0.85rem; }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* Custom Tooltips - uses data-tooltip to avoid native browser tooltip doubling */
.toolbar-btn[data-tooltip],
.btn-icon[data-tooltip],
.btn[data-tooltip] {
    position: relative;
}

.toolbar-btn[data-tooltip]:hover::after,
.btn-icon[data-tooltip]:hover::after,
.btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg-white);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 500;
    pointer-events: none;
    animation: fadeIn 0.12s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.toolbar-btn[data-tooltip]:hover::before,
.btn-icon[data-tooltip]:hover::before,
.btn[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--text);
    z-index: 500;
    pointer-events: none;
}

/* Tooltips on bottom for header buttons */
.app-header .btn-icon[data-tooltip]:hover::after {
    bottom: auto;
    top: calc(100% + 6px);
}

.app-header .btn-icon[data-tooltip]:hover::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--text);
}

/* Tooltips on bottom for email view toolbar and action buttons */
.email-view-toolbar .toolbar-btn[data-tooltip]:hover::after,
.email-view-back .toolbar-btn[data-tooltip]:hover::after,
.email-view-actions .toolbar-btn[data-tooltip]:hover::after {
    bottom: auto;
    top: calc(100% + 6px);
}

.email-view-toolbar .toolbar-btn[data-tooltip]:hover::before,
.email-view-back .toolbar-btn[data-tooltip]:hover::before,
.email-view-actions .toolbar-btn[data-tooltip]:hover::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--text);
}

/* Tooltips on bottom for email toolbar buttons */
.email-toolbar .toolbar-btn[data-tooltip]:hover::after {
    bottom: auto;
    top: calc(100% + 6px);
}

.email-toolbar .toolbar-btn[data-tooltip]:hover::before {
    bottom: auto;
    top: calc(100% + 2px);
    border-top-color: transparent;
    border-bottom-color: var(--text);
}

/* Tooltips on top for compose footer buttons */
.compose-footer .toolbar-btn[data-tooltip]:hover::after,
.compose-footer .btn[data-tooltip]:hover::after {
    bottom: calc(100% + 6px);
    top: auto;
}

/* Print styles */
@media print {
    .sidebar, .app-header, .email-toolbar, .chat-widget, .ai-assistant-widget, .compose-window {
        display: none !important;
    }

    .email-view {
        overflow: visible !important;
    }
}
