/* Smail Encrypted Email Service — Professional Theme v2 */
/* Material Design-inspired color scheme: navy sidebar, white content */

/* ─── CSS Variables & Reset ─────────────────────────────────────────────── */
/* ─── CSS Variables: Dark Theme (Proton Dark Aesthetic) ────────────── */
:root[data-theme="dark"],
:root {
  --primary: #00b894;
  --primary-dark: #00a381;
  --primary-light: rgba(0,184,148,0.12);
  --primary-container: rgba(0,184,148,0.15);
  --on-primary: #ffffff;
  --on-primary-container: #e4faf3;
  --sidebar-bg: #1e2128;
  --sidebar-hover: #2a2e38;
  --sidebar-active: #313643;
  --sidebar-text: #9ca3af;
  --sidebar-text-active: #e4e6eb;
  --sidebar-text-dimmed: #6b7d99;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --surface: #252830;
  --surface-variant: #2d3139;
  --surface-container: #2a2e38;
  --surface-container-high: #313643;
  --surface-alt: #2d3139;
  --background: #1a1d23;
  --on-surface: #e4e6eb;
  --on-surface-variant: #9ca3af;
  --outline: #333842;
  --outline-variant: #3a3f4a;
  --error: #ef4444;
  --error-container: rgba(239,68,68,0.12);
  --on-error: #ffffff;
  --error-dark: #dc2626;
  --error-light: #fca5a5;
  --success: #22c55e;
  --success-container: rgba(34,197,94,0.12);
  --success-dark: #16a34a;
  --warning: #f59e0b;
  --warning-container: rgba(245,158,11,0.12);
  --warning-text: #f59e0b;
  --warning-border: #f59e0b;
  --accent-blue: #3b82f6;
  --accent-blue-transparent: rgba(59,130,246,0.08);
  --star-color: #f59e0b;
  --danger-hover-bg: rgba(239,68,68,0.08);
  --danger-hover-color: #ef4444;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-full: 50px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --transition: 200ms ease;
  --primary-shadow: rgba(0,184,148,0.3);
  --primary-shadow-hover: rgba(0,184,148,0.4);
  --primary-shadow-focus: rgba(0,184,148,0.12);
  --hover-bg: rgba(255,255,255,0.05);
  --active-bg: rgba(59,130,246,0.15);
  --auth-bg: linear-gradient(135deg, #1a1d23 0%, #252830 100%);
  --primary-hover: #00a381;
  --overlay-bg: rgba(0,0,0,0.5);
  --compose-header-hover: rgba(255,255,255,0.2);
  --white-transparent: rgba(255,255,255,0.05);
}

/* ─── CSS Variables: Light Theme (Navy/White) ──────────────────────── */
:root[data-theme="light"] {
  --primary: #003d9b;
  --primary-dark: #002d75;
  --primary-light: #e8edff;
  --primary-container: #dae2ff;
  --on-primary: #ffffff;
  --on-primary-container: #001848;
  --sidebar-bg: #001a3e;
  --sidebar-hover: #002d6e;
  --sidebar-active: #003d9b;
  --sidebar-text: #a4b6d0;
  --sidebar-text-active: #ffffff;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --surface: #ffffff;
  --surface-variant: #f4f6fc;
  --surface-container: #eef1f9;
  --surface-container-high: #e4e8f2;
  --background: #f0f2f7;
  --on-surface: #1a1f36;
  --on-surface-variant: #525770;
  --outline: #d0d5e0;
  --outline-variant: #e0e4ed;
  --error: #dc3545;
  --error-container: #fce4e6;
  --on-error: #ffffff;
  --success: #28a745;
  --success-container: #e6f7eb;
  --warning: #ffc107;
  --warning-container: #fff8e1;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --border-radius-full: 50px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  --transition: 200ms ease;
  --accent-blue: #3b82f6;
  --accent-blue-transparent: rgba(59,130,246,0.08);
  --active-bg: rgba(0,61,155,0.10);
  --auth-bg: linear-gradient(135deg, #f0f2f7 0%, #e4e8f2 100%);
  --compose-header-hover: rgba(0,0,0,0.05);
  --danger-hover-bg: rgba(220,53,69,0.08);
  --danger-hover-color: #dc3545;
  --error-dark: #b91c1c;
  --error-light: #fca5a5;
  --hover-bg: rgba(0,0,0,0.04);
  --overlay-bg: rgba(0,0,0,0.3);
  --primary-hover: #002d75;
  --primary-shadow: rgba(0,61,155,0.3);
  --primary-shadow-focus: rgba(0,61,155,0.12);
  --primary-shadow-hover: rgba(0,61,155,0.4);
  --sidebar-text-dimmed: #7a8ba8;
  --star-color: #f59e0b;
  --success-dark: #1e7e34;
  --surface-alt: #eef1f9;
  --warning-border: #ffc107;
  --warning-text: #856404;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--background);
  overflow: hidden;
  height: 100vh;
}

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

/* ─── Layout ────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar Navigation ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 8px;
  border-bottom: 1px solid var(--outline-variant);
  margin-bottom: 16px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 700;
}

.sidebar-brand-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--sidebar-text-active);
  letter-spacing: -0.3px;
}

.sidebar-brand-text p {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--sidebar-text);
  opacity: 0.6;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 0 12px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--sidebar-text);
  border-radius: var(--border-radius);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.sidebar-nav a .nav-icon {
  width: 22px;
  text-align: center;
  font-size: 18px;
  display: inline-block;
}

.sidebar-nav a .badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--border-radius-full);
  font-weight: 600;
}

.compose-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 24px);
  margin: 0 12px 16px;
  padding: 14px 20px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--border-radius-full);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px var(--primary-shadow);
}
.compose-btn:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px var(--primary-shadow-hover);
  transform: translateY(-1px);
}
.compose-btn:active {
  transform: translateY(0);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--outline-variant);
  margin-top: auto;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--border-radius);
  transition: background var(--transition);
}
.sidebar-user:hover {
  background: var(--sidebar-hover);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.user-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-link {
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 600;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--transition);
}
.logout-link:hover {
  color: var(--error-light);
  background: var(--hover-bg);
  text-decoration: none;
}

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Top Bar ────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  flex-shrink: 0;
}

.topbar-title {
.topbar-user {  margin-left: auto;  display: flex;  align-items: center;  gap: 12px;  font-size: 14px;}.topbar-user-email {  color: var(--on-surface-variant);}.topbar-logout {  color: var(--primary);  text-decoration: none;  font-size: 13px;}.topbar-logout:hover {  text-decoration: underline;}
  font-size: 20px;
  font-weight: 600;
  color: var(--on-surface);
}

/* ─── Content Scrollable Area ─────────────────────────────────────────────── */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.content-card {
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--outline);
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table-container {
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--outline);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--surface-variant);
  padding: 12px 16px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--on-surface-variant);
  border-bottom: 2px solid var(--outline);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--outline-variant);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--surface-container);
}

