/* ============================================================
   CYNERGY MAIL — SOLAR PROFESSIONAL DESIGN SYSTEM
   Light mode, warm palette matching cynergy-admin

   Background:  #FAFAF7       Surface: #FFFFFF
   Primary:     #F2BB31       Green:   #3A9255
   Ink:         #1C1C1A       Border:  #E5E3DC
   Shadows:     layered, subtle, warm-tinted
   Radius:      6-12px        Easing:  cubic-bezier(0.16, 1, 0.3, 1)
   ============================================================ */

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

:root {
  /* ── Core palette ── */
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-elevated: #F5F3EE;
  --surface-alt: #F5F0EB;
  --surface-hover: #F0EDE6;

  --ink: #1C1C1A;
  --text-1: #1C1C1A;
  --text-2: #6B6B60;
  --text-3: #9CA3AF;
  --text-4: #BDBDBD;

  /* ── Brand ── */
  --gold: #F2BB31;
  --gold-dark: #D59628;
  --gold-light: #FEF3E3;
  --gold-50: rgba(242, 187, 49, 0.08);
  --gold-100: rgba(242, 187, 49, 0.15);
  --green: #3A9255;
  --green-dark: #286D3F;
  --green-light: #E8F5ED;

  /* ── Semantic ── */
  --danger: #DC3545;
  --danger-light: #FEF2F2;
  --warning: #D97706;
  --warning-light: #FEFCE8;
  --info: #2E86AB;
  --info-light: #EFF6FF;

  /* ── Borders ── */
  --border: #E5E3DC;
  --border-strong: #D1CFC7;
  --border-accent: #F2BB31;

  /* ── Shadows (warm-tinted, layered) ── */
  --shadow-xs: 0 1px 2px rgba(28, 28, 26, 0.04);
  --shadow-sm: 0 1px 3px rgba(28, 28, 26, 0.06), 0 1px 2px rgba(28, 28, 26, 0.03);
  --shadow-md: 0 2px 8px rgba(28, 28, 26, 0.06), 0 1px 3px rgba(28, 28, 26, 0.03);
  --shadow-lg: 0 4px 16px rgba(28, 28, 26, 0.08), 0 2px 4px rgba(28, 28, 26, 0.04);
  --shadow-xl: 0 8px 32px rgba(28, 28, 26, 0.10), 0 4px 8px rgba(28, 28, 26, 0.05);
  --shadow-focus: 0 0 0 3px rgba(242, 187, 49, 0.25);
  --shadow-focus-green: 0 0 0 3px rgba(58, 146, 85, 0.25);

  /* ── Radii ── */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* ── Transitions ── */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 150ms var(--ease);
  --t-base: 200ms var(--ease);
  --t-slow: 300ms var(--ease);

  /* ── Typography ── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* ── Sidebar ── */
  --sidebar-width: 280px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  overflow: hidden;
}

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

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ======================= LOGIN ======================= */
.login-screen {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 60px 40px;
  background: linear-gradient(160deg, #F5F3EE 0%, #FEF3E3 50%, #E8F5ED 100%);
  position: relative;
  overflow: hidden;
}

.login-brand::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 187, 49, 0.12) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.login-brand::after {
  content: '';
  position: absolute;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(58, 146, 85, 0.08) 0%, transparent 70%);
  bottom: -80px;
  left: -60px;
  pointer-events: none;
}

.brand-content { text-align: center; z-index: 1; }

.brand-logo {
  width: 80px; height: 80px; margin: 0 auto 24px;
  background: var(--gold); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px; color: white; box-shadow: var(--shadow-lg);
}

.brand-content h1 {
  font-size: 28px; font-weight: 700; color: var(--ink);
  margin-bottom: 8px; letter-spacing: -0.5px;
}
.brand-content p { font-size: 15px; color: var(--text-2); max-width: 300px; }

.login-form-side {
  flex: 0 0 520px;
  display: flex; align-items: center; justify-content: center;
  padding: 60px; background: var(--surface);
}

