/* ─── CSS Custom Properties per Theme ──────────────────────────────────────── */

:root, [data-theme="light"] {
  --bg:            #F8FAFC;
  --surface:       #FFFFFF;
  --surface2:      #F1F5F9;
  --border:        #E2E8F0;
  --text1:         #0F172A;
  --text2:         #475569;
  --text3:         #94A3B8;
  --accent:        #4F46E5;
  --accent-h:      #4338CA;
  --accent-text:   #FFFFFF;
  --danger:        #DC2626;
  --success:       #16A34A;
  --warning:       #D97706;
  --sb-bg:         #1E293B;
  --sb-text:       #CBD5E1;
  --sb-active-bg:  #334155;
  --sb-active:     #818CF8;
  --unread-dot:    #4F46E5;
  --star:          #F59E0B;
  --shadow:        0 1px 3px 0 rgb(0 0 0/.1), 0 1px 2px -1px rgb(0 0 0/.1);
  --shadow-md:     0 4px 6px -1px rgb(0 0 0/.1), 0 2px 4px -2px rgb(0 0 0/.1);
  --shadow-lg:     0 10px 15px -3px rgb(0 0 0/.1), 0 4px 6px -4px rgb(0 0 0/.1);
  --radius:        8px;
  --radius-lg:     12px;
}

[data-theme="dark"] {
  --bg:            #0F172A;
  --surface:       #1E293B;
  --surface2:      #293548;
  --border:        #334155;
  --text1:         #F1F5F9;
  --text2:         #94A3B8;
  --text3:         #64748B;
  --accent:        #818CF8;
  --accent-h:      #6366F1;
  --accent-text:   #0F172A;
  --danger:        #F87171;
  --success:       #4ADE80;
  --warning:       #FCD34D;
  --sb-bg:         #020617;
  --sb-text:       #94A3B8;
  --sb-active-bg:  #1E293B;
  --sb-active:     #818CF8;
  --unread-dot:    #818CF8;
  --star:          #FCD34D;
  --shadow:        0 1px 3px 0 rgb(0 0 0/.4);
  --shadow-md:     0 4px 6px -1px rgb(0 0 0/.4);
  --shadow-lg:     0 10px 15px -3px rgb(0 0 0/.5);
}

[data-theme="ocean"] {
  --bg:            #F0F9FF;
  --surface:       #FFFFFF;
  --surface2:      #E0F2FE;
  --border:        #BAE6FD;
  --text1:         #0C4A6E;
  --text2:         #0369A1;
  --text3:         #7DD3FC;
  --accent:        #0284C7;
  --accent-h:      #0369A1;
  --accent-text:   #FFFFFF;
  --danger:        #DC2626;
  --success:       #16A34A;
  --warning:       #D97706;
  --sb-bg:         #0C4A6E;
  --sb-text:       #BAE6FD;
  --sb-active-bg:  #075985;
  --sb-active:     #7DD3FC;
  --unread-dot:    #0284C7;
  --star:          #F59E0B;
  --shadow:        0 1px 3px 0 rgb(12 74 110/.15);
  --shadow-md:     0 4px 6px -1px rgb(12 74 110/.2);
  --shadow-lg:     0 10px 15px -3px rgb(12 74 110/.2);
}

[data-theme="forest"] {
  --bg:            #F0FDF4;
  --surface:       #FFFFFF;
  --surface2:      #DCFCE7;
  --border:        #BBF7D0;
  --text1:         #14532D;
  --text2:         #166534;
  --text3:         #6EE7B7;
  --accent:        #16A34A;
  --accent-h:      #15803D;
  --accent-text:   #FFFFFF;
  --danger:        #DC2626;
  --success:       #16A34A;
  --warning:       #D97706;
  --sb-bg:         #14532D;
  --sb-text:       #BBF7D0;
  --sb-active-bg:  #166534;
  --sb-active:     #86EFAC;
  --unread-dot:    #16A34A;
  --star:          #F59E0B;
  --shadow:        0 1px 3px 0 rgb(20 83 45/.15);
  --shadow-md:     0 4px 6px -1px rgb(20 83 45/.2);
  --shadow-lg:     0 10px 15px -3px rgb(20 83 45/.2);
}