tbody tr:last-child td {
  border-bottom: none;
}

tr.unread {
  font-weight: 700;
  background: var(--primary-container);
  border-left: 5px solid var(--accent-blue);
}

tr.unread td:first-child {
  padding-left: 10px;
}

tr.unread:hover {
  background: var(--primary-light);
}

/* ─── Message Sender Column ──────────────────────────────────────────────── */
.sender-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sender-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  font-weight: 700;
  color: var(--on-primary-container);
  flex-shrink: 0;
}

.sender-name {
  font-weight: 500;
}

/* ─── Attachment Indicator ──────────────────────────────────────────────── */
.att-indicator {
  color: var(--on-surface-variant);
  font-size: 16px;
}

/* ─── Subject Column ──────────────────────────────────────────────────────── */
.subject-cell {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.encrypted-label {
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  font-weight: 500;
}

/* ─── Date Column ──────────────────────────────────────────────────────────── */
.date-cell {
  color: var(--on-surface-variant);
  font-size: 13px;
  white-space: nowrap;
}

/* ─── Action Buttons ──────────────────────────────────────────────────────── */
.action-group {
  display: flex;
  gap: 6px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  background: var(--surface);
  color: var(--on-surface-variant);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--surface-variant);
  color: var(--on-surface);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
}

.btn-primary:hover {
  background: var(--primary-dark);
  color: var(--on-primary);
}

.btn-danger {
  background: var(--error);
  color: var(--on-error);
  border: none;
}

.btn-danger:hover {
  background: var(--error-dark);
  color: var(--on-error);
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.form-card {
  max-width: 520px;
  margin: 40px auto;
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--outline);
  padding: 40px;
}

.form-card-wide {
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--outline);
  padding: 32px;
}

.form-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--on-surface);
  margin-bottom: 8px;
}

.form-subtitle {
  font-size: 14px;
  color: var(--on-surface-variant);
  margin-bottom: 28px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-sans);
  border: 1.5px solid var(--outline);
  border-radius: var(--border-radius);
  background: var(--surface);
  color: var(--on-surface);
  transition: all var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow-focus);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.form-group input[type="file"] {
  padding: 8px;
  border-style: dashed;
  background: var(--surface-variant);
}

.form-group input[type="file"]:hover {
  background: var(--surface-container);
}

.help-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  margin-top: 4px;
}

.form-row {
  display: flex;
  gap: 16px;
}