.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.3px; }
.login-card .subtitle { font-size: 14px; color: var(--text-2); margin-bottom: 32px; }
.login-card .error-banner {
  background: var(--danger-light); border: 1px solid rgba(220, 53, 69, 0.2);
  color: var(--danger); padding: 10px 14px; border-radius: var(--r-md);
  font-size: 13px; margin-bottom: 20px; display: none;
}
.login-card .error-banner.visible { display: block; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.login-card input[type="email"],
.login-card input[type="password"],
.login-card input[type="text"] {
  width: 100%; padding: 10px 14px; font-size: 14px; font-family: var(--font-sans);
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink); transition: border-color var(--t-fast), box-shadow var(--t-fast); outline: none;
}
.login-card input:focus { border-color: var(--gold); box-shadow: var(--shadow-focus); }
.login-card .field { margin-bottom: 18px; }
.login-card .btn-login { width: 100%; margin-top: 8px; }
.twofa-step { display: none; }
.twofa-step.visible { display: block; }
.twofa-note { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }

/* ======================= BUTTONS ======================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 18px; font-size: 14px; font-weight: 600; font-family: var(--font-sans);
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  transition: all var(--t-fast); white-space: nowrap; line-height: 1.4; outline: none;
}
.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn-primary { background: var(--gold); color: #1C1C1A; border-color: var(--gold); }
.btn-primary:hover { background: var(--gold-dark); border-color: var(--gold-dark); box-shadow: var(--shadow-sm); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-elevated); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #c82333; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--surface-elevated); color: var(--ink); }
.btn-green { background: var(--green); color: white; border-color: var(--green); }
.btn-green:hover { background: var(--green-dark); }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-login {
  padding: 11px 24px; font-size: 15px; background: var(--gold);
  color: #1C1C1A; font-weight: 700; border-radius: var(--r-md);
}
.btn-login:hover { background: var(--gold-dark); }

/* ======================= FORMS ======================= */
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], textarea, select {
  font-family: var(--font-sans); font-size: 14px; padding: 9px 13px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  color: var(--ink); transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none; width: 100%;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: var(--shadow-focus); }
textarea { resize: vertical; min-height: 80px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B6B60' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}
label { display: block; font-size: 13px; font-weight: 600; color: var(--text-1); margin-bottom: 5px; }
.form-group { margin-bottom: 16px; }
.form-group .help { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ======================= MAIN LAYOUT ======================= */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 10;
}
.sidebar-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; }
.sidebar-brand-icon {
  width: 36px; height: 36px; background: var(--gold); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
}
.sidebar-brand-text h2 { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.sidebar-brand-text span { font-size: 11px; color: var(--text-3); }

.compose-btn {
  margin: 16px 20px; padding: 11px 20px; font-size: 14px; font-weight: 700;
  background: var(--gold); color: #1C1C1A; border: none; border-radius: var(--r-md);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--t-fast); font-family: var(--font-sans);
}
.compose-btn:hover { background: var(--gold-dark); box-shadow: var(--shadow-sm); }

.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--text-3); padding: 12px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--r-md); cursor: pointer; transition: all var(--t-fast);
  font-size: 14px; color: var(--text-2); font-weight: 500; position: relative;
}
.nav-item:hover { background: var(--surface-elevated); color: var(--ink); }
.nav-item.active { background: var(--gold-50); color: var(--ink); }
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--gold); border-radius: 0 3px 3px 0;
}
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; background: var(--gold-100); color: var(--gold-dark);
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px;
  min-width: 20px; text-align: center;
}
.nav-item.active .badge { background: var(--gold); color: #1C1C1A; }

.sidebar-footer { padding: 12px 20px; border-top: 1px solid var(--border); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--gold-50);
  color: var(--gold-dark); display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.user-email {
  font-size: 13px; font-weight: 500; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}

/* ======================= MAIN CONTENT ======================= */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); min-height: 56px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--ink); }
.topbar-count { font-size: 13px; color: var(--text-3); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); cursor: pointer;
  color: var(--text-2); font-size: 16px; transition: all var(--t-fast);
}
.topbar-btn:hover { background: var(--surface-elevated); border-color: var(--border-strong); color: var(--ink); }

.content-area { flex: 1; display: flex; overflow: hidden; }
.message-list-pane {
  width: 380px; min-width: 320px; border-right: 1px solid var(--border);
  overflow-y: auto; background: var(--surface);
}
.message-detail-pane {
  flex: 1; overflow-y: auto; background: var(--bg);
  display: flex; flex-direction: column;
}

