:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --sidebar-bg: #ffffff;
    --sidebar-text: #475569;
    --sidebar-hover: #f1f5f9;
    --active-item: #e0e7ff;
    --active-text: #4f46e5;
    --content-bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', sans-serif; background: var(--content-bg); color: var(--text-main); height: 100vh; display: flex; overflow: hidden; font-size: 15px; }

/* SIDEBAR */
.sidebar { width: 280px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid var(--border); box-shadow: var(--shadow-sm); z-index: 10; }
.brand { padding: 24px; font-size: 1.25rem; font-weight: 700; color: var(--text-main); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; letter-spacing: -0.025em; }
.brand i { color: var(--primary); font-size: 1.5rem; }
.user-info { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.user-info .avatar { width: 40px; height: 40px; background: var(--active-item); color: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1.1rem; }
.user-info div { font-weight: 600; color: var(--text-main); }
.user-info small { color: var(--text-muted); display: block; font-weight: 400; font-size: 0.85rem;}

.menu-label { padding: 16px 24px 8px; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 700; letter-spacing: 0.05em; }
.menu { list-style: none; padding: 0 12px; margin: 0; flex-grow: 1; overflow-y: auto; }
.menu li { margin-bottom: 4px; }
.menu li a { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--sidebar-text); text-decoration: none; font-size: 0.95rem; font-weight: 500; border-radius: var(--radius-sm); transition: var(--transition); }
.menu li a i { font-size: 1.1rem; width: 20px; text-align: center; color: #94a3b8; transition: var(--transition); }
.menu li a:hover { background: var(--sidebar-hover); color: var(--text-main); }
.menu li a:hover i { color: var(--sidebar-text); }
.menu li a.active { background: var(--active-item); color: var(--active-text); }
.menu li a.active i { color: var(--active-text); }

.submenu { padding-left: 10px; margin-top: 4px; margin-bottom: 12px; border-left: 2px solid var(--border); margin-left: 22px; }
.submenu li a { padding: 8px 16px; font-size: 0.9rem; border-radius: var(--radius-sm); }
.submenu li a.active-sub { color: var(--primary); font-weight: 600; background: transparent; }
.submenu li a.active-sub::before { content: ''; position: absolute; left: 20px; width: 6px; height: 6px; background: var(--primary); border-radius: 50%; }

.bottom-actions { padding: 16px 12px; border-top: 1px solid var(--border); background: #fdfdfd; }
.logout a { color: var(--danger); }
.logout a i { color: var(--danger); }
.logout a:hover { background: #fef2f2; color: var(--danger-hover); }

/* MAIN CONTENT */
.main-content { flex: 1; min-height: 0; min-width: 0; overflow-y: auto; padding: 40px; display: block; background: var(--content-bg); }
.header-title { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; }
.header-title h1 { margin: 0; font-size: 1.8rem; font-weight: 700; color: var(--text-main); letter-spacing: -0.025em; }
.header-title small { font-size: 1rem; color: var(--text-muted); font-weight: 500; }

/* CARDS & FORMS */
.card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 30px; border: 1px solid #f1f5f9; margin-bottom: 24px; transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-md); }
.card h3 { margin-top: 0; font-weight: 600; color: var(--text-main); margin-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }

label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 500; color: var(--text-main); }
input, select, textarea { width: 100%; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit; transition: var(--transition); background: #f8fafc; color: var(--text-main); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1); }

.btn { padding: 10px 20px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; transition: var(--transition); justify-content: center; }
.btn-primary { background: var(--primary); color: white; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: white; color: var(--text-main); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }

/* TABLE */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th { text-align: left; padding: 16px; border-bottom: 2px solid var(--border); font-size: 0.85rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; letter-spacing: 0.05em; }
.data-table td { padding: 16px; border-bottom: 1px solid var(--border); font-size: 0.95rem; vertical-align: middle; transition: var(--transition); }
.data-table tr { transition: var(--transition); }
.data-table tbody tr:hover td { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ALERTS */
.alert { padding: 16px 20px; border-radius: var(--radius-sm); margin-bottom: 24px; display: flex; align-items: center; gap: 12px; font-weight: 500; animation: slideDown 0.3s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* LOGIN SCREEN */
.login-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #4f46e5 0%, #0ea5e9 100%); margin: 0; font-family: 'Inter', sans-serif;}
.login-card { background: rgba(255, 255, 255, 0.95); padding: 48px 40px; border-radius: 20px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); width: 100%; max-width: 420px; margin: auto; backdrop-filter: blur(10px); }
.login-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 8px; text-align: center; color: var(--text-main); letter-spacing: -0.025em; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }
.login-card .form-group { margin-bottom: 20px; }
.login-card .btn-login { width: 100%; padding: 14px; background: var(--primary); color: white; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem; font-weight: 600; margin-top: 10px; transition: var(--transition); box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3); }
.login-card .btn-login:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4); }

/* EMAIL LIST SPECIFIC */
.email-row { cursor: pointer; transition: var(--transition); }
.email-row.unread td { font-weight: 700; color: var(--text-main); background: #ffffff; }
.email-row.read td { color: var(--text-muted); }
.unread-badge { background: var(--primary); color: white; font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: auto; display: none; }

.star-btn { color: #cbd5e1; cursor: pointer; text-decoration: none; font-size: 1.1rem; transition: var(--transition); display: inline-block; padding: 4px; }
.star-btn:hover { transform: scale(1.1); }
.star-btn.starred { color: var(--warning); }
.action-btn { color: var(--text-muted); margin-left: 12px; cursor: pointer; transition: var(--transition); font-size: 1.1rem; padding: 4px; display: inline-block; }
.action-btn:hover { color: var(--danger); transform: scale(1.1); }
.compose-link { background: var(--primary) !important; color: white !important; font-weight: 600 !important; border-radius: var(--radius-sm); margin: 10px 16px; justify-content: center; box-shadow: var(--shadow-sm); }
.compose-link:hover { background: var(--primary-hover) !important; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.compose-link i { color: white !important; }

/* EDITOR */
.editor-container { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.editor-toolbar { background: #f8fafc; border-bottom: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; }
.editor-btn { background: white; color: var(--text-main); border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; }
.editor-btn:hover { background: #f1f5f9; color: var(--primary); border-color: #cbd5e1; }
.editor-content { min-height: 300px; padding: 20px; outline: none; overflow-y: auto; font-size: 0.95rem; line-height: 1.6; }

/* VIEW EMAIL */
.email-header { border-bottom: 1px solid var(--border); margin-bottom: 24px; padding-bottom: 20px; }
.email-header h2 { margin: 0 0 12px 0; font-size: 1.5rem; letter-spacing: -0.025em; }
.email-sender { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.email-sender .avatar { width: 40px; height: 40px; background: #e2e8f0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; color: #64748b; }
.email-content { font-size: 1rem; line-height: 1.7; color: #334155; overflow-x: auto; }

@keyframes highlightNew { 0% { background-color: var(--success-bg); } 100% { background-color: transparent; } }
.new-email-row td { animation: highlightNew 3s ease-out; }

/* RESPONSIVE */
@media (max-width: 768px) {
    body { flex-direction: column; overflow: auto; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
    .menu { display: flex; overflow-x: auto; margin: 0; padding: 10px; gap: 10px; white-space: nowrap; }
    .menu li a { padding: 8px 16px; background: #f1f5f9; }
    .submenu { display: none; }
    .main-content { padding: 20px; }
    .header-title { flex-direction: column; align-items: flex-start; gap: 10px; }
    .form-grid { grid-template-columns: 1fr; }
}