.form-row .form-group {
  flex: 1;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--outline-variant);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--border-radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  font-family: var(--font-sans);
}

.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--surface);
  color: var(--on-surface);
  border: 1.5px solid var(--outline);
}
.btn-secondary:hover {
  background: var(--surface-variant);
  border-color: var(--on-surface-variant);
}

.btn-success {
  background: var(--success);
  color: var(--on-primary);
}
.btn-success:hover {
  background: var(--success-dark);
}

.btn-danger {
  background: var(--error);
  color: var(--on-error);
}
.btn-danger:hover {
  background: var(--error-dark);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover {
  background: var(--primary-light);
}

/* ─── Messages (Error/Success) ──────────────────────────────────────────── */
.message-box {
  padding: 14px 18px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.message-box .msg-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.message-box.error {
  background: var(--error-container);
  color: var(--error);
  border-left: 4px solid var(--error);
}

.message-box.success {
  background: var(--success-container);
  color: var(--success);
  border-left: 4px solid var(--success);
}

.message-box.warning {
  background: var(--warning-container);
  color: var(--warning-text);
  border-left: 4px solid var(--warning);
}

/* ─── Message Read View ──────────────────────────────────────────────────── */
.message-read {
  max-width: 760px;
  margin: 0 auto;
}

.message-header-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--border-radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.message-sender-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--outline-variant);
}

.sender-avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.sender-details {
  flex: 1;
}
.sender-details .sender-full-name {
  font-size: 16px;
  font-weight: 600;
}
.sender-details .sender-email-addr {
  font-size: 13px;
  color: var(--on-surface-variant);
}

.message-meta {
  font-size: 13px;
  color: var(--on-surface-variant);
  margin-bottom: 4px;
}
.message-meta strong {
  color: var(--on-surface);
}

.message-subject-heading {
  font-size: 22px;
  font-weight: 700;
  margin: 16px 0 8px;
  color: var(--on-surface);
}

.message-body-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--border-radius-lg);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  min-height: 120px;
}

.message-body-card pre {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.7;
  color: var(--on-surface);
  margin: 0;
}

/* Decrypt Section */
.decrypt-section {
  background: var(--warning-container);
  border: 1px solid var(--warning-border);
  border-radius: var(--border-radius);
  padding: 20px;
  margin-bottom: 20px;
}

.decrypt-section p {
  margin-bottom: 12px;
  font-size: 14px;
}

.decrypt-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.decrypt-form label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  display: block;
}

.decrypt-form input[type="password"] {
  padding: 10px 14px;
  font-size: 14px;
  border: 1.5px solid var(--outline);
  border-radius: var(--border-radius);
  outline: none;
  transition: all var(--transition);
  min-width: 220px;
}

.decrypt-form input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow-focus);
}

/* Attachments */
.attachment-section {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--border-radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.attachment-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface-variant);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--outline-variant);
}

.attachment-item:last-child {
  border-bottom: none;
}

.att-icon {
  font-size: 20px;
}

.att-name {
  flex: 1;
  font-weight: 500;
  font-size: 14px;
}

.att-size {
  color: var(--on-surface-variant);
  font-size: 13px;
  white-space: nowrap;
}

.att-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.att-password-input {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  outline: none;
  width: 150px;
}

/* ─── Action Bar ──────────────────────────────────────────────────────────── */
.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--outline-variant);
}

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--on-surface-variant);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ─── Error Page ──────────────────────────────────────────────────────────── */
.error-page {
  text-align: center;
  padding: 80px 20px;
}

.error-page .error-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.error-page h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--on-surface);
}

.error-page .error-message {
  font-size: 16px;
  color: var(--on-surface-variant);
  background: var(--error-container);
  border: 1px solid var(--error);
  border-radius: var(--border-radius);
  padding: 16px 24px;
  display: inline-block;
  margin-bottom: 24px;
}

/* ─── Login/Register Page Specific ────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--auth-bg);
}

.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.auth-logo h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--on-surface);
}

.auth-logo p {
  font-size: 14px;
  color: var(--on-surface-variant);
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--on-surface-variant);
}

.auth-footer a {
  font-weight: 600;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 0;
    min-width: 0;
    overflow: hidden;
    transition: width 0.3s ease;
  }
  .sidebar.open {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
  }
  .main-content {
    margin-left: 0;
  }
  .content-area {
    padding: 16px;
  }
  .topbar {
    padding: 0 16px;
  }
  .form-card,
  .form-card-wide {
    padding: 24px;
    margin: 20px auto;
  }
  .auth-container {
    padding: 12px;
  }
  .auth-card {
    padding: 28px 24px;
  }
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  .action-group {
    flex-direction: column;
    gap: 4px;
  }
  .action-bar {
    flex-wrap: wrap;
  }
}

/* ─── Utility ──────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--on-surface-variant); }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.inline { display: inline; }
.inline-block { display: inline-block; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* For forms in tables (delete/read inline) */
.inline-form {
  display: inline;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
}

