/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: #1a1a1a; background: #f5f5f5; }
a { color: #0066cc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.layout { display: flex; height: 100vh; }
.sidebar { width: 240px; background: #1e293b; color: #e2e8f0; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 16px; border-bottom: 1px solid #334155; }
.sidebar-header h2 { font-size: 18px; color: #fff; margin-bottom: 4px; }
.sidebar-header .user-name { font-size: 12px; color: #94a3b8; }
.sidebar-actions { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.sidebar-search { padding: 0 16px 12px; }
.sidebar-search input { width: 100%; padding: 6px 10px; border: 1px solid #475569; border-radius: 4px; background: #334155; color: #e2e8f0; font-size: 13px; }
.sidebar-search input::placeholder { color: #94a3b8; }
.folder-list { list-style: none; flex: 1; overflow-y: auto; }
.folder-list li a { display: flex; justify-content: space-between; padding: 8px 16px; color: #cbd5e1; font-size: 13px; transition: background 0.15s; }
.folder-list li a:hover { background: #334155; text-decoration: none; }
.folder-list li.active a { background: #334155; color: #fff; font-weight: 600; }
.folder-list li.folder-child a { padding-left: 32px; font-size: 12px; }
.badge { background: #3b82f6; color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 10px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid #334155; display: flex; flex-direction: column; gap: 8px; }
.content { flex: 1; overflow-y: auto; padding: 0; background: #fff; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; color: #374151; font-size: 13px; cursor: pointer; text-align: center; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn-primary { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-primary:hover { background: #1d4ed8; }
.btn-compose { display: block; width: 100%; background: #2563eb; color: #fff; border: none; border-radius: 4px; padding: 10px; text-align: center; font-weight: 600; }
.btn-compose:hover { background: #1d4ed8; text-decoration: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { color: #dc2626; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-full { width: 100%; }
.btn-logout { color: #94a3b8; font-size: 13px; }
.btn-logout:hover { color: #fff; }

/* Login page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #1e293b; }
.login-container { background: #fff; padding: 40px; border-radius: 8px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,0.2); }
.login-container h1 { text-align: center; margin-bottom: 24px; color: #1e293b; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; color: #374151; font-size: 13px; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }
.form-group textarea { resize: vertical; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fca5a5; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #86efac; }

/* Message list */
.message-list-header { padding: 16px 20px; border-bottom: 1px solid #e5e7eb; }
.message-list-header h3 { font-size: 16px; color: #374151; }
.message-table { width: 100%; border-collapse: collapse; }
.message-table thead { background: #f9fafb; }
.message-table th { text-align: left; padding: 8px 12px; font-size: 12px; color: #6b7280; font-weight: 500; text-transform: uppercase; border-bottom: 1px solid #e5e7eb; }
.message-table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.message-table tr { cursor: pointer; transition: background 0.1s; }
.message-table tbody tr:hover { background: #f0f7ff; }
.message-table tr.unread td { font-weight: 600; }
.col-from { width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-date { width: 130px; white-space: nowrap; color: #6b7280; }
.col-subject .preview { color: #9ca3af; font-weight: 400; margin-left: 8px; }
.att-icon { margin-right: 4px; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid #e5e7eb; }
.page-info { font-size: 13px; color: #6b7280; }

/* Empty state */
.empty-state { padding: 60px 20px; text-align: center; color: #9ca3af; }

/* Message view */
.message-view { max-width: 900px; margin: 0 auto; padding: 20px; }
.message-toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #e5e7eb; }
.message-header { margin-bottom: 16px; }
.message-header h2 { font-size: 20px; margin-bottom: 8px; }
.message-meta { font-size: 13px; color: #6b7280; line-height: 1.6; }
.attachments { padding: 10px 0; margin-bottom: 12px; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
.attachment-link { display: inline-block; margin: 4px 8px 4px 0; padding: 4px 10px; background: #f3f4f6; border-radius: 4px; color: #2563eb; }
.attachment-link:hover { background: #e5e7eb; text-decoration: none; }
.message-body { line-height: 1.6; overflow-wrap: break-word; word-break: break-word; }
.message-body img { max-width: 100%; height: auto; }

/* Compose */
.compose-view { max-width: 700px; margin: 0 auto; padding: 20px; }
.compose-view h2 { margin-bottom: 16px; }

/* Move form */
.move-form select { padding: 3px 6px; font-size: 12px; border: 1px solid #d1d5db; border-radius: 4px; }

/* Calendar view */
.calendar-view { max-width: 900px; margin: 0 auto; padding: 20px; }
.calendar-nav { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.calendar-nav h2 { flex: 1; text-align: center; font-size: 18px; margin: 0; }

/* Calendar grid */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e5e7eb; border: 1px solid #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 24px; }
.calendar-dow { background: #f9fafb; padding: 8px 4px; text-align: center; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; }
.calendar-day { background: #fff; min-height: 80px; padding: 4px 6px; position: relative; }
.calendar-day.empty { background: #fafafa; }
.calendar-day.today { background: #eff6ff; }
.calendar-day.today .day-number { background: #2563eb; color: #fff; border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; }
.calendar-day.selected { outline: 2px solid #2563eb; outline-offset: -2px; }
.calendar-day.has-events .day-number { font-weight: 600; }
.day-number { display: inline-block; font-size: 13px; color: #374151; padding: 2px; }
.day-number:hover { text-decoration: none; color: #2563eb; }
.event-dots { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; }
.event-dot { width: 6px; height: 6px; border-radius: 50%; background: #2563eb; }
.event-dot-more { font-size: 10px; color: #6b7280; }

/* Agenda */
.agenda-section { border-top: 1px solid #e5e7eb; padding-top: 16px; }
.agenda-section h3 { font-size: 16px; color: #374151; margin-bottom: 12px; }
.agenda-list { list-style: none; }
.agenda-item { display: flex; gap: 16px; padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.agenda-time { min-width: 140px; font-size: 13px; color: #6b7280; white-space: nowrap; }
.agenda-details { flex: 1; }
.agenda-subject { font-size: 14px; font-weight: 500; color: #1a1a1a; }
.agenda-subject:hover { color: #2563eb; }
.agenda-location { display: block; font-size: 12px; color: #6b7280; margin-top: 2px; }
.empty-state-sm { padding: 20px; text-align: center; color: #9ca3af; font-size: 13px; }

/* Event detail view */
.event-view { max-width: 900px; margin: 0 auto; padding: 20px; }
.attendees-section { margin-bottom: 16px; padding: 12px 0; border-bottom: 1px solid #e5e7eb; font-size: 13px; }
.attendees-list { list-style: none; margin-top: 6px; padding-left: 0; }
.attendees-list li { padding: 3px 0; }
.attendee-status { font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 6px; }
.attendee-accepted { background: #dcfce7; color: #16a34a; }
.attendee-declined { background: #fef2f2; color: #dc2626; }
.attendee-tentativelyAccepted { background: #fef9c3; color: #a16207; }

/* Responsive */
@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; max-height: 50vh; }
    .col-from { width: 120px; }
    .col-date { display: none; }
    .calendar-day { min-height: 50px; }
    .agenda-time { min-width: 100px; }
}
