/* ═══════════════ xxxmail — design system ═══════════════
   Profissional, simples, com mesclas sutis de violeta.
   Todos os hooks de id/classe usados pelo app.js foram preservados. */

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

/* O atributo hidden precisa vencer qualquer display de classe (ex.: .app). */
[hidden] { display: none !important; }

:root {
  color-scheme: light;

  --brand-1: #4f46e5;
  --brand-2: #7c3aed;
  --brand-3: #06b6d4;
  --gradient: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 52%, #6d5df6 100%);
  --gradient-soft: linear-gradient(135deg, rgba(79, 70, 229, .10), rgba(124, 58, 237, .10));

  --bg: #f2f3f9;
  --surface: #ffffff;
  --surface-2: #eceef6;
  --surface-3: #f7f8fc;
  --text: #151a28;
  --muted: #667085;
  --border: #e2e6f0;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #b45309;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(23, 25, 45, .10);
  --shadow-sm: 0 2px 8px rgba(23, 25, 45, .06);
  --shadow-brand: 0 6px 18px rgba(99, 91, 255, .28);

  --sidebar-w: 264px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  color-scheme: dark;

  /* Escuro elegante: carvão com matiz violeta profundo — nada de preto-e-branco lavado */
  --bg: #0e0e17;
  --surface: #151522;
  --surface-2: #1f1f30;
  --surface-3: #181826;
  --text: #edeaf7;
  --muted: #a09cb8;
  --border: #282839;
  --accent: #a78bfa;
  --accent-ink: #17122b;
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .4);
  --shadow-brand: 0 6px 20px rgba(139, 109, 250, .30);
  --gradient: linear-gradient(135deg, #6d5df6 0%, #8b5cf6 52%, #7c6cf8 100%);
  --gradient-soft: linear-gradient(135deg, rgba(139, 109, 250, .14), rgba(124, 58, 237, .10));
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.muted { color: var(--muted); }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: var(--text); }
img { display: block; }

::placeholder { color: var(--muted); opacity: .75; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border: 3px solid transparent; border-radius: 8px; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border); background-clip: content-box; border: 3px solid transparent; }

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: var(--radius-sm);
  padding: 10px 18px; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, box-shadow .2s ease, opacity .15s ease, filter .2s ease, background .15s ease;
  white-space: nowrap; letter-spacing: .01em;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: var(--gradient); color: #fff; box-shadow: var(--shadow-brand);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 8px 22px color-mix(in srgb, var(--brand-2) 38%, transparent); }
.btn-primary:active:not(:disabled) { transform: scale(.98); filter: brightness(.97); }
.btn-primary:disabled { opacity: .55; cursor: wait; transform: none; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: none; cursor: pointer; color: var(--muted);
  transition: background .15s ease, color .15s ease;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ── Fields ──────────────────────────────── */
.field { display: block; margin-bottom: 14px; text-align: left; }
.field > span { display: block; font-size: 12px; font-weight: 700; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.field input, .field textarea, .alias-form input, .search {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field textarea:focus, .alias-form input:focus, .search:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field textarea { resize: vertical; min-height: 120px; }

/* ═══════════════ LOGIN (premium) ═══════════════ */
.login-view { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.login-bg {
  position: absolute; inset: 0; overflow: hidden;
  background:
    radial-gradient(900px 620px at 8% 10%, rgba(124, 58, 237, .40), transparent 62%),
    radial-gradient(820px 660px at 94% 90%, rgba(6, 182, 212, .30), transparent 62%),
    radial-gradient(700px 520px at 72% 2%, rgba(79, 70, 229, .34), transparent 62%),
    radial-gradient(560px 560px at 28% 98%, rgba(168, 85, 247, .22), transparent 62%),
    var(--bg);
}
.login-bg::before {
  content: ""; position: absolute; inset: -20%;
  background:
    radial-gradient(560px 420px at 22% 30%, rgba(124, 58, 237, .22), transparent 65%),
    radial-gradient(520px 420px at 80% 68%, rgba(6, 182, 212, .18), transparent 65%);
  animation: aurora-drift 22s ease-in-out infinite alternate;
  pointer-events: none;
}
.login-bg::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}
@keyframes aurora-drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to { transform: translate3d(2%, 2%, 0) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .login-bg::before { animation: none; }
  .login-card { animation: none; }
}
[data-theme="dark"] .login-bg {
  background:
    radial-gradient(900px 620px at 8% 10%, rgba(124, 58, 237, .34), transparent 62%),
    radial-gradient(820px 660px at 94% 90%, rgba(6, 182, 212, .20), transparent 62%),
    radial-gradient(700px 520px at 72% 2%, rgba(109, 93, 246, .28), transparent 62%),
    radial-gradient(560px 560px at 28% 98%, rgba(139, 92, 246, .18), transparent 62%),
    var(--bg);
}
.login-card {
  position: relative; width: 400px; max-width: 100%;
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(26px) saturate(1.25); -webkit-backdrop-filter: blur(26px) saturate(1.25);
  border: 1px solid color-mix(in srgb, var(--brand-2) 22%, var(--border));
  border-radius: 26px;
  padding: 46px 38px 38px; text-align: center;
  box-shadow:
    0 30px 80px rgba(23, 25, 45, .18),
    0 6px 22px rgba(23, 25, 45, .10),
    0 0 44px color-mix(in srgb, var(--brand-2) 14%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .45);
  animation: rise .55s cubic-bezier(.2, .8, .25, 1);
  overflow: hidden;
}
[data-theme="dark"] .login-card {
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, .55),
    0 6px 22px rgba(0, 0, 0, .4),
    0 0 60px color-mix(in srgb, var(--brand-2) 20%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .08);
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 8%; right: 8%; height: 3px;
  background: var(--gradient); border-radius: 0 0 4px 4px;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--brand-2) 55%, transparent);
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: none; } }
.login-logo-wrap { position: relative; width: 88px; height: 88px; margin: 0 auto 20px; }
.login-logo-wrap::before {
  content: ""; position: absolute; inset: -22px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--brand-2) 48%, transparent), transparent 68%);
  filter: blur(12px); pointer-events: none;
}
.login-logo { position: relative; width: 88px; height: 88px; border-radius: 24px; box-shadow: var(--shadow-brand); }
.login-card h1 {
  font-size: 33px; font-weight: 800; letter-spacing: -0.035em; line-height: 1.1;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--muted); margin: 8px 0 30px; font-size: 14.5px; letter-spacing: .01em; }