/* Attachment chips - compact style above message body */
.attachments-bar {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--border-radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface-variant);
  border: 1px solid var(--outline);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
}
.attachment-chip .att-icon {
  font-size: 14px;
}
.attachment-chip .att-name {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--on-surface);
}
.attachment-chip .att-size {
  color: var(--on-surface-variant);
  font-size: 11px;
  white-space: nowrap;
}
.attachment-chip .att-actions form,
.attachment-chip .att-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.att-password-input-sm {
  width: 90px;
  padding: 2px 6px;
  font-size: 11px;
  border: 1px solid var(--outline);
  border-radius: 4px;
  background: var(--surface-variant);
  color: var(--on-surface);
}
.btn-sm {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.btn-sm:hover {
  background: var(--primary-hover);
  text-decoration: none;
}
/* Also make the email address slightly smaller */
.sender-email-addr {
  font-size: 12px;
  color: var(--on-surface-variant);
}

/* Compose top bar with back button */
.compose-top-bar {
  margin-bottom: 16px;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background var(--transition);
}
.btn-back:hover {
  background: var(--accent-blue-transparent);
  text-decoration: none;
}

/* ─── Feature A: Labels ───────────────────────────────────────────── */

.label-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--on-primary);
    white-space: nowrap;
    margin: 1px 2px;
    line-height: 1.5;
}

.label-badge-empty {
    background: var(--surface-container-high);
    color: var(--on-surface-variant);
    font-style: italic;
}

.label-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.label-dot-sm {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 4px;
    vertical-align: middle;
}

.msg-label-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 2px;
}

/* Sidebar labels section */
.sidebar-section-title {
    padding: 12px 16px 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-text-dimmed);
    font-weight: 600;
}

.sidebar-labels {
    margin-bottom: 4px;
}

.sidebar-label-link {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 6px 16px !important;
    font-size: 13px !important;
    color: var(--sidebar-text) !important;
    text-decoration: none;
    transition: background var(--transition);
}

.sidebar-label-link:hover {
    background: var(--sidebar-hover) !important;
}

.sidebar-label-manage-link {
    font-size: 12px !important;
    opacity: 0.7;
}

/* Label manager modal */
.label-manager-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay-bg);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.label-manager-modal {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    width: 450px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.label-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--outline-variant);
}

.label-manager-header h2 {
    font-size: 18px;
    margin: 0;
}

.label-manager-body {
    padding: 20px;
}

.label-manager-list {
    margin-bottom: 20px;
}

.label-manager-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--outline-variant);
}

.label-manager-item-name {
    flex: 1;
    font-size: 14px;
}

.label-manager-item-actions {
    display: flex;
    gap: 4px;
}

.label-manager-create {
    padding-top: 16px;
    border-top: 1px solid var(--outline-variant);
}

.label-manager-create h3 {
    font-size: 14px;
    margin-bottom: 8px;
}

.label-create-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.form-color {
    width: 40px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--outline);
    border-radius: var(--border-radius);
    cursor: pointer;
    background: none;
}

/* Label dropdown on message rows */
.label-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.label-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 500;
    min-width: 180px;
    max-height: 200px;
    overflow-y: auto;
}

.label-dropdown-item {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    gap: 6px;
    transition: background var(--transition);
}

.label-dropdown-item:hover {
    background: var(--surface-container);
}

.label-dropdown-item .label-check {
    margin-left: auto;
    color: var(--primary);
    font-weight: bold;
}

.label-dropdown-item.disabled {
    color: var(--on-surface-variant);
    font-style: italic;
    cursor: default;
}

/* Labels in read page */
.message-labels-section {
    margin-top: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--outline-variant);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.msg-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.label-remove-btn {
    cursor: pointer;
    margin-left: 4px;
    font-weight: bold;
    opacity: 0.7;
}

.label-remove-btn:hover {
    opacity: 1;
}

.add-label-wrapper {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* ─── Feature B: Popup Compose ─────────────────────────────────────── */

.compose-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 600px;
    max-height: 600px;
    background: var(--surface);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 200ms ease, box-shadow 200ms ease;
}

.compose-popup-minimized {
    max-height: 40px;
    overflow: hidden;
}

.compose-popup-minimized .compose-popup-body {
    display: none;
}

.compose-popup-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    bottom: auto;
    right: auto;
    z-index: 2000;
}

.compose-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--primary);
    color: var(--on-primary);
    cursor: default;
    user-select: none;
}

.compose-popup-title {
    font-size: 14px;
    font-weight: 600;
}

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

