/* ================================================================
   远辰智联邮箱系统 - 主样式
   ================================================================ */
:root {
  --primary: #1565c0;
  --primary-light: #1976d2;
  --primary-dark: #0d47a1;
  --primary-hover: #1e88e5;
  --accent: #00acc1;
  --accent-light: #26c6da;
  --success: #2e7d32;
  --success-light: #43a047;
  --warning: #e65100;
  --warning-light: #f57c00;
  --danger: #c62828;
  --danger-light: #e53935;
  --info: #0277bd;
  --text-primary: #1a1a2e;
  --text-secondary: #546e7a;
  --text-muted: #90a4ae;
  --text-light: #cfd8dc;
  --bg-body: #f0f4f8;
  --bg-white: #ffffff;
  --bg-sidebar: #0d1b2a;
  --bg-sidebar-hover: #1a2e45;
  --bg-header: #ffffff;
  --border: #e0e8f0;
  --border-light: #f0f4f8;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.06);
  --shadow: 0 2px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.15);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: all .2s ease;
  --font: 'PingFang SC','Segoe UI','Microsoft YaHei',sans-serif;
  --sidebar-width: 220px;
}

*, *::before, *::after { box-sizing: border-box; }

button { border: none; outline: none; cursor: pointer; background: transparent; font-family: var(--font); }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text-primary);
  margin: 0; padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-hover); }

img { max-width: 100%; vertical-align: middle; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5ccd6; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9aaab4; }

/* ================================================================
   AUTH PAGES (Login / Register)
   ================================================================ */
.auth-bg {
  min-height: 100vh;
  background: linear-gradient(135deg, #0d47a1 0%, #1565c0 40%, #00acc1 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.auth-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
  top: -200px; right: -150px;
  pointer-events: none;
}

.auth-bg::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.auth-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px;
  padding: 48px 40px;
  position: relative; z-index: 1;
  animation: slideUp .4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  text-align: center; margin-bottom: 32px;
}

.auth-logo .logo-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(21,101,192,.3);
}

.auth-logo .logo-icon svg { width: 34px; height: 34px; color: #fff; }

.auth-logo h1 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--text-primary); margin: 0 0 6px;
}

.auth-logo p {
  color: var(--text-secondary); font-size: .875rem; margin: 0;
}

.auth-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  margin-bottom: 28px; gap: 24px;
}

.auth-tab {
  padding: 10px 0; font-size: 1rem; font-weight: 600;
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: var(--transition);
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.form-group { margin-bottom: 20px; }

.form-label {
  display: block; margin-bottom: 7px;
  font-weight: 500; color: var(--text-primary); font-size: .875rem;
}

.form-control {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9375rem; font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-white);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}

.form-control.is-invalid { border-color: var(--danger-light); }

.input-group { position: relative; }

.input-group .form-control { padding-left: 42px; }

.input-group .input-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 18px; height: 18px;
}

.input-group .input-suffix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-secondary); font-size: .8125rem;
  background: var(--bg-body); padding: 2px 8px;
  border-radius: 4px; pointer-events: none;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 22px; border-radius: var(--radius-sm);
  font-size: .9375rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; border: none; outline: none;
  transition: var(--transition); white-space: nowrap;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 3px 12px rgba(21,101,192,.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  box-shadow: 0 5px 18px rgba(21,101,192,.4);
  transform: translateY(-1px); color: #fff;
}

.btn-primary:active { transform: translateY(0); }

.btn-block { width: 100%; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(21,101,192,.04); }

.btn-sm { padding: 6px 14px; font-size: .8125rem; }

.btn-lg { padding: 13px 28px; font-size: 1rem; }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover { background: var(--danger-light); color: #fff; }

.btn-success {
  background: var(--success); color: #fff;
}
.btn-success:hover { background: var(--success-light); color: #fff; }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--bg-body); color: var(--primary); }

.btn-icon {
  padding: 7px; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-secondary);
  border: none; outline: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--bg-body); color: var(--primary); }
.btn-icon svg { width: 18px; height: 18px; }

.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 20px; font-size: .875rem;
  display: flex; align-items: flex-start; gap: 10px;
  animation: fadeIn .3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-danger  { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.alert-info    { background: #e3f2fd; color: #0277bd; border: 1px solid #90caf9; }
.alert-warning { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }

/* ================================================================
   MAIN LAYOUT
   ================================================================ */
.app-layout {
  display: flex; min-height: 100vh; flex-direction: column;
}

.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  height: 58px;
  display: flex; align-items: center;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 16px;
}

.app-header .logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.05rem; color: var(--text-primary);
  text-decoration: none; flex-shrink: 0;
}

