/* ============================================================
   Math Department Management System - style.css (rebuilt)
   ============================================================ */

/* ---- CSS Variables (design tokens) ---- */
:root {
    --primary:        #4F46E5;
    --primary-dark:   #4338CA;
    --primary-light:  #818CF8;
    --success:        #10B981;
    --success-dark:   #059669;
    --danger:         #EF4444;
    --danger-dark:    #DC2626;
    --warning:        #F59E0B;
    --warning-dark:   #D97706;
    --info:           #3B82F6;

    --bg-main:        #F9FAFB;
    --bg-card:        #FFFFFF;
    --bg-sidebar:     #111827;

    --text-primary:   #111827;
    --text-secondary: #6B7280;
    --text-light:     #9CA3AF;
    --text-inverse:   #FFFFFF;

    --border:         #E5E7EB;
    --border-dark:    #D1D5DB;

    --shadow-sm:      0 1px 3px rgba(0,0,0,0.05);
    --shadow-md:      0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg:      0 10px 25px rgba(0,0,0,0.10);

    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      14px;
    --radius-full:    999px;

    --space-xs:       4px;
    --space-sm:       8px;
    --space-md:       14px;
    --space-lg:       22px;
    --space-xl:       32px;

    --sidebar-w:      260px;
    --transition:     all 0.18s ease;
}

[data-theme="dark"] {
    --bg-main:        #0F172A;
    --bg-card:        #1E293B;
    --bg-sidebar:     #0B1120;
    --text-primary:   #F1F5F9;
    --text-secondary: #94A3B8;
    --text-light:     #64748B;
    --border:         #334155;
    --border-dark:    #475569;
}

/* ---- Base ---- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: var(--transition);
}

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

button, .btn { font-family: inherit; cursor: pointer; }

.hidden { display: none !important; }

/* Utility spacing */
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mb-3 { margin-bottom: var(--space-lg); }
.gap-2 { gap: var(--space-md); }
.text-center { text-align: center; }
.flex { display: flex; }

/* ---- Layout ---- */
.layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-main);
    width: 100%;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: #E5E7EB;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
}

.content, main.main {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--space-md) var(--space-lg);
    width: 100%;
}
main.main .content { padding: 0; }
main.main > .header { padding: 0 var(--space-lg); }