.compose-popup-minimize,
.compose-popup-close {
    background: none;
    border: none;
    color: var(--on-primary);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 14px;
    border-radius: 4px;
}

.compose-popup-minimize:hover,
.compose-popup-close:hover {
    background: var(--compose-header-hover);
}

.compose-popup-body {
    padding: 12px;
    overflow-y: auto;
    flex: 1;
}

.compose-field {
    margin-bottom: 8px;
}

.compose-input,
.compose-textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--outline);
    border-radius: var(--border-radius);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color var(--transition);
    box-sizing: border-box;
}

.compose-input:focus,
.compose-textarea:focus {
    border-color: var(--primary);
}

.compose-textarea {
    height: 150px;
    resize: vertical;
}

.compose-file-input {
    font-size: 12px;
}

.compose-collapsible {
    display: flex;
    align-items: center;
    gap: 6px;
}

.compose-toggle {
    cursor: pointer;
    font-size: 12px;
    color: var(--primary);
    user-select: none;
    min-width: 32px;
}

.compose-hidden-input {
    flex: 1;
}

.compose-popup-footer {
    display: flex;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--outline-variant);
}

.compose-status {
    padding: 6px 10px;
    border-radius: var(--border-radius);
    font-size: 12px;
    margin-top: 8px;
}

.compose-status-info {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.compose-status-success {
    background: var(--success-container);
    color: var(--success);
}

.compose-status-error {
    background: var(--error-container);
    color: var(--error);
}

/* ─── Feature C: Filters ───────────────────────────────────────────── */

.filters-page {
    max-width: 800px;
}

.filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filters-header h2 {
    font-size: 20px;
    margin: 0;
}

.filter-row {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    margin-bottom: 8px;
    transition: box-shadow var(--transition);
}

.filter-row:hover {
    box-shadow: var(--shadow-sm);
}

.filter-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.filter-drag-handle {
    cursor: grab;
    color: var(--on-surface-variant);
    font-size: 16px;
    user-select: none;
}

.filter-name {
    font-weight: 600;
    font-size: 14px;
    flex: 1;
}

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

.filter-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    margin-right: 8px;
}

.filter-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--surface-container-high);
    border-radius: 20px;
    transition: background var(--transition);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: transform var(--transition);
}

.filter-toggle input:checked + .toggle-slider {
    background-color: var(--primary);
}

.filter-toggle input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

.filter-preview {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: var(--on-surface-variant);
}

.filter-conditions,
.filter-actions-preview {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.condition-row,
.action-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

/* Empty state variant */
.empty-state-sm {
    padding: 16px;
    text-align: center;
    color: var(--on-surface-variant);
    font-size: 13px;
}

/* ─── Mobile Responsive ────────────────────────────────────────────── */

@media (max-width: 767px) {
    .compose-popup {
        border-radius: 0;
        width: 100% !important;
        max-height: 100% !important;
    }

    .compose-popup:not(.compose-popup-fullscreen) {
        display: none;
    }

    .label-manager-modal {
        width: 95vw;
    }

    .filter-header {
        flex-wrap: wrap;
    }

    .filter-preview {
        flex-direction: column;
        gap: 4px;
    }

    .condition-row,
    .action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .condition-row select,
    .action-row select,
    .condition-row input,
    .action-row input {
        width: 100% !important;
    }

    .filters-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ─── Inbox label badge in sender cell ─────────────────────────────── */

.sender-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sender-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Star and delete action buttons */
.btn-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 14px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  background: transparent;
  color: var(--star-color);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-star:hover {
  background: var(--warning-container);
  border-color: var(--star-color);
}
.btn-danger-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  background: transparent;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-danger-del:hover {
  color: var(--danger-hover-color);
  background: var(--danger-hover-bg);
  border-color: var(--danger-hover-color);
}

/* ===== Sidebar Restructuring (Subproject 1144) ===== */
.sidebar-nav-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    color: var(--on-surface);
    text-decoration: none;
    border-radius: 6px;
    margin: 2px 0;
    transition: background 0.15s;
}
.sidebar-nav-item:hover {
    background: var(--hover-bg);
}
.sidebar-nav-item.active {
    background: var(--active-bg, var(--primary-light));
    color: var(--primary, var(--primary));
    font-weight: 600;
}
.nav-icon {
    width: 24px;
    text-align: center;
    margin-right: 8px;
    font-size: 16px;
}
.nav-label {
    flex: 1;
}
.nav-badge {
    background: var(--primary, var(--primary));
    color: var(--on-primary);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.5;
}
.sidebar-section {
    margin-top: 16px;
    padding: 0 12px;
}
.sidebar-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--on-surface-variant);
    letter-spacing: 0.5px;
    padding: 8px 0;
}
.sidebar-section-actions {
    display: flex;
    gap: 4px;
}
.sidebar-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    color: var(--on-surface-variant);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.sidebar-action-icon:hover {
    background: var(--hover-bg);
    color: var(--on-surface);
}
.sidebar-nav-toggle {
    margin: 4px 0;
}
.sidebar-toggle-link {
    font-size: 12px;
    color: var(--on-surface-variant) !important;
}
.sidebar-section:empty {
    display: none;
}
/* Override existing sidebar link styles to work with new structure */
.sidebar-labels .sidebar-label-link {
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--on-surface);
    text-decoration: none;
    border-radius: 4px;
}
.sidebar-labels .sidebar-label-link:hover {
    background: var(--hover-bg);
}
.label-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ─── Admin Panel Styles ─────────────────────────────────────────── */

