/* Final dark theme fix for /mail and /admin-mail. Loaded last on purpose. */
:root {
  --bg: #060b18;
  --bg2: #0b1224;
  --text: #f8fafc;
  --muted: #a8b3cf;
  --line: rgba(255, 255, 255, .14);
  --card: rgba(255, 255, 255, .085);
  --card-solid: #101a33;
  --brand: #60a5fa;
  --brand2: #8b5cf6;
  --ok: #34d399;
  --danger: #fb7185;
  --shadow: 0 28px 90px rgba(0, 0, 0, .38);
}

html,
body,
body.mail-shell,
body.admin-shell {
  min-height: 100%;
  color: var(--text) !important;
  background:
    radial-gradient(circle at 8% 0%, rgba(96, 165, 250, .26), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(139, 92, 246, .24), transparent 34rem),
    radial-gradient(circle at 48% 100%, rgba(14, 165, 233, .12), transparent 32rem),
    linear-gradient(145deg, #0d0827 0%, #07182a 48%, #070b16 100%) !important;
  background-attachment: fixed !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.85), rgba(0,0,0,.15));
}

body.mail-shell .topbar,
body.admin-shell .topbar,
body.admin-shell .brand-panel,
body.admin-shell .admin-card,
body.admin-shell .glass-card,
body.admin-shell .form-section,
body.admin-shell .user-row,
body.admin-shell .status-card,
body.mail-shell .panel-card,
body.mail-shell .login-card,
body.mail-shell .message-table,
body.mail-shell .detail-meta div,
body.mail-shell .address-box,
body.mail-shell .custom-box {
  color: var(--text) !important;
  border: 1px solid rgba(255, 255, 255, .14) !important;
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.065)) !important;
  backdrop-filter: blur(22px) saturate(1.15) !important;
  -webkit-backdrop-filter: blur(22px) saturate(1.15) !important;
  box-shadow: var(--shadow) !important;
}

body.admin-shell .brand-panel,
body.admin-shell .admin-card,
body.mail-shell .compose-panel,
body.mail-shell .inbox-panel,
body.mail-shell .detail-panel,
body.mail-shell .login-card {
  border-radius: 30px !important;
}

body.mail-shell .message-table,
body.mail-shell .message-table-head,
body.mail-shell .message-row,
body.mail-shell .empty-state,
body.mail-shell .message-render,
body.admin-shell .code-panel {
  border-color: rgba(255,255,255,.13) !important;
  background: rgba(7, 13, 31, .48) !important;
  color: var(--text) !important;
}

body.mail-shell .message-table-head {
  color: #bfdbfe !important;
  background: rgba(96, 165, 250, .10) !important;
}

body.mail-shell .message-row:hover,
body.mail-shell .message-row.selected {
  background: rgba(96, 165, 250, .16) !important;
}

body.mail-shell .sender-cell,
body.mail-shell .subject-cell,
body.mail-shell .message-row time,
body.mail-shell .empty-state h3,
body.mail-shell .detail-meta strong,
body.mail-shell .message-render,
body.admin-shell h1,
body.admin-shell h2,
body.admin-shell h3,
body.admin-shell .check,
body.admin-shell .status-card strong,
body.admin-shell .user-row strong,
body.admin-shell .mini-grid span {
  color: var(--text) !important;
}

body.mail-shell .message-row time,
body.mail-shell .empty-state p,
body.mail-shell .hint,
body.mail-shell .muted,
body.mail-shell .mini-label,
body.mail-shell .detail-meta span,
body.admin-shell .hint,
body.admin-shell .muted,
body.admin-shell .status-card span,
body.admin-shell .user-row span,
body.admin-shell label,
body.admin-shell .section-head p {
  color: var(--muted) !important;
}

body.mail-shell input,
body.admin-shell input,
body.admin-shell select,
body.mail-shell select {
  color: #f8fafc !important;
  background: rgba(5, 10, 24, .72) !important;
  border: 1px solid rgba(255,255,255,.16) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05) !important;
}

body.mail-shell input::placeholder,
body.admin-shell input::placeholder {
  color: rgba(203, 213, 225, .58) !important;
}

body.admin-shell select option {
  color: #0f172a;
  background: #ffffff;
}

body.mail-shell .domain-chip,
body.admin-shell code,
body.mail-shell code {
  color: #dbeafe !important;
  background: rgba(96, 165, 250, .14) !important;
  border: 1px solid rgba(96, 165, 250, .20) !important;
}

body.mail-shell .count-pill,
body.admin-shell .mini-grid span {
  color: #dbeafe !important;
  background: rgba(96, 165, 250, .14) !important;
  border: 1px solid rgba(96, 165, 250, .18) !important;
}

body.mail-shell .primary-btn,
body.mail-shell .toolbar-btn.accent,
body.admin-shell .primary-btn {
  color: white !important;
  background: linear-gradient(135deg, #60a5fa, #8b5cf6) !important;
  box-shadow: 0 18px 40px rgba(96, 165, 250, .22) !important;
}

body.mail-shell .secondary-btn,
body.mail-shell .ghost-btn,
body.mail-shell .toolbar-btn,
body.admin-shell .secondary-btn,
body.admin-shell .ghost-btn,
body.admin-shell .toolbar-btn {
  color: #f8fafc !important;
  background: rgba(255,255,255,.10) !important;
  border: 1px solid rgba(255,255,255,.13) !important;
}

body.mail-shell .toolbar-btn.danger,
body.admin-shell .toolbar-btn.danger,
body.admin-shell .danger-text {
  color: #fecdd3 !important;
  background: rgba(244, 63, 94, .13) !important;
  border-color: rgba(244, 63, 94, .22) !important;
}

body.mail-shell button:hover,
body.admin-shell button:hover,
body.mail-shell a.toolbar-btn:hover {
  transform: translateY(-1px);
}

body.mail-shell .alert-error,
body.admin-shell .alert-error {
  color: #fecdd3 !important;
  background: rgba(244,63,94,.14) !important;
  border: 1px solid rgba(244,63,94,.24) !important;
}

body.mail-shell .alert-success,
body.admin-shell .alert-success {
  color: #bbf7d0 !important;
  background: rgba(34,197,94,.12) !important;
  border: 1px solid rgba(34,197,94,.22) !important;
}

body.mail-shell .message-render {
  min-height: 260px;
  line-height: 1.65;
  border-radius: 22px !important;
  overflow-x: auto;
}

body.mail-shell .message-render a {
  color: #93c5fd !important;
}

body.mail-shell .message-render img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

body.mail-shell .message-render table {
  max-width: 100%;
}

body.mail-shell .login-copy {
  background:
    radial-gradient(circle at 15% 10%, rgba(255,255,255,.22), transparent 30%),
    linear-gradient(135deg, rgba(37,99,235,.92), rgba(124,58,237,.92)) !important;
}

body.admin-shell .admin-layout {
  width: min(1180px, calc(100% - 28px));
  margin: 22px auto 54px;
}

@media (max-width: 680px) {
  body.admin-shell .admin-layout,
  body.mail-shell .topbar,
  body.mail-shell .mail-page,
  body.mail-shell .auth-wrap {
    width: min(100% - 18px, 1180px) !important;
  }
  body.admin-shell .brand-panel,
  body.admin-shell .admin-card,
  body.admin-shell .form-section,
  body.mail-shell .compose-panel,
  body.mail-shell .inbox-panel,
  body.mail-shell .detail-panel,
  body.mail-shell .login-card {
    border-radius: 22px !important;
  }
}