/* ---- Sidebar ---- */
.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}
.sidebar-title { font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-subtitle { font-size: 0.75rem; color: #9CA3AF; }

.sidebar-user {
    padding: var(--space-lg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    text-align: center;
}
.sidebar-user .avatar {
    width: 60px; height: 60px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    color: white; font-weight: 700; font-size: 1.3rem;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 10px;
}
.sidebar-user .name { color: white; font-weight: 600; font-size: 0.95rem; }
.sidebar-user .role-container { margin-top: 8px; }
.sidebar-user .role {
    display: inline-block;
    background: rgba(79,70,229,0.2);
    color: #C7D2FE;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.sidebar-nav { padding: var(--space-md) 0; flex: 1; }
.sidebar-nav-section { padding: var(--space-md) var(--space-lg) 4px; }
.sidebar-nav-title {
    color: #6B7280;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}
.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px var(--space-lg);
    color: #D1D5DB;
    font-size: 0.9rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.sidebar-nav-item:hover {
    background: rgba(79,70,229,0.15);
    color: #fff;
}
.sidebar-nav-item.active {
    background: rgba(79,70,229,0.25);
    color: #fff;
    border-left-color: var(--primary);
    font-weight: 500;
}
.sidebar-nav-item .icon { font-size: 1.05rem; width: 22px; text-align: center; }

/* ---- Header (top of content) ---- */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    gap: 20px;
    flex-wrap: wrap;
    padding: 10px 0 14px;
    border-bottom: 1px solid var(--border);
}
.header-title { font-size: 1.35rem; font-weight: 700; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.header-search {
    position: relative;
    max-width: 420px;
    flex: 1;
}
.header-search input {
    width: 100%;
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--bg-card);
    font-size: 0.9rem;
    color: var(--text-primary);
}
.header-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 1.1rem;
}

/* ---- Page header (inside content) ---- */
.page-header { margin-bottom: var(--space-lg); }
.page-title { font-size: 1.75rem; font-weight: 700; margin-bottom: 4px; }
.page-subtitle { color: var(--text-secondary); font-size: 0.95rem; }

/* ---- Cards ---- */
.card, .card-section, .stat-card, .action-card, .choice-card, .behavior-card,
.material-card, .student-info-card, .profile-header, .add-custom-tile {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card { margin-bottom: var(--space-lg); }
.card-title { font-size: 1.05rem; font-weight: 600; margin-bottom: var(--space-md); color: var(--text-primary); }

/* Stat cards on dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    width: 100%;
}
.stat-card {
    padding: var(--space-lg);
    display: flex; flex-direction: column; gap: 6px;
    border-left: 4px solid var(--primary);
}
.stat-card.primary { border-left-color: var(--primary); }
.stat-card.info    { border-left-color: var(--info); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.danger  { border-left-color: var(--danger); }
.stat-card .icon { font-size: 1.7rem; }
.stat-card .label { color: var(--text-secondary); font-size: 0.85rem; }
.stat-card .value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); }
.stat-card .trend { font-size: 0.78rem; color: var(--text-light); }
.stat-card .num { font-weight: 700; }

/* Quick action grid on dashboard */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    width: 100%;
}
.action-card {
    padding: var(--space-lg);
    border-left: 4px solid var(--primary);
    display: block;
    color: var(--text-primary);
}
.action-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}
.action-card.academic   { border-left-color: var(--info); }
.action-card.behavioral { border-left-color: var(--warning); }
.action-card.materials  { border-left-color: var(--success); }
.action-card .icon { font-size: 2rem; margin-bottom: 8px; }
.action-card h3 { margin-bottom: 4px; }
.action-card p { color: var(--text-secondary); font-size: 0.85rem; }

/* ---- Welcome banner ---- */
.welcome-banner {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    padding: var(--space-lg) var(--space-xl);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-md);
}
.welcome-banner h2 { color: white; margin-bottom: 4px; }
.welcome-banner p { opacity: 0.95; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-main); }
.btn-success   { background: var(--success); color: white; }
.btn-success:hover:not(:disabled)   { background: var(--success-dark); }
.btn-danger    { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled)    { background: var(--danger-dark); }
.btn-warning   { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled)   { background: var(--warning-dark); }