.admin-dashboard {
    padding: 24px;
    max-width: 1200px;
}

.admin-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.admin-card {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.admin-card h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--on-surface);
    font-size: 18px;
    font-weight: 600;
}

.admin-dashboard-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.admin-dashboard-actions .btn {
    padding: 10px 20px;
    font-size: 14px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    background: var(--surface-variant);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--on-surface-variant);
    border-bottom: 2px solid var(--outline);
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--outline-variant);
    color: var(--on-surface);
}

.admin-table tr:hover td {
    background: var(--surface-variant);
}

.admin-section-title {
    color: var(--on-surface);
    font-size: 20px;
    font-weight: 600;
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

.admin-form {
    max-width: 500px;
}

.admin-form .form-group {
    margin-bottom: 16px;
}

.admin-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--on-surface);
    font-size: 14px;
}

.admin-form .form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--outline);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.admin-form .form-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-light);
}

.admin-form .form-help {
    display: block;
    color: var(--on-surface-variant);
    font-size: 12px;
    margin-top: 4px;
}

.admin-form .btn {
    margin-top: 8px;
}

.sidebar-admin-link {
    border-top: 1px solid var(--outline-variant);
    margin-top: 4px;
    padding-top: 8px;
}

.sidebar-admin-link.active {
    background: var(--active-bg);
}

.alert-error {
    background: var(--error-container);
    border: 1px solid var(--outline);
    color: var(--error);
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}

.text-muted {
    color: var(--on-surface-variant);
    font-size: 14px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ─── Responsive List Views & Mobile Hamburger Menu (Subproject 1187) ─────
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Hamburger Menu Button ─────────────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--on-surface);
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
  line-height: 1;
}
.hamburger-btn:hover {
  background: var(--surface-container);
}

/* ─── Sidebar Overlay (mobile) ──────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-bg);
  z-index: 99;
}

/* ─── Mobile Three-Dot Menu ─────────────────────────────────────────────── */
.mobile-action-trigger {
  display: none;
  position: relative;
}
.mobile-action-dots {
  background: none;
  border: 1px solid var(--outline);
  border-radius: 6px;
  cursor: pointer;
  padding: 4px 10px;
  font-size: 18px;
  line-height: 1;
  color: var(--on-surface-variant);
  transition: background var(--transition);
}
.mobile-action-dots:hover {
  background: var(--surface-container);
}
.mobile-action-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
  z-index: 600;
  min-width: 160px;
  padding: 4px 0;
}
.mobile-action-dropdown.show {
  display: block;
}
.mobile-action-dropdown form {
  display: block;
  margin: 0;
}
.mobile-action-dropdown .dropdown-action-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  color: var(--on-surface);
  transition: background var(--transition);
  font-family: var(--font-sans);
}
.mobile-action-dropdown .dropdown-action-btn:hover {
  background: var(--surface-container);
}
.mobile-action-dropdown .dropdown-label-wrapper {
  padding: 0;
}
.mobile-action-dropdown .dropdown-label-btn {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  color: var(--on-surface);
  font-family: var(--font-sans);
  transition: background var(--transition);
}
.mobile-action-dropdown .dropdown-label-btn:hover {
  background: var(--surface-container);
}
.mobile-action-dropdown .label-dropdown {
  position: static;
  box-shadow: none;
  border: none;
  border-radius: 0;
  max-height: 150px;
}