[data-theme="sakura"] {
  --bg:            #FFF1F2;
  --surface:       #FFFFFF;
  --surface2:      #FFE4E6;
  --border:        #FECDD3;
  --text1:         #881337;
  --text2:         #9F1239;
  --text3:         #FDA4AF;
  --accent:        #E11D48;
  --accent-h:      #BE123C;
  --accent-text:   #FFFFFF;
  --danger:        #DC2626;
  --success:       #16A34A;
  --warning:       #D97706;
  --sb-bg:         #881337;
  --sb-text:       #FECDD3;
  --sb-active-bg:  #9F1239;
  --sb-active:     #FDA4AF;
  --unread-dot:    #E11D48;
  --star:          #F59E0B;
  --shadow:        0 1px 3px 0 rgb(136 19 55/.15);
  --shadow-md:     0 4px 6px -1px rgb(136 19 55/.2);
  --shadow-lg:     0 10px 15px -3px rgb(136 19 55/.2);
}

/* ─── Base Layout ───────────────────────────────────────────────────────────── */

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text1);
  background: var(--bg);
  transition: background .2s, color .2s;
}

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

/* ─── App Shell ─────────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.3px;
  border-bottom: 1px solid rgb(255 255 255 / .06);
}

.sidebar-logo svg { opacity: .9; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-decoration: none;
  border-radius: 0;
}

.nav-item:hover { background: rgb(255 255 255 / .06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sb-active-bg); color: var(--sb-active); }
.nav-item.active svg { color: var(--sb-active); }
.nav-item svg { flex-shrink: 0; opacity: .8; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-section {
  padding: 6px 16px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgb(255 255 255 / .3);
  margin-top: 8px;
}

/* ─── Header ────────────────────────────────────────────────────────────────── */

.app-header {
  height: 56px;
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 10;
  position: relative;
}

.header-logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text1);
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.header-logo:hover { text-decoration: none; }
.header-logo svg { color: var(--accent); }

.header-search {
  flex: 1;
  max-width: 500px;
  margin: 0 16px;
}

.search-input {
  width: 100%;
  padding: 7px 14px 7px 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text1);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(79 70 229 / .1);
}

.search-input::placeholder { color: var(--text3); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* ─── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-h); color: var(--accent-text); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text1);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { opacity: .9; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  padding: 7px 10px;
}
.btn-ghost:hover { background: var(--surface2); color: var(--text1); }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-icon { padding: 7px; border-radius: 50%; }

/* ─── Cards ─────────────────────────────────────────────────────────────────── */

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

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

.card-body { padding: 20px; }

/* ─── Main content ──────────────────────────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

/* ─── Email list ─────────────────────────────────────────────────────────────── */

.email-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }

.email-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  color: var(--text1);
}

.email-row:last-child { border-bottom: none; }
.email-row:hover { background: var(--surface2); text-decoration: none; }
.email-row.unread { font-weight: 600; }
.email-row.unread .email-subject { color: var(--text1); }

.email-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--unread-dot);
  flex-shrink: 0;
}

.email-meta { flex: 1; min-width: 0; }
.email-from { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-subject-line { display: flex; align-items: baseline; gap: 6px; }
.email-subject { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text1); }
.email-preview { font-size: 12.5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.email-count { font-size: 11.5px; color: var(--text3); background: var(--surface2); padding: 0 5px; border-radius: 4px; font-weight: 600; flex-shrink: 0; }

.email-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.email-date { font-size: 12px; color: var(--text2); white-space: nowrap; }
.email-date.unread { color: var(--accent); font-weight: 600; }

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text3);
  padding: 2px;
  font-size: 14px;
  transition: color .15s;
}
.star-btn:hover { color: var(--star); }
.star-btn.starred { color: var(--star); }

/* ─── Thread view ───────────────────────────────────────────────────────────── */

.thread-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.thread-subject {
  font-size: 20px;
  font-weight: 600;
  color: var(--text1);
  flex: 1;
}

.email-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: none;
  overflow: hidden;
}

.email-card:last-child { border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.email-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background .12s;
}

.email-card-header:hover { background: var(--surface2); }

.email-card-body {
  padding: 0 20px 20px 68px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text1);
}

.email-card-body iframe { border: none; width: 100%; min-height: 200px; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */

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

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text1);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(79 70 229 / .1);
}