.app-header .logo-icon-sm {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}

.app-header .logo-icon-sm svg { width: 20px; height: 20px; color: #fff; }

.header-search {
  flex: 1; max-width: 500px; position: relative;
}

.header-search input {
  width: 100%; padding: 8px 14px 8px 38px;
  border: 1.5px solid var(--border);
  border-radius: 20px; font-size: .875rem;
  background: var(--bg-body); color: var(--text-primary);
  transition: var(--transition); outline: none;
}

.header-search input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(21,101,192,.1);
}

.header-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); width: 16px; height: 16px;
}

.header-actions {
  display: flex; align-items: center; gap: 6px; margin-left: auto;
}

.header-badge {
  position: relative;
}

.badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  padding: 1px 5px; border-radius: 10px;
  min-width: 16px; text-align: center;
  line-height: 1.4;
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  object-fit: cover; cursor: pointer;
  border: 2px solid var(--border);
  transition: var(--transition);
}

.avatar:hover { border-color: var(--primary); }

.avatar-sm { width: 28px; height: 28px; }
.avatar-lg { width: 48px; height: 48px; }

.dropdown { position: relative; }

.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 1000;
  padding: 6px 0;
  animation: fadeDown .2s ease;
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-menu.hidden { display: none; }

.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: var(--text-primary);
  font-size: .875rem; cursor: pointer;
  transition: var(--transition);
}

.dropdown-item:hover { background: var(--bg-body); color: var(--primary); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-secondary); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #ffebee; }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.user-info-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}

.user-info-header .name { font-weight: 600; font-size: .9375rem; }
.user-info-header .email { color: var(--text-secondary); font-size: .8125rem; margin-top: 2px; }

/* ================================================================
   SIDEBAR
   ================================================================ */
.app-body {
  display: flex; flex: 1; overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
  position: sticky; top: 58px;
  height: calc(100vh - 58px);
}

.sidebar-compose {
  padding: 16px 14px;
}

.btn-compose {
  width: 100%; padding: 11px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: .9rem; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: var(--transition);
  box-shadow: 0 3px 12px rgba(0,0,0,.25);
}

.btn-compose:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(0,0,0,.3);
}

.btn-compose svg { width: 18px; height: 18px; }

.sidebar-nav { flex: 1; padding: 4px 0; }

.nav-section { margin-bottom: 6px; }

.nav-section-title {
  padding: 10px 16px 4px;
  font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  color: rgba(255,255,255,.35); text-transform: uppercase;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; margin: 1px 8px;
  color: rgba(255,255,255,.7);
  font-size: .875rem;
  cursor: pointer; border-radius: var(--radius-sm);
  transition: var(--transition);
  text-decoration: none; position: relative;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: rgba(21,101,192,.5);
  color: #fff;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--accent);
  border-radius: 0 2px 2px 0; margin-left: -8px;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff; font-size: .7rem; font-weight: 700;
  padding: 1px 7px; border-radius: 10px;
  line-height: 1.5; min-width: 20px; text-align: center;
}

.nav-badge.red { background: var(--danger); }

.sidebar-storage {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.storage-bar {
  height: 4px; background: rgba(255,255,255,.15);
  border-radius: 2px; overflow: hidden; margin: 6px 0;
}

.storage-fill {
  height: 100%; background: var(--accent);
  border-radius: 2px; transition: width .6s ease;
}

.storage-text {
  font-size: .75rem; color: rgba(255,255,255,.5);
  display: flex; justify-content: space-between;
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
  flex: 1; overflow-y: auto;
  background: var(--bg-body);
  display: flex; flex-direction: column;
}

.content-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex; align-items: center; gap: 12px;
}

.content-header h2 {
  font-size: 1.125rem; font-weight: 700;
  color: var(--text-primary); margin: 0;
}