/* ======================= MESSAGE LIST ======================= */
.message-list { list-style: none; }
.message-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background var(--t-fast); position: relative;
}
.message-item:hover { background: var(--surface-elevated); }
.message-item.active { background: var(--gold-50); border-left: 3px solid var(--gold); padding-left: 13px; }
.message-item.unread .message-sender { font-weight: 700; color: var(--ink); }
.message-item.unread .message-subject { font-weight: 600; }
.message-item .unread-dot {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; background: var(--gold); border-radius: 50%; display: none;
}
.message-item.unread .unread-dot { display: block; }
.message-sender {
  font-size: 13px; font-weight: 500; color: var(--text-1); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.message-subject {
  font-size: 14px; color: var(--ink); margin-bottom: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.message-preview {
  font-size: 12px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.message-time { font-size: 11px; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.message-item-inner { flex: 1; min-width: 0; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: 40px; text-align: center;
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-3); }

/* ======================= MESSAGE DETAIL ======================= */
.message-detail { flex: 1; display: flex; flex-direction: column; }
.message-detail-header { padding: 24px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.message-detail-subject {
  font-size: 20px; font-weight: 700; color: var(--ink); margin-bottom: 16px;
  letter-spacing: -0.3px; line-height: 1.3;
}
.message-detail-meta { display: flex; align-items: flex-start; gap: 12px; }
.sender-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--gold-50);
  color: var(--gold-dark); display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.message-meta-info { flex: 1; }
.message-meta-from { font-size: 14px; font-weight: 600; color: var(--ink); }
.message-meta-to { font-size: 13px; color: var(--text-2); }
.message-meta-cc { font-size: 12px; color: var(--text-3); }
.message-meta-date { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.message-detail-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.message-body {
  flex: 1; padding: 24px 28px; font-size: 14px; line-height: 1.7;
  color: var(--ink); overflow-y: auto;
}
.message-body pre { white-space: pre-wrap; font-family: var(--font-sans); }

.attachment-list {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 28px;
  border-top: 1px solid var(--border); background: var(--surface-elevated);
}
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; color: var(--ink);
  cursor: pointer; transition: all var(--t-fast);
}
.attachment-chip:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.attachment-chip .att-icon { font-size: 14px; }
.attachment-chip .att-size { color: var(--text-3); font-size: 11px; }

/* ======================= COMPOSE (Gmail-style) ======================= */
.compose-overlay {
  position: fixed; inset: 0; background: rgba(28, 28, 26, 0.35);
  backdrop-filter: blur(6px); z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 32px;
}
.compose-overlay.active { display: flex; }
.compose-modal {
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  width: 100%; max-width: 720px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: composeIn 0.3s var(--ease);
}
@keyframes composeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.compose-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
}
.compose-header h3 { font-size: 15px; font-weight: 700; color: var(--ink); letter-spacing: -0.2px; }
.compose-header-actions { display: flex; align-items: center; gap: 6px; }
.compose-close {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: transparent;
  cursor: pointer; color: var(--text-2); font-size: 18px;
  border-radius: var(--r-sm); transition: all var(--t-fast);
}
.compose-close:hover { background: rgba(28,28,26,0.06); color: var(--ink); }

.compose-body { padding: 0; overflow-y: auto; flex: 1; }
.compose-recipient-area {
  padding: 16px 24px 8px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.compose-field {
  display: flex; align-items: center; gap: 12px; padding: 6px 0;
  border-bottom: 1px solid var(--surface-hover);
}
.compose-field:last-child { border-bottom: none; }
.compose-field-label {
  flex: 0 0 48px; font-size: 13px; font-weight: 500; color: var(--text-2);
}
.compose-field input {
  flex: 1; border: none; outline: none; background: transparent;
  font-family: var(--font-sans); font-size: 14px; color: var(--ink);
  padding: 4px 0;
}
.compose-field input::placeholder { color: var(--text-3); }
.compose-field input:focus { outline: none; }
.compose-cc-bcc-toggle {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  cursor: pointer; padding: 4px 8px; border-radius: var(--r-sm);
  transition: all var(--t-fast); white-space: nowrap;
}
.compose-cc-bcc-toggle:hover { color: var(--gold-dark); background: var(--gold-50); }
.compose-field-hidden { display: none; }
.compose-field-visible { display: flex; }

.compose-subject-area { padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface); }
.compose-subject-input {
  width: 100%; border: none; outline: none; background: transparent;
  font-family: var(--font-sans); font-size: 16px; font-weight: 600; color: var(--ink);
  padding: 4px 0;
}
.compose-subject-input::placeholder { color: var(--text-3); font-weight: 400; }

.compose-body-area { padding: 16px 24px; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.compose-textarea {
  flex: 1; min-height: 220px; width: 100%; padding: 8px 0;
  border: none; border-radius: 0;
  font-family: var(--font-sans); font-size: 14px; line-height: 1.6; color: var(--ink);
  resize: none; outline: none; background: transparent;
}
.compose-textarea::placeholder { color: var(--text-3); }

.compose-signature-hint {
  margin-top: 8px; padding-top: 12px; border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-3); font-style: italic;
}

.compose-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 24px 12px; }
.compose-att-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px;
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; color: var(--ink); transition: all var(--t-fast);
}
.compose-att-chip:hover { border-color: var(--gold); box-shadow: var(--shadow-sm); }
.compose-att-chip .att-icon { font-size: 16px; }
.compose-att-chip .att-name { font-weight: 500; }
.compose-att-chip .att-size { color: var(--text-3); font-size: 11px; }
.compose-att-chip .att-remove {
  cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1;
  padding: 0 0 0 4px; transition: color var(--t-fast);
}
.compose-att-chip .att-remove:hover { color: var(--danger); }
.compose-att-chip.uploading { opacity: 0.6; }
.compose-att-chip .att-spinner { animation: spin 0.8s linear infinite; font-size: 14px; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.compose-att-chip .att-inline-tag {
  background: var(--info-light); color: var(--info); font-size: 10px;
  font-weight: 700; padding: 1px 5px; border-radius: 3px;
}

.compose-toolbar {
  display: flex; align-items: center; gap: 4px; padding: 8px 16px;
  border-top: 1px solid var(--border); background: var(--surface-elevated);
}
.compose-tool-btn {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; background: transparent;
  cursor: pointer; color: var(--text-2); font-size: 16px;
  border-radius: var(--r-sm); transition: all var(--t-fast);
}
.compose-tool-btn:hover { background: rgba(28,28,26,0.06); color: var(--ink); }

.compose-actions {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-top: 1px solid var(--border); background: var(--surface);
}
.compose-actions-left { display: flex; align-items: center; gap: 8px; }
.compose-actions-right { display: flex; gap: 10px; }

/* Reply forward bar */
.message-detail-actions {
  display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap;
  padding-top: 16px; border-top: 1px solid var(--border);
}
.detail-action-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; font-weight: 500; color: var(--text-1);
  cursor: pointer; transition: all var(--t-fast);
}
.detail-action-btn:hover {
  background: var(--surface-elevated); border-color: var(--gold);
  color: var(--gold-dark); box-shadow: var(--shadow-sm);
}
.detail-action-btn.primary {
  background: var(--gold); border-color: var(--gold); color: var(--ink); font-weight: 600;
}
.detail-action-btn.primary:hover {
  background: var(--gold-dark); border-color: var(--gold-dark); color: var(--surface);
}
.detail-action-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* Inline reply area */
.inline-reply {
  margin: 0 28px 24px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  display: none;
}
.inline-reply.active { display: block; animation: slideDown 0.25s var(--ease); }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.inline-reply-header {
  padding: 10px 16px; background: var(--surface-elevated);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.inline-reply-header span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.inline-reply textarea {
  width: 100%; min-height: 140px; padding: 12px 16px;
  border: none; outline: none; resize: vertical;
  font-family: var(--font-sans); font-size: 14px; line-height: 1.6; color: var(--ink);
  background: var(--surface);
}
.inline-reply-actions {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-elevated);
}
.inline-reply-attachments { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; }