.form-control::placeholder { color: var(--text3); }

select.form-control { cursor: pointer; }

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

.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.form-check-label { font-size: 13.5px; color: var(--text1); cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── Tables ─────────────────────────────────────────────────────────────────── */

.table-wrapper { overflow-x: auto; }

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

th {
  padding: 10px 14px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text2);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text1);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-blue   { background: #DBEAFE; color: #1D4ED8; }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-red    { background: #FEE2E2; color: #DC2626; }
.badge-gray   { background: var(--surface2); color: var(--text2); }
.badge-accent { background: var(--accent); color: var(--accent-text); }
[data-theme="dark"] .badge-blue  { background: #1E3A5F; color: #93C5FD; }
[data-theme="dark"] .badge-green { background: #14532D; color: #86EFAC; }
[data-theme="dark"] .badge-red   { background: #450A0A; color: #FCA5A5; }

/* ─── Dropdown ──────────────────────────────────────────────────────────────── */

.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  color: var(--text1);
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover { background: var(--surface2); text-decoration: none; }
.dropdown-item.active { color: var(--accent); font-weight: 600; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-header { padding: 6px 14px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text3); }

/* ─── Profile switcher button ───────────────────────────────────────────────── */

.profile-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  transition: background .15s;
  white-space: nowrap;
  max-width: 200px;
}

.profile-switcher-btn:hover { background: var(--border); }

.profile-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

/* ─── Theme picker ──────────────────────────────────────────────────────────── */

.theme-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text2);
  transition: background .15s;
}

.theme-btn:hover { background: var(--border); color: var(--text1); }

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  flex-shrink: 0;
}

.theme-swatch:hover { transform: scale(1.15); }
.theme-swatch.active { border-color: var(--text1); }

.theme-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}