/* ─── Card Layout (mobile) ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .table-container thead,
  .message-table thead {
    display: none;
  }

  .table-container tbody tr,
  .message-table tbody tr {
    display: block;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    position: relative;
  }

  .table-container tbody tr:hover,
  .message-table tbody tr:hover {
    background: var(--surface);
  }

  .table-container tbody tr.unread,
  .message-table tbody tr.unread {
    background: var(--primary-container);
    border-left: 4px solid var(--accent-blue);
  }

  .table-container tbody td,
  .message-table tbody td {
    display: block;
    padding: 4px 0;
    border: none;
    text-align: left;
  }

  .table-container tbody td.text-center,
  .message-table tbody td.text-center {
    display: none;
  }

  .table-container tbody td:first-child {
    padding-bottom: 6px;
    font-weight: 600;
  }

  .table-container tbody tr .att-indicator,
  .message-table tbody tr .att-indicator {
    display: inline;
    margin-left: 6px;
    font-size: 14px;
  }

  .table-container tbody td:nth-child(3),
  .message-table tbody td:nth-child(3) {
    font-size: 15px;
    font-weight: 500;
    color: var(--on-surface);
    padding: 2px 0 4px;
  }

  .subject-cell {
    max-width: none;
    white-space: normal;
  }

  .date-cell {
    font-size: 12px;
    color: var(--on-surface-variant);
  }

  .table-container .action-group,
  .message-table .action-group {
    flex-direction: row !important;
    gap: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--outline-variant);
    margin-top: 6px;
    flex-wrap: wrap;
  }

  .table-container .action-group .btn-icon,
  .message-table .action-group .btn-icon {
    display: none;
  }

  .table-container .action-group .mobile-action-trigger,
  .message-table .action-group .mobile-action-trigger {
    display: block;
  }

  .table-container .action-group .label-dropdown-wrapper,
  .message-table .action-group .label-dropdown-wrapper {
    display: none;
  }

  .table-container tbody td:last-child,
  .message-table tbody td:last-child {
    padding: 0;
    margin-top: 6px;
  }

  .table-container tbody td[colspan] {
    padding: 14px 16px;
  }

  .content-area {
    padding: 12px !important;
  }

  .message-table-wrapper {
    border-radius: 0;
    border: none;
    background: transparent;
  }

  .message-table-wrapper table.message-table tbody tr {
    background: var(--surface);
    border: 1px solid var(--outline);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 10px;
  }
}

/* ─── Tablet Layout (641px - 900px) ──────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 900px) {
  .action-group .btn-icon {
    padding: 6px 8px;
    font-size: 14px;
    min-width: 32px;
  }

  .action-group .btn-primary:not(.btn-star):not(.btn-danger):not(.btn-danger-del) {
    font-size: 0;
    padding: 6px 10px;
  }
  .action-group .btn-primary:not(.btn-star):not(.btn-danger):not(.btn-danger-del)::before {
    content: "👁️";
    font-size: 14px;
  }

  .msg-label-badges .label-badge {
    max-width: 24px;
    overflow: hidden;
    white-space: nowrap;
    text-indent: 20px;
    padding: 2px 6px;
    position: relative;
  }
  .msg-label-badges .label-badge::after {
    content: "🏷️";
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    text-indent: 0;
  }

  thead th[style*="width"] {
    width: auto !important;
  }
}

/* ─── Hamburger Menu visible below 768px ─────────────────────────────────── */
@media (max-width: 768px) {
  .hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

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

  .sidebar.open {
    z-index: 101;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .sidebar.open + .sidebar-overlay,
  .sidebar.open ~ .sidebar-overlay {
    display: block;
  }

  .sidebar.open {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    box-shadow: var(--shadow-lg);
  }
}

/* ─── Sent-specific: View button on tablet shows icon only ──────────────── */
@media (min-width: 641px) and (max-width: 900px) {
  .action-group a.btn-icon.btn-primary {
    font-size: 0;
    padding: 6px 10px;
  }
  .action-group a.btn-icon.btn-primary::before {
    content: "👁️";
    font-size: 14px;
  }
}

/* ─── Empty state adjustments on mobile ──────────────────────────────────── */
@media (max-width: 640px) {
  .empty-state {
    padding: 32px 16px;
  }
  .empty-state .empty-icon {
    font-size: 36px;
  }
  .empty-state h3 {
    font-size: 16px;
  }
}

/* ─── Fix for action-group column flex override on mobile ───────────────── */

/* ─── Clickable Row Links ──────────────────────────────────────────────────── */
.sender-name-link,
.subject-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.sender-name-link:hover,
.subject-link:hover {
  text-decoration: underline;
}
/* ─── External Sender Badge ────────────────────────────────────────────── */
.external-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary, #1a73e8);
  background: transparent;
  border: 1px solid var(--primary, #1a73e8);
  border-radius: 10px;
  padding: 0 6px;
  line-height: 18px;
  vertical-align: middle;
  white-space: nowrap;
  margin-left: 4px;
  cursor: default;
  user-select: none;
}

/* Global attachment password field */
.global-att-password {
  margin: 12px 0;
  padding: 12px;
  background: var(--surface-alt, var(--surface-alt));
  border-radius: 8px;
  border: 1px solid var(--outline);
}
.att-pw-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--on-surface);
}
.att-global-pw-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  font-size: 16px;
  border: 1px solid var(--outline);
  border-radius: 6px;
  outline: none;
  background: var(--surface);
  color: var(--on-surface);
  box-sizing: border-box;
}
.att-global-pw-input:focus {
  border-color: var(--primary, var(--accent-blue));
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* ===== Unread / Read Visual Distinction ===== */



/* ===== Unread Badge ===== */
.unread-badge {
  display: inline-block;
  background: var(--accent-blue);
  color: var(--on-primary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 6px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.4;
}



/* --- Theme Toggle Button --- */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--border-radius);
  background: transparent;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  background: var(--hover-bg);
  color: var(--sidebar-text-active);
}
.theme-toggle-btn .sun-icon,
.theme-toggle-btn .moon-icon {
  display: none;
}
:root[data-theme="dark"] .theme-toggle-btn .sun-icon {
  display: block;
}
:root[data-theme="dark"] .theme-toggle-btn .moon-icon {
  display: none;
}
:root[data-theme="light"] .theme-toggle-btn .moon-icon {
  display: block;
}
:root[data-theme="light"] .theme-toggle-btn .sun-icon {
  display: none;
}