.login-hint { margin-top: 20px; font-size: 12px; color: var(--muted); }
.login-alt { margin-top: 16px; font-size: 13px; text-align: center; }
.login-alt a { color: var(--accent); text-decoration: none; font-weight: 600; }
.login-alt a:hover { text-decoration: underline; }
#pedirMsg { min-height: 18px; }

/* Inputs do login: fundo sutil, raio generoso, focus com glow */
#loginForm .field > span, #login2faForm .field > span { letter-spacing: .6px; }
#loginForm .field input, #login2faForm .field input {
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
  border-radius: 13px; padding: 13px 15px; font-size: 15px;
  border-width: 1.5px;
}
#loginForm .field input::placeholder, #login2faForm .field input::placeholder { opacity: .6; }
#loginForm .field input:focus, #login2faForm .field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent),
    0 3px 14px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* Botão do login: gradiente com elevação no hover */
#loginForm .btn-primary, #login2faForm .btn-primary {
  margin-top: 8px; padding: 13px 18px; font-size: 15px; border-radius: 13px;
  letter-spacing: .01em;
  transition: transform .14s ease, box-shadow .22s ease, filter .2s ease, opacity .2s ease;
}
#loginForm .btn-primary:hover:not(:disabled), #login2faForm .btn-primary:hover:not(:disabled) {
  transform: translateY(-1px); filter: brightness(1.07);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--brand-2) 42%, transparent);
}
#loginForm .btn-primary:active:not(:disabled), #login2faForm .btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(.99); filter: brightness(.98);
}
#loginForm .btn-primary:disabled, #login2faForm .btn-primary:disabled {
  opacity: .72; cursor: wait; transform: none;
}