/* ─── Avatar ─────────────────────────────────────────────────────────────────── */

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Stats cards ───────────────────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon-blue   { background: #DBEAFE; color: #2563EB; }
.stat-icon-purple { background: #EDE9FE; color: #7C3AED; }
.stat-icon-green  { background: #DCFCE7; color: #16A34A; }
.stat-icon-amber  { background: #FEF3C7; color: #D97706; }
[data-theme="dark"] .stat-icon-blue   { background: #1E3A5F; color: #93C5FD; }
[data-theme="dark"] .stat-icon-purple { background: #2E1065; color: #C4B5FD; }
[data-theme="dark"] .stat-icon-green  { background: #14532D; color: #86EFAC; }
[data-theme="dark"] .stat-icon-amber  { background: #431407; color: #FCD34D; }

.stat-value { font-size: 24px; font-weight: 700; color: var(--text1); line-height: 1; }
.stat-label { font-size: 12.5px; color: var(--text2); margin-top: 3px; }

/* ─── Flash / alerts ─────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: #DCFCE7; color: #15803D; border: 1px solid #BBF7D0; }
.alert-error   { background: #FEE2E2; color: #DC2626; border: 1px solid #FECACA; }
.alert-info    { background: #DBEAFE; color: #1D4ED8; border: 1px solid #BFDBFE; }
[data-theme="dark"] .alert-success { background: #14532D; color: #86EFAC; border-color: #166534; }
[data-theme="dark"] .alert-error   { background: #450A0A; color: #FCA5A5; border-color: #7F1D1D; }
[data-theme="dark"] .alert-info    { background: #1E3A5F; color: #93C5FD; border-color: #1E40AF; }

/* ─── Permission grid ───────────────────────────────────────────────────────── */

.perm-grid th, .perm-grid td { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: left; }
.perm-grid input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

/* ─── Compose ───────────────────────────────────────────────────────────────── */

.compose-field {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.compose-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  min-width: 60px;
  padding-top: 2px;
}

.compose-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 13.5px;
  color: var(--text1);
  font-family: inherit;
}

.compose-input::placeholder { color: var(--text3); }

.compose-body {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--text1);
  font-family: inherit;
  resize: none;
  padding: 16px 0;
  line-height: 1.7;
  min-height: 300px;
}

/* ─── Empty state ───────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 20px;
  color: var(--text2);
  text-align: center;
  gap: 12px;
}

.empty-state svg { opacity: .3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text1); }
.empty-state p  { font-size: 13.5px; }

/* ─── Misc utilities ────────────────────────────────────────────────────────── */

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12.5px; }
.text-muted { color: var(--text2); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title { font-size: 20px; font-weight: 700; color: var(--text1); }
.page-subtitle { font-size: 13.5px; color: var(--text2); margin-top: 2px; }

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Illustration containers ───────────────────────────────────────────────── */

.illustration { display: flex; align-items: center; justify-content: center; }
.illustration svg { max-width: 100%; height: auto; }

/* ─── Login page ─────────────────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
}

.login-left {
  flex: 1;
  background: linear-gradient(135deg, var(--accent) 0%, #7C3AED 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: #fff;
}

.login-right {
  width: 420px;
  min-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--surface);
}

@media (max-width: 768px) {
  .login-left { display: none; }
  .login-right { width: 100%; min-width: unset; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ─── Responsive Layout Utilities ───────────────────────────────────────────── */

/* Grid helpers (used by admin 2-col layouts) */
.two-col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.four-col-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* Hamburger button — hidden on desktop, visible on mobile */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text1);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.hamburger-btn:hover { background: var(--border); }

/* Sidebar drawer backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .45);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-backdrop.is-open { display: block; }

/* Mobile search bar (full-width, shown below header on mobile) */
.mobile-search-bar {
  display: none;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.mobile-search-bar form { display: flex; gap: 8px; align-items: center; }
.mobile-search-bar input {
  flex: 1; padding: 8px 12px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text1); font-size: 14px; outline: none;
}
.mobile-search-bar input:focus { border-color: var(--accent); }

/* Mobile bottom navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 150;
  align-items: center;
  justify-content: space-around;
  box-shadow: 0 -2px 12px rgb(0 0 0 / .08);
}
.mobile-bottom-nav a, .mobile-bottom-nav button {
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; color: var(--text2); font-size: 10px; font-weight: 600;
  text-decoration: none; background: none; border: none; cursor: pointer;
  padding: 4px 12px; border-radius: var(--radius); transition: color .15s;
  letter-spacing: .3px;
}
.mobile-bottom-nav a:hover, .mobile-bottom-nav button:hover { text-decoration: none; }
.mobile-bottom-nav a.active, .mobile-bottom-nav a:focus,
.mobile-bottom-nav button.mnav-compose { color: var(--accent); }
.mobile-bottom-nav .mnav-compose svg {
  background: var(--accent); color: var(--accent-text);
  border-radius: 50%; padding: 7px; width: 38px; height: 38px;
}

/* Email row hover actions — CSS-based, no Alpine needed */
.email-hover-actions { display: none; gap: 4px; }
.email-row:hover .email-hover-actions { display: flex; }
.email-row:hover .email-date { display: none; }

/* On touch devices (mobile), always show actions; date stays visible too */
@media (hover: none) {
  .email-hover-actions { display: flex; }
  .email-row .email-date { display: block !important; }
}

/* Dashboard 2-col grid (users table + illustration) */
.dashboard-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

/* User form grid (left: fields, right: permissions/actions sidebar) */
.user-form-grid { display: grid; grid-template-columns: 1fr 380px; gap: 20px; align-items: start; }

/* SMTP profile list card row */
.smtp-profile-row { display: flex; align-items: center; gap: 16px; padding: 16px 20px; flex-wrap: wrap; }
.smtp-profile-meta { flex: 1; min-width: 0; }
.smtp-profile-details { display: flex; gap: 16px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.smtp-profile-section { text-align: right; }
.smtp-profile-section + .smtp-profile-section { padding-left: 16px; border-left: 1px solid var(--border); }

/* Inbox/drafts/search inner scroll container */
.inbox-scroll { overflow-y: auto; flex: 1; }

/* ─── Tablet (≤ 900px) ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .stats-grid, .four-col-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-switcher-btn span.truncate { max-width: 80px; }
}

/* ─── Mobile (≤ 768px) ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Show hamburger */
  .hamburger-btn { display: flex; }

  /* Sidebar becomes a fixed off-canvas drawer */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    width: 264px !important;
    min-width: 264px !important;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.sidebar-open { transform: translateX(0); }

  /* Main content fills full width */
  .main-content { width: 100%; }

  /* Header compact */
  .app-header { padding: 0 12px; gap: 8px; height: 52px; min-height: 52px; }
  .header-search { display: none; }

  /* Show mobile search bar */
  .mobile-search-bar { display: block; }

  /* Add bottom padding so content doesn't hide behind bottom nav */
  .content-area { padding: 14px 12px 72px; }

  /* Show mobile bottom nav */
  .mobile-bottom-nav { display: flex; }

  /* Profile switcher - shorten on mobile */
  .profile-switcher-btn { max-width: 130px; }
  .profile-switcher-btn span.truncate { max-width: 70px; }

  /* Page title */
  .page-title { font-size: 17px; }

  /* Stats grid → 2 col */
  .stats-grid, .four-col-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-card { padding: 14px 14px; }
  .stat-value { font-size: 20px; }

  /* Form rows collapse */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }

  /* Two-col admin grids collapse */
  .two-col-grid { grid-template-columns: 1fr; }

  /* Dashboard grid collapse */
  .dashboard-grid { grid-template-columns: 1fr; }

  /* User form grid collapse */
  .user-form-grid { grid-template-columns: 1fr; }

  /* SMTP profile card: details wrap below name on mobile */
  .smtp-profile-details { width: 100%; justify-content: flex-start; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
  .smtp-profile-section { text-align: left; }
  .smtp-profile-section + .smtp-profile-section { border-left: none; padding-left: 0; border-top: none; }

  /* Inbox scroll div bottom padding (so content isn't hidden under bottom nav) */
  .inbox-scroll { padding-bottom: 72px; }

  /* Page header rows with action buttons wrap on mobile */
  .flex.items-center.justify-between.mb-6 { flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

  /* Thread header wraps on narrow screens */
  .thread-header-row { flex-wrap: wrap; gap: 8px; }
  .thread-header-row .thread-actions { flex-wrap: wrap; }

  /* Permission form wraps on mobile */
  .perm-create-form { flex-wrap: wrap; }
  .perm-create-form .form-group { min-width: 160px; }

  /* Card body padding */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; }

  /* Email list */
  .email-row { padding: 10px 10px; gap: 8px; }
  .email-avatar { width: 32px; height: 32px; font-size: 11px; }
  .email-from { font-size: 13px; }
  .email-subject { font-size: 12.5px; }
  .email-preview { font-size: 12px; }
  .email-date { font-size: 11px; }

  /* Thread view — reduce deep indent on mobile */
  .email-card-body { padding: 12px 14px 16px 14px; }
  .email-card-header { padding: 12px 14px; }

  /* Compose field */
  .compose-label { min-width: 44px; font-size: 12px; }

  /* Tables scroll horizontally */
  .card > div > table, .card table { min-width: 540px; }
  .card { overflow-x: auto; }

  /* Permission grid - hide less important columns */
  .perm-grid { font-size: 12px; }
  .perm-grid th, .perm-grid td { padding: 8px 8px; }

  /* Alert messages */
  .alert { font-size: 13px; padding: 10px 12px; }

  /* Content area headings row */
  .flex.items-center.gap-3.mb-6 { flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

  /* Dropdown menus — wider on mobile */
  .dropdown-menu { min-width: 200px; }

  /* Hide profile switcher text, show only dot on very small */
  .header-search { display: none; }
}

/* ─── Small phones (≤ 480px) ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .stats-grid, .four-col-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-icon { width: 36px; height: 36px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11.5px; }

  /* Header — hide profile switcher completely, keep hamburger + avatar + theme */
  .profile-switcher-btn { display: none; }

  /* Email rows even more compact */
  .email-row { padding: 9px 10px; }
  .email-right { gap: 3px; }
  .email-avatar { width: 30px; height: 30px; }

  /* Thread header actions wrap */
  .thread-actions { flex-wrap: wrap; gap: 6px; }

  /* Content area */
  .content-area { padding: 10px 10px 72px; }

  .card-body { padding: 12px; }

  /* Page title */
  .page-title { font-size: 15px; }

  /* Compose */
  .compose-label { min-width: 36px; }
}

/* ─── Login page mobile already has its own query above ─────────────────────── */
/* Enhanced login mobile */
@media (max-width: 768px) {
  .login-right { padding: 32px 24px; }
}