/* Inline label editor */
.label-inline-edit {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 8px 0;
    width: 100%;
}

.label-inline-edit-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--outline);
    border-radius: var(--border-radius);
    background: var(--surface);
    color: var(--on-surface);
    font-size: 14px;
    box-sizing: border-box;
}

.label-inline-edit-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-container);
}

.label-inline-edit-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.label-inline-edit-color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.label-inline-edit-color:hover {
    transform: scale(1.15);
}

.label-inline-edit-color.selected {
    border-color: var(--on-surface);
    box-shadow: 0 0 0 1px var(--surface);
    transform: scale(1.1);
}

.label-inline-edit-actions {
    display: flex;
    gap: 6px;
    margin-top: 2px;
}

.label-inline-edit-actions .btn-sm {
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    border-radius: var(--border-radius);
    transition: opacity 0.15s;
}

.label-inline-edit-actions .btn-sm:hover {
    opacity: 0.85;
}

.label-inline-edit-actions .btn-primary-sm {
    background: var(--primary);
    color: var(--on-primary);
}

.label-inline-edit-actions .btn-secondary-sm {
    background: var(--surface-container-high);
    color: var(--on-surface);
}


/* Forwarded attachments info on compose form */
.forwarded-attachments-info {
    margin-top: 8px;
    padding: 6px 12px;
    background: #f0f8ff;
    border: 1px solid #b8d4f0;
    border-radius: 4px;
    font-size: 0.85em;
    color: #333;
}


/* Bulk delete styles */
.bulk-col { width: 36px; text-align: center; }
.bulk-col input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
#bulk-action-bar { 
  background: #f0f0f0; padding: 8px 12px; border-radius: 6px;
  display: flex; align-items: center; gap: 12px;
}
#bulk-count { font-weight: bold; color: #555; }


/* ── Quick-create filter popup (quickfilter.js) ── */
.quickfilter-menu {
    position: fixed; z-index: 10000;
    background: var(--surface, #fff);
    border: 1px solid var(--outline, #ddd);
    border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.15);
    padding: 6px; min-width: 220px;
    font-size: 14px;
}
.quickfilter-menu-title {
    padding: 6px 10px; font-weight: 600;
    color: var(--on-surface-variant, #9ca3af);
    font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
.quickfilter-menu-item {
    display: block; width: 100%; text-align: left;
    padding: 8px 10px; border: none; background: none; cursor: pointer;
    border-radius: 6px; font-size: 14px;
    color: var(--on-surface, #e4e6eb);
}
.quickfilter-menu-item:hover { background: var(--hover-bg, rgba(255,255,255,0.05)); }
.quickfilter-modal { max-width: 440px; }
.quickfilter-modal .form-group { margin-bottom: 12px; }
.quickfilter-modal label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.qf-condition-row { display: flex; gap: 8px; align-items: center; }
.qf-field-label { font-weight: 600; white-space: nowrap; }
.qf-operator { width: 130px; }
.qf-value { flex: 1; }
.qf-label-select { margin-top: 6px; }
.quickfilter-error { color: #c0392b; background: #fdecea; border-radius: 6px; padding: 8px 10px; margin-bottom: 12px; font-size: 13px; }
.quickfilter-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.quickfilter-toast {
    position: fixed; bottom: 24px; right: 24px; z-index: 10001;
    background: #1e3a5f; color: #fff; padding: 12px 16px; border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: 14px;
}
.quickfilter-toast a { color: #8ec5ff; font-weight: 600; }