.content-header .header-tools {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* ================================================================
   MAIL LIST
   ================================================================ */
.mail-container {
  display: flex; flex: 1; overflow: hidden;
  background: var(--bg-white);
}

.mail-list-panel {
  width: 380px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.mail-list-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.mail-list-toolbar .select-all {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}

.toolbar-actions { display: flex; gap: 4px; }

.mail-list {
  flex: 1; overflow-y: auto;
}

.mail-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}

.mail-item:hover { background: #f5f8ff; }
.mail-item.selected { background: #e8f0fe; }
.mail-item.active { background: #e8f0fe; border-left: 3px solid var(--primary); }

.mail-item.unread .mail-sender { font-weight: 700; }
.mail-item.unread .mail-subject { font-weight: 600; }
.mail-item.unread::after {
  content: '';
  position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; background: var(--primary);
  border-radius: 50%;
}

.mail-item-check {
  flex-shrink: 0; margin-top: 2px;
  width: 16px; height: 16px; accent-color: var(--primary);
}

.mail-item-body { flex: 1; min-width: 0; }

.mail-sender {
  font-size: .875rem; color: var(--text-primary);
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 3px;
}

.mail-sender .sender-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}

.mail-sender .mail-time {
  font-size: .75rem; color: var(--text-muted);
  font-weight: 400; flex-shrink: 0;
}

.mail-subject {
  font-size: .875rem; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}

.mail-preview {
  font-size: .8rem; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mail-tags {
  display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap;
}

.tag {
  font-size: .7rem; padding: 1px 7px; border-radius: 10px;
  font-weight: 500;
}

.tag-star { background: #fff8e1; color: #f59f00; }
.tag-attach { background: #e3f2fd; color: #0277bd; }
.tag-flagged { background: #ffebee; color: #c62828; }

/* ================================================================
   MAIL DETAIL
   ================================================================ */
.mail-detail-panel {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}

.mail-detail-empty {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-muted);
}

.mail-detail-empty svg { width: 80px; height: 80px; margin-bottom: 16px; opacity: .3; }
.mail-detail-empty p { font-size: 1rem; }

.mail-detail-toolbar {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; background: var(--bg-white);
}

.mail-detail-body {
  flex: 1; overflow-y: auto; padding: 28px;
}

.mail-detail-subject {
  font-size: 1.375rem; font-weight: 700;
  color: var(--text-primary); margin-bottom: 20px;
  line-height: 1.4;
}

.mail-meta {
  background: var(--bg-body); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 24px;
  display: flex; gap: 14px; align-items: flex-start;
}

.mail-meta .meta-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.125rem; font-weight: 700; flex-shrink: 0;
}

.mail-meta-info { flex: 1; }

.mail-meta-info .from-name {
  font-weight: 600; font-size: .9375rem; color: var(--text-primary);
}

.mail-meta-info .from-email {
  font-size: .8125rem; color: var(--text-secondary);
}

.mail-meta-info .to-info {
  font-size: .8125rem; color: var(--text-secondary); margin-top: 4px;
}

.mail-meta .meta-time {
  font-size: .8125rem; color: var(--text-muted); flex-shrink: 0;
}

.mail-body-content {
  background: var(--bg-white); border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px 28px; line-height: 1.8;
  color: var(--text-primary); font-size: .9375rem;
  word-break: break-word;
}

.mail-attachments {
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

.mail-attachments h4 {
  font-size: .875rem; color: var(--text-secondary);
  margin: 0 0 12px;
}

.attachment-list {
  display: flex; flex-wrap: wrap; gap: 10px;
}

.attachment-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
}

.attachment-item:hover {
  border-color: var(--primary);
  background: #e8f0fe;
}

.attachment-icon {
  width: 36px; height: 36px;
  background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .75rem; font-weight: 700;
}

.attachment-info .file-name {
  font-size: .875rem; font-weight: 500; color: var(--text-primary);
  max-width: 160px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.attachment-info .file-size {
  font-size: .75rem; color: var(--text-muted);
}

/* ================================================================
   COMPOSE MODAL
   ================================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  animation: fadeIn .2s ease;
}

.modal-overlay.hidden { display: none; }

.compose-window {
  width: 720px; max-width: 96vw;
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: flex; flex-direction: column;
  max-height: 88vh;
  animation: slideUp .3s ease;
}

.compose-header {
  display: flex; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.compose-header h3 {
  margin: 0; font-size: 1rem; font-weight: 700;
  color: var(--text-primary); flex: 1;
}

.compose-body {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}

.compose-field {
  display: flex; align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.compose-field label {
  font-size: .8125rem; font-weight: 600;
  color: var(--text-secondary); width: 36px; flex-shrink: 0;
}

.compose-field input {
  flex: 1; border: none; outline: none;
  font-size: .9rem; font-family: var(--font);
  color: var(--text-primary); background: transparent;
}

.compose-field .cc-link {
  font-size: .8125rem; color: var(--primary); cursor: pointer;
}

.compose-toolbar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 2px; flex-wrap: wrap; flex-shrink: 0;
}

.toolbar-btn {
  padding: 5px 8px; border: none; background: transparent;
  color: var(--text-secondary); cursor: pointer;
  border-radius: var(--radius-sm); font-size: .8125rem;
  transition: var(--transition); display: flex; align-items: center;
}

.toolbar-btn:hover { background: var(--bg-body); color: var(--primary); }
.toolbar-btn svg { width: 16px; height: 16px; }

.compose-editor {
  flex: 1; padding: 16px 20px;
  min-height: 260px; max-height: 380px;
  overflow-y: auto; outline: none;
  font-size: .9375rem; line-height: 1.8;
  color: var(--text-primary);
}

.compose-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}

.compose-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}

.compose-attach-list {
  padding: 6px 20px 0;
  display: flex; flex-wrap: wrap; gap: 8px;
}

.compose-attach-item {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  background: var(--bg-body); border: 1px solid var(--border);
  border-radius: 20px; font-size: .8rem;
  color: var(--text-secondary);
}

.compose-attach-item .remove-attach {
  cursor: pointer; color: var(--text-muted);
  display: flex; width: 14px; height: 14px;
}

.compose-attach-item .remove-attach:hover { color: var(--danger); }

/* ================================================================
   CARDS & PANELS
   ================================================================ */
.card {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}

.card-header h3 {
  font-size: 1rem; font-weight: 700; margin: 0; flex: 1;
}

.card-body { padding: 20px; }

.page-container { padding: 24px; }

/* ================================================================
   TABLE
   ================================================================ */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%; border-collapse: collapse;
  font-size: .875rem;
}

.table th {
  padding: 11px 14px;
  background: var(--bg-body); color: var(--text-secondary);
  font-weight: 600; text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tr:hover td { background: #f5f8ff; }

.table tr:last-child td { border-bottom: none; }

/* ================================================================
   BADGES & STATUS
   ================================================================ */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}

.status-active  { background: #e8f5e9; color: #2e7d32; }
.status-inactive { background: #ffebee; color: #c62828; }
.status-admin   { background: #e3f2fd; color: #0277bd; }
.status-user    { background: var(--bg-body); color: var(--text-secondary); }

/* ================================================================
   PAGINATION
   ================================================================ */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 16px; justify-content: center;
}

.pagination a, .pagination span {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  font-size: .875rem; color: var(--text-secondary);
  border: 1px solid var(--border);
  transition: var(--transition); cursor: pointer;
  text-decoration: none;
}

.pagination a:hover { border-color: var(--primary); color: var(--primary); background: #e8f0fe; }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ================================================================
   STATS CARDS (ADMIN)
   ================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px; padding: 24px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  padding: 22px;
  display: flex; align-items: center; gap: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 28px; height: 28px; color: #fff; }

.stat-icon.blue   { background: linear-gradient(135deg, #1565c0, #1976d2); }
.stat-icon.green  { background: linear-gradient(135deg, #2e7d32, #43a047); }
.stat-icon.orange { background: linear-gradient(135deg, #e65100, #f57c00); }
.stat-icon.cyan   { background: linear-gradient(135deg, #00838f, #00acc1); }

.stat-info .value {
  font-size: 1.75rem; font-weight: 800;
  color: var(--text-primary); line-height: 1;
}

.stat-info .label {
  font-size: .8125rem; color: var(--text-secondary); margin-top: 4px;
}

/* ================================================================
   SETTINGS PAGE
   ================================================================ */
.settings-layout {
  display: flex; gap: 0;
  background: var(--bg-white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 500px;
}

.settings-nav {
  width: 220px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 8px 0;
}

.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; cursor: pointer;
  color: var(--text-secondary); font-size: .875rem;
  transition: var(--transition);
}

.settings-nav-item:hover { background: var(--bg-body); color: var(--primary); }
.settings-nav-item.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }
.settings-nav-item svg { width: 16px; height: 16px; }

.settings-content { flex: 1; padding: 28px; }

.settings-section { display: none; }
.settings-section.active { display: block; }

.settings-section h3 {
  font-size: 1.0625rem; font-weight: 700;
  margin: 0 0 20px; padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.form-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}

.form-row.three-col { grid-template-columns: 1fr 1fr 1fr; }

.form-hint {
  font-size: .8rem; color: var(--text-muted); margin-top: 5px;
}

/* ================================================================
   CONTACTS
   ================================================================ */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; padding: 20px;
}

.contact-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px;
  transition: var(--transition);
  cursor: pointer;
}

.contact-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.contact-avatar {
  width: 54px; height: 54px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.25rem; font-weight: 700;
}

.contact-name { font-weight: 600; font-size: .9375rem; }
.contact-email { font-size: .8125rem; color: var(--text-secondary); word-break: break-all; }
.contact-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ================================================================
   ADMIN LAYOUT
   ================================================================ */
.admin-layout {
  display: flex; min-height: 100vh; flex-direction: column;
}

.admin-header {
  background: var(--bg-sidebar);
  height: 58px;
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.admin-header .logo {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-weight: 700; font-size: 1.0625rem;
  text-decoration: none;
}

.admin-header .admin-tag {
  font-size: .7rem; padding: 2px 8px;
  background: var(--accent); color: #fff;
  border-radius: 4px; font-weight: 700;
}

.admin-header .header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
}

.admin-header .admin-user {
  color: rgba(255,255,255,.8); font-size: .875rem;
}

.admin-body { display: flex; flex: 1; }

.admin-sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid rgba(255,255,255,.07);
  padding: 12px 0;
  position: sticky; top: 58px;
  height: calc(100vh - 58px); overflow-y: auto;
}

.admin-nav-section-title {
  padding: 12px 18px 4px;
  font-size: .7rem; font-weight: 700; letter-spacing: .08em;
  color: rgba(255,255,255,.3); text-transform: uppercase;
}

.admin-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; margin: 1px 8px;
  color: rgba(255,255,255,.65);
  font-size: .875rem; cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  text-decoration: none;
}

.admin-nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.admin-nav-item.active { background: rgba(21,101,192,.5); color: #fff; font-weight: 600; }
.admin-nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.admin-main { flex: 1; overflow-y: auto; background: var(--bg-body); }

.admin-page { padding: 24px; }

.admin-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}

.admin-page-header h2 {
  font-size: 1.25rem; font-weight: 800; margin: 0;
  color: var(--text-primary);
}

/* ================================================================
   EDITOR
   ================================================================ */
.rich-editor-wrap {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rich-editor-toolbar {
  display: flex; gap: 2px; padding: 8px 10px;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.editor-area {
  min-height: 200px; padding: 14px 16px;
  outline: none; font-size: .9375rem;
  line-height: 1.8; color: var(--text-primary);
}

/* ================================================================
   TOAST / NOTIFICATION
   ================================================================ */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 9999;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-radius: var(--radius);
  background: var(--bg-white);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  font-size: .875rem; min-width: 280px;
  animation: toastIn .3s ease;
  color: var(--text-primary);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error   svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }

/* ================================================================
   MISC UTILITIES
   ================================================================ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-primary-color { color: var(--primary); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.divider {
  border: none; border-top: 1px solid var(--border);
  margin: 20px 0;
}

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 72px; height: 72px; opacity: .25; margin-bottom: 16px; }
.empty-state h3 { font-size: 1rem; margin: 0 0 8px; color: var(--text-secondary); }
.empty-state p  { font-size: .875rem; margin: 0; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1100px) {
  .mail-list-panel { width: 320px; }
}

@media (max-width: 900px) {
  .sidebar { width: 56px; }
  .sidebar .nav-item span,
  .sidebar .nav-section-title,
  .sidebar .btn-compose span,
  .sidebar .storage-text,
  .sidebar .storage-bar,
  .sidebar-storage { display: none; }
  .btn-compose { padding: 11px; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item svg { width: 20px; height: 20px; }
  .nav-badge { position: absolute; right: 4px; top: 4px; }
  .mail-list-panel { width: 280px; }
  :root { --sidebar-width: 56px; }
}

@media (max-width: 700px) {
  .mail-container { flex-direction: column; }
  .mail-list-panel { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
  .mail-detail-panel { min-height: 400px; }
  .compose-window { width: 100vw; max-height: 100vh; border-radius: 0; }
  .form-row { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
}