/* Sent folder badge */
.sent-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; background: var(--green-light); color: var(--green-dark);
  font-size: 11px; font-weight: 600; border-radius: 10px; margin-left: 8px;
}
.sent-to-arrow { color: var(--green-dark); font-weight: 600; }

/* ======================= SETTINGS / SECURITY ======================= */
.settings-screen { display: none; flex: 1; overflow-y: auto; }
.settings-screen.active { display: flex; flex-direction: column; }
.settings-header { padding: 24px 28px; border-bottom: 1px solid var(--border); background: var(--surface); }
.settings-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.settings-header p { font-size: 13px; color: var(--text-2); }
.settings-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  background: var(--surface); padding: 0 28px;
}
.settings-tab {
  padding: 12px 20px; font-size: 14px; font-weight: 600; color: var(--text-2);
  cursor: pointer; border-bottom: 2px solid transparent; transition: all var(--t-fast);
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.active { color: var(--gold-dark); border-bottom-color: var(--gold); }
.settings-content { flex: 1; overflow-y: auto; padding: 28px; }
.settings-panel { display: none; max-width: 560px; }
.settings-panel.active { display: block; }
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 24px; margin-bottom: 20px;
}
.settings-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.settings-section .section-desc { font-size: 13px; color: var(--text-2); margin-bottom: 20px; }