/* ═══════════════ APP SHELL ═══════════════ */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand-2) 7%, var(--surface)) 0%, var(--surface) 34%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; box-shadow: var(--shadow-sm); }
.brand-name {
  font-size: 19px; font-weight: 800; letter-spacing: -0.4px;
  background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border: none; border-radius: 10px;
  background: transparent; cursor: pointer; font-weight: 600; font-size: 14px;
  color: var(--muted); text-align: left; width: 100%;
  transition: background .13s ease, color .13s ease;
}
.nav-item svg { flex: none; }
.nav-item[hidden] { display: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active {
  background: var(--gradient-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.badge {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: 999px; background: var(--gradient); color: #fff;
  font-size: 11.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
}

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.catchall-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px;
}
.catchall-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.catchall-chip .dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.catchall-chip strong { color: var(--text); }
.user-line {
  font-size: 12px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 4px;
}

.scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 10px; padding: 0 18px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--gradient); opacity: .35; pointer-events: none;
}
.menu-btn { display: none; }
.search-wrap {
  position: relative; flex: 1; max-width: 520px; display: flex; align-items: center;
}
.search-wrap svg { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.search { padding-left: 38px !important; padding-right: 40px !important; border-radius: 999px !important; background: var(--surface-3) !important; }
.search-wrap kbd {
  position: absolute; right: 14px; font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 7px;
  background: var(--surface); font-family: inherit; pointer-events: none;
}
.topbar .icon-btn { margin-left: auto; }
.topbar .icon-btn + .icon-btn { margin-left: 0; }

.content { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }
.view[hidden] { display: none; }

/* ═══════════════ INBOX ═══════════════ */
.inbox-layout { flex: 1; display: flex; min-height: 0; }

.mail-list { width: 380px; flex: none; border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.mail-item {
  display: flex; gap: 12px; padding: 13px 16px 13px 15px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .14s ease, box-shadow .14s ease; position: relative;
  border-left: 3px solid transparent;
}
.mail-item:hover { background: var(--surface-3); box-shadow: inset 0 1px 0 var(--border); }
.mail-item.is-selected { background: var(--gradient-soft); border-left-color: var(--brand-2); }
.mail-item.is-selected::before { content: none; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #fff;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.avatar img.avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 34px; height: 34px; font-size: 12px; }
.avatar-lg { width: 72px; height: 72px; font-size: 24px; }
.me-avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; vertical-align: -8px; margin-right: 7px; }
.profile-row { display: flex; gap: 16px; align-items: center; margin-top: 12px; }
.storage-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.storage-row:last-child { border-bottom: 0; }
.mail-main { flex: 1; min-width: 0; }
.mail-top { display: flex; align-items: baseline; gap: 8px; }
.mail-from { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.is-unread .mail-from::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); margin-right: 7px; vertical-align: 1px;
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 70%, transparent);
}
.mail-date { margin-left: auto; flex: none; font-size: 12px; color: var(--muted); }
.mail-subject { font-size: 13.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.is-unread .mail-subject { font-weight: 700; }
.mail-snippet { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.mail-to { font-size: 11.5px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-to b { color: var(--accent); font-weight: 600; }
.mail-del {
  position: absolute; right: 10px; bottom: 10px;
  opacity: 0; transition: opacity .13s ease;
}
.mail-item:hover .mail-del, .mail-item:focus-within .mail-del { opacity: 1; }

.list-empty, .list-error { padding: 60px 30px; text-align: center; color: var(--muted); }
.list-empty .big, .list-error .big { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* skeleton */
.skel { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; }
.skel .a { width: 42px; height: 42px; border-radius: 50%; }
.skel .b { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.skel .l { height: 12px; border-radius: 6px; }
.skel .a, .skel .l {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* reader */
.reader { flex: 1; min-width: 0; overflow-y: auto; background: var(--bg); }
.reader-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); padding: 40px; text-align: center; }
.reader-empty-logo { width: 72px; height: 72px; border-radius: 20px; opacity: .85; margin-bottom: 8px; }
.reader-body { max-width: 780px; margin: 0 auto; padding: 30px 34px 60px; animation: rise .25s ease; }
.reader-back { display: none; margin-bottom: 14px; }
.reader-subject { font-size: 22px; letter-spacing: -0.3px; margin-bottom: 14px; }
.reader-meta {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 16px; margin-bottom: 14px;
}
.reader-meta .who { min-width: 0; }
.reader-meta .from { font-weight: 700; }
.reader-meta .addr { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.reader-meta .when { margin-left: auto; flex: none; font-size: 12.5px; color: var(--muted); }
.reader-actions { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.reader-text {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px 26px; white-space: pre-wrap; word-break: break-word;
  line-height: 1.75; font-size: 14.5px; letter-spacing: .005em;
  box-shadow: var(--shadow-sm);
  color: color-mix(in srgb, var(--text) 94%, var(--muted));
}

/* HTML do e-mail: iframe sandboxed (o CSS interno do e-mail vive no
   documento do iframe, montado no app.js — aqui só a moldura) */
.reader-html {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.reader-html iframe { display: block; width: 100%; border: 0; min-height: 320px; background: #fff; }

/* ═══════════════ PAGES (aliases / settings) ═══════════════ */
.page { flex: 1; overflow-y: auto; padding: 34px; max-width: 860px; width: 100%; margin: 0 auto; }
.page h2 { font-size: 24px; letter-spacing: -0.4px; margin-bottom: 6px; }
.page-sub { color: var(--muted); margin-bottom: 22px; max-width: 640px; }
.page-sub strong, .domain-var { color: var(--accent); }

.switch-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.switch-card p { font-size: 13px; margin-top: 2px; }
.switch { position: relative; display: inline-block; flex: none; width: 50px; height: 29px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; z-index: 2; margin: 0; }
.switch .knob { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: background .2s ease; }
.switch .knob::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3);
  transition: transform .2s ease;
}
.switch input:checked + .knob { background: var(--gradient); border-color: transparent; }
.switch input:checked + .knob::after { transform: translateX(21px); }

.alias-form { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.alias-form input { flex: 1; }
.at-suffix { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.at-suffix .domain-var { font-weight: 700; }

.alias-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.alias-list li {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 15px;
  box-shadow: var(--shadow-sm);
  animation: rise .2s ease;
}
.alias-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.alias-list .addr { font-weight: 600; }
.alias-list .addr b { color: var(--accent); }
.alias-list .when { margin-left: auto; font-size: 12px; color: var(--muted); }
.alias-fwd {
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px; border-top: 1px dashed var(--border);
}
.alias-fwd .fwd-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
/* Selo visível: para qual conta o alias encaminha */
.fwd-badge {
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.alias-fwd .fwd-input {
  flex: 1; min-width: 0; padding: 8px 11px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text);
  transition: border-color .15s ease;
}
.alias-fwd .fwd-input:focus { outline: none; border-color: var(--accent); }
.alias-fwd .fwd-select, .alias-fwd .fwd-outro {
  flex: 1; min-width: 0; padding: 8px 11px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--text);
  transition: border-color .15s ease;
}
.alias-fwd .fwd-select:focus, .alias-fwd .fwd-outro:focus { outline: none; border-color: var(--accent); }
.link-danger { background: none; border: none; color: var(--danger); font-weight: 700; cursor: pointer; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.link-qr { background: none; border: none; color: var(--brand-2); font-weight: 700; cursor: pointer; font-size: 13px; padding: 6px 8px; border-radius: 6px; }
.link-qr:hover { background: color-mix(in srgb, var(--brand-2) 10%, transparent); }
.lock-badge { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
/* QR Code do alias */
.qr-body { text-align: center; }
.qr-img { display: inline-block; background: #fff; padding: 12px; border-radius: 12px; line-height: 0; }
.qr-img svg { width: 220px; height: 220px; }
.qr-addr { margin-top: 12px; }
.qr-addr code { font-size: 15px; }
.link-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }

.aliases-empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.status-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow-sm);
}
.status-card p { font-size: 12.5px; margin-top: 3px; }
.status { font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; padding: 5px 11px; border-radius: 999px; flex: none; }
.status.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.status.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }

.info-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow-sm);
}
.info-card h3 { margin-bottom: 10px; font-size: 15px; }
.info-card ol { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 13.5px; }
.info-card em { color: var(--accent); font-style: normal; font-weight: 600; }

/* ═══════════════ MODAL ═══════════════ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 12, 20, .55); backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 18px 18px; animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 560px; max-width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); animation: rise .22s cubic-bezier(.2, .8, .25, 1);
  overflow: hidden;
}
.modal::before { content: ""; display: block; height: 4px; background: var(--gradient); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px 20px; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 20px 20px;
}
.send-hint { font-size: 12px; color: var(--muted); }

/* ═══════════════ TOAST ═══════════════ */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #1c1e2b; color: #fff;
  padding: 12px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px;
  animation: toast-in .25s cubic-bezier(.2, .8, .25, 1); max-width: 90vw;
  border: 1px solid rgba(255, 255, 255, .08);
}
[data-theme="dark"] .toast { background: #232336; color: #edeaf7; border-color: var(--border); }
.toast.error { background: var(--danger); color: #fff; border-color: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .25s ease; }

/* ═══════════════ LOGS ═══════════════ */
.select {
  width: 100%; padding: 11px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s ease;
}
.select:focus { outline: none; border-color: var(--accent); }

.log-filters { display: flex; gap: 10px; margin-bottom: 16px; }
.log-filters .select { width: 170px; flex: none; }
.log-filters input {
  flex: 1; padding: 10px 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.log-filters input:focus { outline: none; border-color: var(--accent); }

.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 14px;
}
.lvl {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 9px; border-radius: 999px; flex: none; margin-top: 2px;
}
.lvl-info { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lvl-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.lvl-error { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.log-main { flex: 1; min-width: 0; }
.log-event { font-weight: 700; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.log-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.log-side { flex: none; text-align: right; }
.log-actor { font-size: 12px; font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-ts { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 1080px) {
  .mail-list { width: 320px; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    transform: translateX(-105%); transition: transform .25s cubic-bezier(.2, .8, .25, 1);
    box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,12,20,.45); z-index: 20; }
  .menu-btn { display: inline-flex; }
  .mail-list { width: 100%; border-right: none; }
  .reader { display: none; }
  body.reading .mail-list { display: none; }
  body.reading .reader { display: block; }
  .reader-back { display: inline-flex; }
  .reader-body { padding: 20px 18px 60px; }
  .status-grid { grid-template-columns: 1fr; }
  .page { padding: 22px 18px; }
  .user-line { display: none; }
  .alias-fwd { flex-wrap: wrap; }
  .alias-fwd .fwd-input { flex: 1 1 100%; }
  .alias-fwd .fwd-select, .alias-fwd .fwd-outro { flex: 1 1 100%; }
  .login-card { padding: 38px 26px 32px; border-radius: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ═══════════════ INBOX: filtros, lote, threads ═══════════════ */
.inbox-tools {
  flex: none; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 14px; display: flex; flex-direction: column; gap: 10px;
}
.inbox-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  font-weight: 700; font-size: 12.5px; padding: 7px 14px; border-radius: 999px; cursor: pointer;
  transition: background .13s ease, color .13s ease;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip.is-active {
  background: var(--gradient-soft); color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.select-inline { width: auto; padding: 7px 10px; font-size: 12.5px; flex: none; }

.batch-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px;
  animation: rise .18s ease;
}
.batch-bar[hidden] { display: none; }
.batch-count { font-size: 12.5px; font-weight: 800; margin-right: 2px; }

.mail-check {
  width: 16px; height: 16px; accent-color: var(--accent);
  flex: none; margin-top: 5px; cursor: pointer;
}
.thread-badge {
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px; padding: 2px 9px; flex: none;
  white-space: nowrap;
}
.mail-item.thread-head { background: var(--surface-3); }
.mail-item.mail-sub { padding-left: 42px; background: var(--surface-3); }
.mail-item.mail-sub .mail-check { margin-left: 0; }

/* etiquetas */
.label-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 2px 9px;
  background: color-mix(in srgb, var(--lc, #6b7280) 14%, transparent);
  color: var(--lc, #6b7280);
  border: 1px solid color-mix(in srgb, var(--lc, #6b7280) 45%, transparent);
  white-space: nowrap;
}
.mail-labels { margin-top: 5px; }
.reader-labels { margin-bottom: 10px; }
.label-form { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.label-form input[type="text"], .label-form input:not([type]) {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.label-form input:focus { outline: none; border-color: var(--accent); }
.forward-form { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.forward-form input {
  flex: 1; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
}
.forward-form input:focus { outline: none; border-color: var(--accent); }
input[type="color"].color-pick {
  width: 40px; height: 34px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); padding: 3px; cursor: pointer; flex: none;
}
.label-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.label-row:last-child { border-bottom: none; }

/* ═══════════════ ENVIADOS ═══════════════ */
.sent-list, .draft-list { display: flex; flex-direction: column; gap: 8px; }
.st {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 4px 10px; border-radius: 999px; flex: none; white-space: nowrap;
}
.st-sent { color: var(--muted); background: var(--surface-2); }
.st-delivered { color: var(--ok); background: color-mix(in srgb, var(--ok) 13%, transparent); }
.st-opened { color: #1d4ed8; background: rgba(37, 99, 235, .12); }
[data-theme="dark"] .st-opened { color: #93c5fd; background: rgba(147, 197, 253, .14); }
.st-bounced { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.st-spam { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.st-failed { color: #fff; background: #7f1d1d; }

/* rascunhos */
.draft-actions { display: flex; gap: 6px; margin-left: auto; flex: none; align-items: center; }

/* ═══════════════ LEITOR: anexos ═══════════════ */
.reader-atts { margin-bottom: 18px; }
.reader-atts h3 { font-size: 13px; margin-bottom: 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.att-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-top: 8px;
  text-decoration: none; color: var(--text);
}
.att-row:hover { background: var(--surface-2); }
.att-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-size { font-size: 12px; color: var(--muted); margin-left: auto; flex: none; }

/* ═══════════════ ALIASES: expiração ═══════════════ */
.exp-badge {
  font-size: 11px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.exp-soon {
  color: var(--warn); border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.exp-past {
  color: var(--danger); border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* ═══════════════ CONFIG: seções, regras, respostas prontas ═══════════════ */
.set-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.set-section h3 { margin-bottom: 2px; font-size: 15px; }
.set-section > .muted { font-size: 13px; margin-bottom: 14px; display: block; }

.rule-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px; margin-bottom: 12px;
}
.rule-form .field { margin-bottom: 0; }
.rule-form .full { grid-column: 1 / -1; }
.rule-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
}
.rule-main { flex: 1; min-width: 0; }
.rule-name { font-weight: 700; }
.rule-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.rule-desc b { color: var(--text); }
.rule-row .switch { width: 44px; height: 26px; }
.rule-row .switch .knob::after { width: 18px; height: 18px; }
.rule-row .switch input:checked + .knob::after { transform: translateX(18px); }

.qr-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.qr-btn {
  font-size: 12px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-3); color: var(--text); border-radius: 999px; padding: 5px 12px; cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Editor: alternância Texto × HTML + prévia */
.cmp-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cmp-modes { display: inline-flex; gap: 6px; }
.cmp-mode {
  font-size: 12px; font-weight: 600; border: 1px solid var(--border);
  background: var(--surface-3); color: var(--text); border-radius: 999px; padding: 4px 11px; cursor: pointer;
}
.cmp-mode:hover { border-color: var(--accent); color: var(--accent); }
.cmp-mode.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.field textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.cmp-preview { margin-top: 10px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.attach-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attach-list { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }
.attach-chip small { opacity: .7; }
.attach-chip button { background: none; border: 0; cursor: pointer; font-size: 12px; line-height: 1; padding: 0; }
.cmp-preview iframe { display: block; width: 100%; height: 300px; border: 0; background: #fff; }

/* ═══════════════ RESPONSIVE (novos blocos) ═══════════════ */
@media (max-width: 860px) {
  .rule-form { grid-template-columns: 1fr; }
  .alias-form { flex-wrap: wrap; }
  .draft-actions { flex-direction: column; align-items: stretch; }
}

/* ═══════════════ LOGIN / CONTAS ═══════════════ */
.login-error {
  display: flex; align-items: flex-start; gap: 10px;
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-left: 3px solid var(--danger);
  color: var(--text);
  font-size: 13px; font-weight: 600; border-radius: 13px; padding: 11px 14px;
  margin: 0 0 16px; text-align: left;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--danger) 12%, transparent);
  animation: shake-in .3s cubic-bezier(.2, .8, .25, 1);
}
.login-error::before {
  content: "!"; flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: 1px;
}
@keyframes shake-in {
  from { opacity: 0; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}
.login-error[hidden] { display: none; }
[data-theme="dark"] .login-error { background: color-mix(in srgb, var(--danger) 14%, #1c1214); }

.user-form {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 18px;
}
.user-form .field { margin-bottom: 0; }
.user-form .full { grid-column: 1 / -1; }
.user-form input, .user-form select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px;
}
.user-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 4px; border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-main { flex: 1; min-width: 180px; }
.user-main .u-email { font-weight: 700; font-size: 14px; }
.user-main .u-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pill {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .4px;
}
.pill.admin { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.pill.off { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

@media (max-width: 860px) {
  .user-form { grid-template-columns: 1fr; }
}

/* Seções restritas ao admin: escondidas para contas comuns */
[data-admin][hidden] { display: none !important; }

/* ── Cota de envio ── */
.quota-head { display:flex; justify-content:space-between; align-items:baseline; margin-bottom:4px; }
.quota-bar { height:10px; border-radius:6px; background:#e5e7eb; overflow:hidden; }
.quota-fill { height:100%; width:0%; border-radius:6px; transition:width .4s ease; }
.quota-brevo { background:linear-gradient(90deg,#4f46e5,#7c3aed); }
.quota-resend { background:linear-gradient(90deg,#f59e0b,#ef4444); }
.quota-fill.quota-warn { background:linear-gradient(90deg,#ef4444,#dc2626); }
/* ── Seletor de provedor no compose ── */
.send-prov { display:flex; align-items:center; gap:8px; font-size:13px; color:#6b7280; }
.select-sm { padding:6px 8px; font-size:13px; }
/* ── Logs amigáveis ── */
.log-code { font-size:11px; color:#9ca3af; font-family:monospace; margin-left:6px; }