/* Action buttons on behavioral/academic pages */
.action-buttons, .send-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-top: var(--space-md);
}
.action-btn, .send-btn {
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.action-btn:hover:not(:disabled),
.send-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.action-btn:disabled, .send-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-log        { background: #6B7280; }
.btn-parents    { background: #F59E0B; }
.btn-hod-parents{ background: #4F46E5; }
.btn-whatsapp   { background: #25D366; }
.btn-positive   { background: #10B981; }
.parents-btn    { background: #F59E0B; color: white; }
.hod-btn        { background: #4F46E5; color: white; }
.student-btn    { background: #7C3AED; color: white; }
.whatsapp-btn   { background: #25D366; color: white; }
.self-btn       { background: #6B7280; color: white; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-danger  { background: #FEE2E2; color: #991B1B; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-primary { background: #E0E7FF; color: #3730A3; }

/* Type badges on materials */
.type-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    background: #E5E7EB;
    color: #374151;
}

/* ---- Forms ---- */
.form-group { margin-bottom: var(--space-md); }
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}
.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input, input[type="text"], input[type="email"], input[type="url"],
input[type="password"], input[type="search"], input[type="number"], input[type="date"],
select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: inherit;
    transition: var(--transition);
}
.form-input:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.15);
}
textarea { resize: vertical; min-height: 80px; }

/* ---- Alerts / flash messages ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border-left: 4px solid var(--info);
    background: #EFF6FF;
    color: #1E3A8A;
    font-size: 0.9rem;
}
.alert-success { background: #D1FAE5; color: #065F46; border-color: var(--success); }
.alert-danger  { background: #FEE2E2; color: #991B1B; border-color: var(--danger); }
.alert-warning { background: #FEF3C7; color: #92400E; border-color: var(--warning); }
.alert-info    { background: #DBEAFE; color: #1E40AF; border-color: var(--info); }

/* ---- Step indicator (used in academic/behavioral flows) ---- */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}
.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.step.active { background: var(--primary); color: white; border-color: var(--primary); font-weight: 600; }
.step.done   { background: var(--success); color: white; border-color: var(--success); }
.step-back {
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}
.step-back:hover { background: var(--bg-card); }

/* ---- Choice grid (used to pick assessment type, etc.) ---- */
.choice-grid, .behavior-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}
.choice-card, .behavior-card {
    padding: var(--space-lg);
    text-align: center;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: var(--transition);
}
.choice-card:hover, .behavior-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.choice-card.active, .behavior-card.active {
    border-color: var(--primary);
    background: rgba(79,70,229,0.05);
}

/* ---- Student search dropdown ---- */
.student-search { position: relative; margin-top: var(--space-md); }
.student-dropdown {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 8px;
    background: var(--bg-card);
}
.student-option {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    gap: 10px;
}
.student-option:last-child { border-bottom: none; }
.student-option:hover { background: var(--bg-main); }
.student-info-card {
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-left: 4px solid var(--primary);
    padding: var(--space-md) var(--space-lg);
}
.student-info-card h4 { color: #3730A3; margin-bottom: 8px; }
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
.info-item { background: rgba(255,255,255,0.6); padding: 8px 12px; border-radius: var(--radius-sm); }
.info-item .label { display: block; font-size: 0.72rem; color: var(--text-secondary); font-weight: 600; }
.info-item .value { display: block; font-weight: 600; color: var(--text-primary); }

/* ---- Occurrence indicators ---- */
.occurrence-indicator {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border-left: 6px solid;
    margin-bottom: var(--space-md);
}
.occurrence-indicator h3 { margin-bottom: 8px; }
.occurrence-1 { background: #D1FAE5; border-left-color: #10B981; }
.occurrence-2 { background: #FEF3C7; border-left-color: #F59E0B; }
.occurrence-3 { background: #FEE2E2; border-left-color: #EF4444; }
.occurrence-positive { background: #E0E7FF; border-left-color: #4F46E5; }

/* ---- Progress bars ---- */
.progress-bar, .progress-bar-bg {
    background: var(--bg-main);
    height: 8px;
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill, .progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
    width: 0%;
    transition: width 0.3s;
}

/* ---- Materials grid (fallback if page-inline CSS is missing) ---- */
.material-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-md);
}
.material-card {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-main);
}
.material-card h4 { font-size: 0.95rem; margin: 4px 0; }
.material-card .meta { font-size: 0.75rem; color: var(--text-secondary); margin-bottom: 8px; }
.material-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Tabs ---- */
.tabs-mini {
    display: flex;
    gap: 10px;
    margin-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.tab-mini {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    font-weight: 500;
    color: var(--text-secondary);
}
.tab-mini.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- Toolbar button ---- */
.toolbar-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
}
.toolbar-btn:hover { background: var(--bg-main); }
.toolbar-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ---- Editor + attachments (academic page) ---- */
.editor-toolbar-custom {
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}
.upload-mini-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.auto-save-indicator {
    color: var(--success);
    font-size: 0.78rem;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.3s;
}
.auto-save-indicator.show { opacity: 1; }

.attachment-section {
    margin-top: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px dashed var(--border-dark);
    border-radius: var(--radius-md);
}
.attached-files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.attached-file {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}
.attached-file .remove {
    cursor: pointer;
    color: var(--danger);
    background: none;
    border: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.attached-file .remove:hover { background: #FEE2E2; }

.upload-zone {
    border: 2px dashed var(--border-dark);
    padding: var(--space-lg);
    text-align: center;
    border-radius: var(--radius-lg);
    background: var(--bg-main);
    transition: var(--transition);
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(79,70,229,0.05);
}
.upload-progress { margin-top: 12px; display: none; }
.upload-progress.show { display: block; }

/* ---- Undo toast ---- */
.undo-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text-primary);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    display: none;
    gap: 14px;
    align-items: center;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    font-size: 0.9rem;
}
.undo-toast button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
}
.undo-toast button:hover { background: var(--primary-dark); }

/* ---- Modal ---- */
.modal { }
.modal-content {
    background: var(--bg-card);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* ---- Profile page ---- */
.profile-header {
    display: flex;
    gap: var(--space-lg);
    align-items: center;
    padding: var(--space-lg);
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-left: 4px solid var(--primary);
}
.profile-avatar {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-weight: 700;
    font-size: 2rem;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.profile-info h2 { color: #3730A3; margin-bottom: 4px; }
.profile-info p { color: var(--text-secondary); font-size: 0.9rem; }
.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-md);
}
.profile-stat {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-align: center;
}
.profile-stat .num { display: block; font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.profile-stat .name { color: var(--text-secondary); font-size: 0.78rem; }

/* Timeline (activity log / student profile) */
.timeline-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item .time { font-size: 0.75rem; color: var(--text-light); min-width: 90px; }

/* ---- Emoji-picker fallback ---- */
emoji-picker {
    --emoji-size: 1.15rem;
    max-width: 100%;
    display: none;
}
emoji-picker.show { display: block; }

/* ---- Footer ---- */
.footer {
    margin-top: var(--space-xl);
    padding: var(--space-md) 0;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-light);
    font-size: 0.8rem;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
    }
    .content { padding: var(--space-md); }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-title { font-size: 1.4rem; }
    .header { flex-direction: column; align-items: stretch; }
    .action-buttons, .send-buttons { grid-template-columns: 1fr; }
}

/* ---- Scrollbars (Chromium) ---- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================================================
   Login page — activated by adding class="login-page" to <body>
   ============================================================ */
body.login-page {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 50%, #C7D2FE 100%) !important;
    padding: 30px 20px;
    flex-direction: column;
    gap: 0;
}

/* Everything that sits directly inside the login body — center it */
body.login-page > * {
    max-width: 460px;
    width: 100%;
    box-sizing: border-box;
}

/* Logo image at top */
body.login-page > img,
body.login-page .login-logo {
    display: block;
    max-width: 130px;
    height: auto;
    margin: 0 auto 20px;
}

/* Title and subtitle */
body.login-page > h1 {
    text-align: center;
    font-size: 1.8rem;
    color: var(--primary-dark);
    margin: 0 0 4px 0;
}

body.login-page > p,
body.login-page > h2 {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    margin: 0 0 24px 0;
}

/* The form becomes the white card */
body.login-page > form {
    background: white;
    padding: 32px 30px;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(79, 70, 229, 0.18);
    margin: 0;
}

body.login-page label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

body.login-page input {
    width: 100%;
    margin-bottom: 16px;
    box-sizing: border-box;
}

body.login-page input:last-of-type {
    margin-bottom: 20px;
}

body.login-page button[type="submit"],
body.login-page .btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), #7C3AED);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}
body.login-page button[type="submit"]:hover,
body.login-page .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
}

/* "Forgot password?" bottom line */
body.login-page > p:last-child,
body.login-page .login-footer {
    color: var(--text-light);
    font-size: 0.82rem;
    margin-top: 16px;
    margin-bottom: 0;
}

/* Modern browser bonus: try to auto-center login pages that DIDN'T get the class */
@supports selector(:has(*)) {
    body:not(.login-page):not(:has(> .layout)) {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
        min-height: 100vh;
        background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 50%, #C7D2FE 100%);
        padding: 30px 20px;
    }
    body:not(.login-page):not(:has(> .layout)) > * {
        max-width: 460px;
        width: 100%;
    }
    body:not(.login-page):not(:has(> .layout)) > form {
        background: white;
        padding: 30px;
        border-radius: var(--radius-lg);
        box-shadow: 0 20px 50px rgba(79, 70, 229, 0.15);
    }
    body:not(.login-page):not(:has(> .layout)) > img {
        max-width: 130px;
        display: block;
        margin: 0 auto 16px;
    }
    body:not(.login-page):not(:has(> .layout)) > h1,
    body:not(.login-page):not(:has(> .layout)) > p {
        text-align: center;
    }
}