.qr-container { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.qr-code {
  width: 160px; height: 160px; border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px; background: white;
  display: flex; align-items: center; justify-content: center;
}
.qr-code canvas, .qr-code img { max-width: 100%; max-height: 100%; }
.secret-display {
  font-family: var(--font-mono); font-size: 14px; background: var(--surface-elevated);
  padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--border);
  word-break: break-all; margin-bottom: 16px;
}
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 16px; }
.recovery-code {
  font-family: var(--font-mono); font-size: 13px; padding: 6px 10px;
  background: var(--surface-elevated); border-radius: var(--r-sm);
  border: 1px solid var(--border); text-align: center;
}

.session-list { list-style: none; }
.session-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.session-item:last-child { border-bottom: none; }
.session-info { font-size: 13px; }
.session-info .session-ip { font-weight: 600; color: var(--ink); }
.session-info .session-ua { color: var(--text-3); font-size: 12px; }
.session-current {
  font-size: 11px; background: var(--green-light); color: var(--green);
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}

.event-list { list-style: none; }
.event-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.event-item:last-child { border-bottom: none; }
.event-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.event-status.success { background: var(--green); }
.event-status.failure { background: var(--danger); }
.event-details { flex: 1; }
.event-details .event-time { color: var(--text-3); font-size: 12px; }

/* ======================= ADMIN ======================= */
.admin-content { display: none; flex: 1; flex-direction: column; overflow-y: auto; }
.admin-content.active { display: flex; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.admin-header h2 { font-size: 20px; font-weight: 700; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.4px; color: var(--text-3); padding: 12px 16px;
  border-bottom: 1px solid var(--border); background: var(--surface-elevated);
}
.admin-table td {
  padding: 14px 16px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
.admin-table tr:hover td { background: var(--surface-elevated); }
.role-badge {
  display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.role-badge.admin { background: var(--gold-100); color: var(--gold-dark); }
.role-badge.user { background: var(--surface-elevated); color: var(--text-2); }
.admin-table .actions-cell { display: flex; gap: 6px; }
.admin-table .actions-cell .btn { font-size: 12px; padding: 5px 10px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(28, 28, 26, 0.3);
  backdrop-filter: blur(4px); z-index: 100; display: none;
  align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-card {
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  padding: 28px; width: 100%; max-width: 440px; animation: modalIn 0.25s var(--ease);
}
.modal-card h3 { font-size: 18px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ======================= LOADING / TOASTS ======================= */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.loading-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(250, 250, 247, 0.8); z-index: 5;
}
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 200;
  display: flex; flex-direction: column-reverse; gap: 8px;
}
.toast {
  padding: 12px 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-size: 13px;
  color: var(--ink); animation: toastIn 0.3s var(--ease); max-width: 360px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ======================= BADGES ======================= */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-gold { background: var(--gold-100); color: var(--gold-dark); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--surface-elevated); color: var(--text-3); }

/* ======================= RESPONSIVE ======================= */
@media (max-width: 768px) {
  .login-brand { display: none; }
  .login-form-side { flex: 1; }
  .sidebar {
    position: fixed; left: -100%; top: 0; bottom: 0; z-index: 50;
    transition: left var(--t-slow); box-shadow: var(--shadow-xl);
  }
  .sidebar.open { left: 0; }
  .message-list-pane { width: 100%; min-width: unset; border-right: none; }
  .message-detail-pane {
    position: fixed; inset: 0; z-index: 30; display: none;
  }
  .message-detail-pane.active { display: flex; }
}

/* ======================= UTILITIES ======================= */
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-muted { color: var(--text-3); }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
