/* ============================================================
   Correio Interno (mad-mailbox) — port do mock mad-mail.
   FONTE: packages/mad-framework/assets/mad-mail.css
   Servido em public/lib/mad/mad-mail.css (composer mad:sync) e inline na view
   via MadBlade::_css (sobrevive à injeção AJAX das telas MAD).

   Tudo escopado sob .mad-mailbox para não vazar tokens no tema global. Os
   popovers flutuantes (compose, menu, toast) são anexados DENTRO de .mad-mailbox
   pela classe JS MadMail, então herdam estes tokens mesmo com position:fixed.
   ============================================================ */

.mad-mailbox{
  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg:#f4f5f7; --surface:#ffffff; --panel:#fafafb; --panel-2:#f6f6f8;
  --border:#ececf0; --border-2:#e3e3e8;
  --text:#1b1c21; --text-soft:#6c6d77; --text-mut:#9a9ba4;
  --accent:#3b5bff; --accent-ink:#2b46e0; --accent-soft:rgba(59,91,255,.12);
  --purple:#8b5cf6; --danger:#ef4444; --ink-btn:#16181d; --ink-btn-h:#25272f;
  --on:#28c76f; --away:#f5a623; --busy:#ef4444; --off:#b3b4bd;
  --shadow-sm:0 1px 2px rgba(20,22,30,.06);
  --shadow-md:0 6px 22px -8px rgba(20,22,30,.18);
  --shadow-lg:0 18px 50px -12px rgba(20,22,30,.30);
  --radius:12px;
  font-family:var(--font); color:var(--text);
  display:flex; min-height:0; height:calc(100vh - 104px); min-height:520px;
  background:var(--surface); position:relative; overflow:hidden;
  border:1px solid var(--border); border-radius:14px;
}
/* Shell GLOBAL de composição (#madComposeRoot, presente em TODA página): só
   serve de escopo de tokens + mount-point do .m-compose (que é position:fixed).
   NÃO é a tela do correio — zera a caixa pra não virar um card vazio de 520px
   "perdido" no meio de cada página. A tela real é .mad-mailbox#madMailbox. */
#madComposeRoot.mad-mailbox{
  display:block; height:auto; min-height:0;
  background:none; border:0; border-radius:0; overflow:visible;
}
.mad-mailbox[data-theme="dark"]{
  --bg:#0e0f13; --surface:#16171d; --panel:#131419; --panel-2:#181a21;
  --border:#25272f; --border-2:#2d2f39;
  --text:#e9e9ee; --text-soft:#9b9da8; --text-mut:#6c6e7a;
  --accent:#6f86ff; --accent-ink:#8aa0ff; --accent-soft:rgba(111,134,255,.16);
  --purple:#a78bfa; --danger:#f87171; --ink-btn:#e9e9ee; --ink-btn-h:#ffffff;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow-md:0 8px 26px -8px rgba(0,0,0,.55);
  --shadow-lg:0 22px 60px -14px rgba(0,0,0,.7);
}
.mad-mailbox *{box-sizing:border-box}
.mad-mailbox svg{display:block}
.mad-mailbox button{font-family:inherit}

/* ---------- folders column ---------- */
.mad-mailbox .mail-folders{width:248px;flex-shrink:0;background:var(--panel);border-right:1px solid var(--border);
  display:flex;flex-direction:column;padding:16px 12px;overflow-y:auto}
.mad-mailbox .mf-compose{display:flex;align-items:center;justify-content:center;gap:9px;height:46px;border-radius:14px;
  border:0;background:var(--ink-btn);color:var(--surface);font-size:14.5px;font-weight:600;cursor:pointer;
  box-shadow:var(--shadow-md);margin-bottom:14px;flex-shrink:0;transition:background .14s}
.mad-mailbox[data-theme="dark"] .mf-compose{color:#16171d}
.mad-mailbox .mf-compose:hover{background:var(--ink-btn-h)}
.mad-mailbox .mf-compose svg{width:18px;height:18px}

.mad-mailbox .mf-item{display:flex;align-items:center;gap:11px;padding:9px 12px;border-radius:10px;font-size:14px;
  color:var(--text-soft);cursor:pointer;font-weight:450;position:relative}
.mad-mailbox .mf-item svg{width:18px;height:18px;color:var(--text-mut);flex-shrink:0}
.mad-mailbox .mf-item:hover{background:var(--panel-2)}
.mad-mailbox .mf-item.on{background:var(--surface);color:var(--text);font-weight:600;box-shadow:var(--shadow-sm);
  border:1px solid var(--border)}
.mad-mailbox .mf-item.on svg{color:var(--accent)}
.mad-mailbox .mf-item .mf-lbl{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mad-mailbox .mf-item .mf-ct{font-size:12px;font-weight:700;color:var(--text-mut);min-width:18px;text-align:right}
.mad-mailbox .mf-item.on .mf-ct{color:var(--accent)}
.mad-mailbox .mf-item .mf-ct.zero{display:none}
.mad-mailbox .mf-item.unreadct .mf-ct{color:var(--accent)}

.mad-mailbox .mf-grp{font-size:11px;font-weight:700;letter-spacing:.08em;color:var(--text-mut);text-transform:uppercase;
  padding:18px 12px 7px;display:flex;align-items:center;justify-content:space-between}
.mad-mailbox .mf-grp .add{cursor:pointer;color:var(--text-mut);width:20px;height:20px;display:flex;align-items:center;justify-content:center;border-radius:6px}
.mad-mailbox .mf-grp .add:hover{background:var(--panel-2);color:var(--text)}
.mad-mailbox .mf-grp .add svg{width:15px;height:15px}
.mad-mailbox .mf-tag{display:flex;align-items:center;gap:11px;padding:8px 12px;border-radius:10px;font-size:14px;
  color:var(--text-soft);cursor:pointer}
.mad-mailbox .mf-tag:hover{background:var(--panel-2)}
.mad-mailbox .mf-tag.on{background:var(--surface);color:var(--text);font-weight:600;box-shadow:var(--shadow-sm);border:1px solid var(--border)}
.mad-mailbox .mf-tag .sw{width:12px;height:12px;border-radius:4px;flex-shrink:0}
.mad-mailbox .mf-tag .mf-lbl{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mad-mailbox .mf-tag .mf-ct{font-size:12px;color:var(--text-mut)}
/* ações do rótulo (✎ renomear / × remover) — aparecem no hover da linha */
.mad-mailbox .mf-tag .mf-tag-rename,
.mad-mailbox .mf-tag .mf-tag-remove{border:0;background:transparent;color:var(--text-mut);cursor:pointer;
  width:18px;height:18px;border-radius:6px;display:flex;align-items:center;justify-content:center;
  line-height:1;flex-shrink:0;opacity:0;transition:opacity .12s,background .12s}
.mad-mailbox .mf-tag .mf-tag-remove{font-size:15px}
.mad-mailbox .mf-tag .mf-tag-rename{font-size:12px}
.mad-mailbox .mf-tag:hover .mf-tag-rename,
.mad-mailbox .mf-tag:hover .mf-tag-remove{opacity:1}
.mad-mailbox .mf-tag .mf-tag-rename:hover,
.mad-mailbox .mf-tag .mf-tag-remove:hover{background:var(--panel-2);color:var(--text)}
/* input de rename inline ocupa o lugar do label */
.mad-mailbox .mf-tag .mf-tag-edit{flex:1;min-width:0;font-size:14px;padding:2px 6px;border-radius:6px;
  border:1px solid var(--accent);background:var(--surface);color:var(--text);outline:none}
.mad-mailbox .mf-tag.editing .mf-tag-rename{opacity:0;pointer-events:none}
/* "+ Novo rótulo" alinhado às linhas da sidebar */
.mad-mailbox .mad-db-blocks{margin-top:2px}
.mad-mailbox .mad-db-blocks .mad-db-blocks-add{margin:4px 0 0 12px}
.mad-mailbox .mf-foot{margin-top:auto;font-size:11.5px;color:var(--text-mut);display:flex;
  align-items:center;gap:7px;border-top:1px solid var(--border);margin-top:14px;padding-top:12px}
.mad-mailbox .mf-foot .liveb{display:inline-flex;align-items:center;gap:5px;color:var(--on);font-weight:600}
.mad-mailbox .mf-foot .liveb i{width:6px;height:6px;border-radius:50%;background:var(--on);animation:mmPulse 2.4s ease-in-out infinite}

/* ---------- mail root: toolbar + split ---------- */
.mad-mailbox .mail-root{flex:1;min-width:0;display:flex;flex-direction:column;height:100%;min-height:0;background:var(--surface)}

.mad-mailbox .m-toolbar{height:58px;flex:0 0 58px;display:flex;align-items:center;gap:8px;padding:0 16px;
  border-bottom:1px solid var(--border);background:var(--surface)}
.mad-mailbox .m-toolbar .tt{font-size:18px;font-weight:600;letter-spacing:-.01em;margin-right:4px;white-space:nowrap}
.mad-mailbox .m-toolbar .tt .cnt{font-size:13px;font-weight:600;color:var(--text-mut);margin-left:6px}
.mad-mailbox .m-search{display:flex;align-items:center;gap:9px;flex:1;max-width:440px;height:40px;padding:0 13px;
  background:var(--panel);border:1px solid var(--border-2);border-radius:11px;color:var(--text-mut)}
.mad-mailbox .m-search svg{width:17px;height:17px;flex-shrink:0}
.mad-mailbox .m-search input{flex:1;min-width:0;border:0;background:transparent;outline:none;font:inherit;font-size:14px;color:var(--text)}
.mad-mailbox .m-search input::placeholder{color:var(--text-mut)}
.mad-mailbox .m-search .clr{cursor:pointer;width:22px;height:22px;border-radius:6px;display:none;align-items:center;justify-content:center}
.mad-mailbox .m-search.has .clr{display:flex}
.mad-mailbox .m-search .clr:hover{background:var(--panel-2);color:var(--text)}
.mad-mailbox .m-search .clr svg{width:14px;height:14px}
.mad-mailbox .m-spacer{flex:1}
.mad-mailbox .m-tbtn{width:38px;height:38px;border-radius:10px;border:0;background:transparent;color:var(--text-soft);
  cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0;transition:.12s;position:relative}
.mad-mailbox .m-tbtn:hover{background:var(--panel-2);color:var(--text)}
.mad-mailbox .m-tbtn svg{width:18px;height:18px}
.mad-mailbox .m-tbtn.spin svg{animation:mmSpin .7s ease}

/* ---------- split ---------- */
.mad-mailbox .m-split{flex:1;min-height:0;display:flex}
.mad-mailbox .m-split[data-arr="bottom"]{flex-direction:column}

.mad-mailbox .m-list-pane{width:392px;flex-shrink:0;display:flex;flex-direction:column;min-height:0;border-right:1px solid var(--border)}
/* single-pane (estilo Gmail): lista OU leitura ocupam 100% da largura */
.mad-mailbox .m-list-pane.full{width:auto;flex:1;border-right:0}
.mad-mailbox .m-read-pane.full{flex:1;min-width:0}
.mad-mailbox .m-split[data-arr="bottom"] .m-list-pane{width:auto;flex:0 0 46%;border-right:0;border-bottom:1px solid var(--border)}

/* list sub-toolbar (bulk actions) */
.mad-mailbox .m-listbar{height:44px;flex:0 0 44px;display:flex;align-items:center;gap:4px;padding:0 10px 0 12px;
  border-bottom:1px solid var(--border);background:var(--panel)}
.mad-mailbox .m-chk{width:19px;height:19px;border-radius:6px;border:2px solid var(--border-2);background:var(--surface);
  flex-shrink:0;cursor:pointer;display:flex;align-items:center;justify-content:center;color:#fff;position:relative}
.mad-mailbox .m-chk svg{width:13px;height:13px;opacity:0}
.mad-mailbox .m-chk.on{background:var(--accent);border-color:var(--accent)}
.mad-mailbox .m-chk.on svg{opacity:1}
.mad-mailbox .m-chk.some{background:var(--accent);border-color:var(--accent)}
.mad-mailbox .m-chk.some::after{content:"";width:9px;height:2px;border-radius:1px;background:#fff;position:absolute}
.mad-mailbox .m-chk.some svg{opacity:0}
.mad-mailbox .m-listbar .lb-btn{width:34px;height:34px;border-radius:9px;border:0;background:transparent;color:var(--text-soft);
  cursor:pointer;display:flex;align-items:center;justify-content:center}
.mad-mailbox .m-listbar .lb-btn:hover{background:var(--panel-2);color:var(--text)}
.mad-mailbox .m-listbar .lb-btn svg{width:17px;height:17px}
.mad-mailbox .m-listbar .lb-info{font-size:12.5px;color:var(--text-mut);margin-left:auto;padding-right:4px}
.mad-mailbox .m-listbar .selinfo{font-size:13px;color:var(--text);font-weight:600;margin-left:6px}
.mad-mailbox .m-listbar .lb-actions{display:none;align-items:center;gap:2px}
.mad-mailbox .m-listbar.sel .lb-actions{display:flex}
.mad-mailbox .m-listbar.sel .lb-default{display:none}

.mad-mailbox .m-list{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column}

/* list row */
.mad-mailbox .m-row{display:flex;gap:11px;padding:13px 14px 13px 12px;cursor:pointer;border-bottom:1px solid var(--border);
  position:relative;align-items:flex-start;transition:background .1s}
.mad-mailbox .m-row:hover{background:var(--panel-2)}
.mad-mailbox .m-row.active{background:var(--accent-soft)}
.mad-mailbox .m-row.active::before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--accent)}
.mad-mailbox .m-row .rl{display:flex;flex-direction:column;align-items:center;gap:8px;padding-top:2px}
.mad-mailbox .m-row .rowchk{width:18px;height:18px;border-radius:5px;border:2px solid var(--border-2);background:var(--surface);
  cursor:pointer;display:none;align-items:center;justify-content:center;color:#fff;flex-shrink:0}
.mad-mailbox .m-row .rowchk svg{width:12px;height:12px;opacity:0}
.mad-mailbox .m-row:hover .rowchk,.mad-mailbox .m-row.checked .rowchk{display:flex}
.mad-mailbox .m-row.checked .rowchk{background:var(--accent);border-color:var(--accent)}
.mad-mailbox .m-row.checked .rowchk svg{opacity:1}
.mad-mailbox .m-row:hover .c-av-wrap,.mad-mailbox .m-row.checked .c-av-wrap{display:none}
.mad-mailbox .c-av-wrap{display:flex}
.mad-mailbox .m-av{width:38px;height:38px;border-radius:50%;display:flex;align-items:center;justify-content:center;
  font-size:14px;font-weight:600;color:#fff;flex-shrink:0;user-select:none}
.mad-mailbox .m-av.org{border-radius:11px}

.mad-mailbox .m-row .rmid{flex:1;min-width:0}
.mad-mailbox .m-row .rtop{display:flex;align-items:center;gap:8px;margin-bottom:2px}
.mad-mailbox .m-row .rname{font-size:14px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;flex:1;min-width:0}
.mad-mailbox .m-row.unread .rname{font-weight:700}
.mad-mailbox .m-row .rtime{font-size:11.5px;color:var(--text-mut);flex-shrink:0;font-weight:500}
.mad-mailbox .m-row.unread .rtime{color:var(--accent);font-weight:600}
.mad-mailbox .m-row .rsubj{font-size:13.5px;color:var(--text);margin-bottom:2px;white-space:nowrap;overflow:hidden;
  text-overflow:ellipsis;font-weight:450}
.mad-mailbox .m-row.unread .rsubj{font-weight:600}
.mad-mailbox .m-row .rprev{font-size:12.5px;color:var(--text-soft);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.4}
.mad-mailbox .m-row .rmeta{display:flex;align-items:center;gap:6px;margin-top:7px;flex-wrap:wrap}
.mad-mailbox .m-row .rdot{position:absolute;left:4px;top:50%;transform:translateY(-50%);width:7px;height:7px;border-radius:50%;background:var(--accent);display:none}
.mad-mailbox .m-row.unread .rdot{display:block}
.mad-mailbox .m-row .rstar{position:absolute;right:12px;bottom:12px;width:24px;height:24px;border:0;background:transparent;
  cursor:pointer;color:var(--text-mut);display:flex;align-items:center;justify-content:center;border-radius:6px}
.mad-mailbox .m-row .rstar:hover{background:var(--surface)}
.mad-mailbox .m-row .rstar svg{width:16px;height:16px}
.mad-mailbox .m-row .rstar.on{color:#f5a623}
.mad-mailbox .m-row .rattach{color:var(--text-mut);display:inline-flex}
.mad-mailbox .m-row .rattach svg{width:14px;height:14px}

.mad-mailbox .chip{display:inline-flex;align-items:center;gap:5px;height:19px;padding:0 8px;border-radius:6px;font-size:11px;
  font-weight:600;white-space:nowrap}
.mad-mailbox .chip .cd{width:7px;height:7px;border-radius:50%}

/* density compact */
.mad-mailbox[data-density="compact"] .m-row{padding:9px 14px 9px 12px}
.mad-mailbox[data-density="compact"] .m-av{width:32px;height:32px;font-size:12.5px}
.mad-mailbox[data-density="compact"] .m-row .rprev{display:none}
.mad-mailbox[data-density="compact"] .mf-item{padding:7px 12px}

/* ---------- reading pane ---------- */
.mad-mailbox .m-read-pane{flex:1;min-width:0;display:flex;flex-direction:column;min-height:0;background:var(--surface)}
.mad-mailbox .m-split[data-arr="bottom"] .m-read-pane{flex:1}

.mad-mailbox .m-read-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
  text-align:center;gap:14px;color:var(--text-soft);padding:40px}
.mad-mailbox .m-read-empty .ic{width:78px;height:78px;border-radius:22px;background:var(--accent-soft);color:var(--accent);
  display:flex;align-items:center;justify-content:center}
.mad-mailbox .m-read-empty .ic svg{width:38px;height:38px}
.mad-mailbox .m-read-empty h3{margin:0;font-size:17px;font-weight:600;color:var(--text)}
.mad-mailbox .m-read-empty p{margin:0;font-size:13.5px;max-width:280px;line-height:1.55}

.mad-mailbox .m-read{flex:1;min-height:0;display:flex;flex-direction:column}
.mad-mailbox .m-read-head{flex-shrink:0;padding:18px 24px 14px;border-bottom:1px solid var(--border)}
.mad-mailbox .m-read-actions{display:flex;align-items:center;gap:4px;margin-bottom:14px;flex-wrap:wrap}
.mad-mailbox .ra-btn{display:flex;align-items:center;gap:7px;height:36px;padding:0 13px;border-radius:10px;border:1px solid var(--border-2);
  background:var(--surface);color:var(--text);font-size:13px;font-weight:500;cursor:pointer;transition:.12s}
.mad-mailbox .ra-btn:hover{background:var(--panel-2)}
.mad-mailbox .ra-btn svg{width:16px;height:16px;color:var(--text-soft)}
.mad-mailbox .ra-btn.icon{width:36px;padding:0;justify-content:center}
.mad-mailbox .ra-btn.danger:hover{color:var(--danger);border-color:rgba(239,68,68,.4)}
.mad-mailbox .ra-btn.danger:hover svg{color:var(--danger)}
.mad-mailbox .ra-spacer{flex:1}

.mad-mailbox .m-read-subj{font-size:21px;font-weight:600;letter-spacing:-.01em;line-height:1.3;margin:0 0 10px;
  display:flex;align-items:flex-start;gap:10px}
.mad-mailbox .m-read-subj .stbtn{flex-shrink:0;width:30px;height:30px;border-radius:8px;border:0;background:transparent;
  cursor:pointer;color:var(--text-mut);display:flex;align-items:center;justify-content:center;margin-top:1px}
.mad-mailbox .m-read-subj .stbtn:hover{background:var(--panel-2)}
.mad-mailbox .m-read-subj .stbtn svg{width:20px;height:20px}
.mad-mailbox .m-read-subj .stbtn.on{color:#f5a623}
.mad-mailbox .m-read-subj .lblrow{display:inline-flex;gap:6px;flex-wrap:wrap;margin-top:6px}
.mad-mailbox .m-read-subj .subjtxt{flex:1;min-width:0}

.mad-mailbox .m-read-from{display:flex;align-items:center;gap:12px;margin-top:4px}
.mad-mailbox .m-read-from .m-av{width:44px;height:44px;font-size:16px}
.mad-mailbox .m-read-from .fm-mid{flex:1;min-width:0}
.mad-mailbox .m-read-from .fm-nm{font-size:14.5px;font-weight:600;display:flex;align-items:center;gap:7px}
.mad-mailbox .m-read-from .fm-nm .em{font-weight:450;color:var(--text-mut);font-size:13px}
.mad-mailbox .m-read-from .fm-to{font-size:12.5px;color:var(--text-soft);margin-top:2px;display:flex;align-items:center;gap:5px}
.mad-mailbox .m-read-from .fm-time{font-size:12.5px;color:var(--text-mut);flex-shrink:0;text-align:right}

.mad-mailbox .m-read-body{flex:1;min-height:0;overflow-y:auto;padding:22px 24px 30px}
.mad-mailbox .m-read-body .bd{max-width:760px}
.mad-mailbox .m-read-body p{font-size:14.5px;line-height:1.7;color:var(--text);margin:0 0 14px}
.mad-mailbox .m-read-body b{font-weight:600}
.mad-mailbox .m-read-body code{font-family:ui-monospace,monospace;font-size:13px;background:var(--panel-2);
  border:1px solid var(--border);border-radius:5px;padding:1px 6px}
.mad-mailbox .m-thread-msg{max-width:760px;padding-bottom:18px;margin-bottom:18px;border-bottom:1px solid var(--border)}
.mad-mailbox .m-thread-msg:last-child{border-bottom:0}

.mad-mailbox .m-atts{margin-top:22px;max-width:760px}
.mad-mailbox .m-atts .at-h{font-size:12px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--text-mut);
  margin-bottom:10px;display:flex;align-items:center;gap:8px}
.mad-mailbox .m-atts .at-h svg{width:15px;height:15px}
.mad-mailbox .m-atts .at-grid{display:flex;flex-wrap:wrap;gap:10px}
.mad-mailbox .m-att{display:flex;align-items:center;gap:11px;width:232px;padding:10px;border:1px solid var(--border);
  border-radius:12px;background:var(--surface);cursor:pointer;transition:.12s;text-decoration:none;color:var(--text)}
.mad-mailbox .m-att:hover{border-color:var(--border-2);box-shadow:var(--shadow-sm)}
.mad-mailbox .m-att .fic{width:40px;height:40px;border-radius:9px;display:flex;align-items:center;justify-content:center;
  flex-shrink:0;color:#fff}
.mad-mailbox .m-att .fic svg{width:20px;height:20px}
.mad-mailbox .m-att .am{flex:1;min-width:0}
.mad-mailbox .m-att .an{font-size:13px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mad-mailbox .m-att .as{font-size:11.5px;color:var(--text-mut);margin-top:1px}
.mad-mailbox .m-att .dl{color:var(--text-mut);width:20px;height:20px;flex-shrink:0;display:flex;align-items:center;justify-content:center}
.mad-mailbox .m-att .dl svg{width:17px;height:17px}

/* quick-reply box (inline) */
.mad-mailbox .m-reply{max-width:760px;margin-top:22px;border:1px solid var(--border);border-radius:14px;background:var(--panel);padding:12px 14px}
/* corpo de escrita do TinyMCE com altura fixa, independente do chrome (toolbar/statusbar) */
.mad-mailbox .m-reply .tox-edit-area{min-height:130px}
.mad-mailbox .m-reply .tox-edit-area iframe{min-height:130px}
.mad-mailbox .m-reply-actions{display:flex;align-items:center;gap:8px;margin-top:10px}

/* ---------- compose floating window ---------- */
.mad-mailbox .m-compose{position:fixed;right:24px;bottom:0;width:540px;max-width:calc(100vw - 48px);height:600px;
  max-height:calc(100vh - 96px);background:var(--surface);border:1px solid var(--border);
  border-radius:14px 14px 0 0;box-shadow:var(--shadow-lg);display:flex;flex-direction:column;overflow:hidden;
  z-index:1200;animation:mmCompIn .26s cubic-bezier(.2,.8,.3,1)}
.mad-mailbox .m-compose[hidden]{display:none}
.mad-mailbox .m-compose.min{height:46px}
.mad-mailbox .m-compose.min .cp-host,.mad-mailbox .m-compose.min .cp-foot{display:none}
.mad-mailbox .m-compose.max{width:760px;height:calc(100vh - 60px)}
.mad-mailbox .cp-head{height:46px;flex-shrink:0;display:flex;align-items:center;gap:8px;padding:0 8px 0 16px;
  background:var(--ink-btn);color:var(--surface);cursor:pointer}
.mad-mailbox[data-theme="dark"] .cp-head{color:#16171d}
.mad-mailbox .cp-head .cp-ttl{flex:1;font-size:13.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.mad-mailbox .cp-head .cph-btn{width:30px;height:30px;border-radius:7px;border:0;background:transparent;color:inherit;
  opacity:.85;cursor:pointer;display:flex;align-items:center;justify-content:center}
.mad-mailbox .cp-head .cph-btn:hover{background:rgba(255,255,255,.16);opacity:1}
.mad-mailbox[data-theme="dark"] .cp-head .cph-btn:hover{background:rgba(0,0,0,.12)}
.mad-mailbox .cp-head .cph-btn svg{width:16px;height:16px}
.mad-mailbox .cp-host{flex:1;min-height:0;overflow-y:auto}
.mad-mailbox .cp-form{display:flex;flex-direction:column;min-height:100%}
.mad-mailbox .cp-fields{flex:1;display:flex;flex-direction:column;gap:2px;padding:8px 16px}
.mad-mailbox .cp-foot{flex-shrink:0;display:flex;align-items:center;gap:8px;padding:12px 16px;border-top:1px solid var(--border)}
.mad-mailbox .cp-send{display:flex;align-items:center;gap:9px;height:42px;padding:0 22px;border-radius:11px;border:0;
  background:var(--accent);color:#fff;font-size:14px;font-weight:600;cursor:pointer;box-shadow:var(--shadow-sm)}
.mad-mailbox .cp-send:hover{filter:brightness(1.06)}
.mad-mailbox .cp-send svg{width:17px;height:17px}
.mad-mailbox .cp-draft{display:flex;align-items:center;gap:7px;height:42px;padding:0 16px;border-radius:11px;
  border:1px solid var(--border-2);background:var(--surface);color:var(--text-soft);font-size:13.5px;font-weight:500;cursor:pointer}
.mad-mailbox .cp-draft:hover{background:var(--panel-2);color:var(--text)}

/* ---------- generic popover menu ---------- */
.mad-mailbox .m-menu{position:fixed;z-index:1300;background:var(--surface);border:1px solid var(--border);border-radius:12px;
  box-shadow:var(--shadow-lg);padding:6px;min-width:208px;animation:mmDdIn .16s cubic-bezier(.2,.8,.3,1)}
.mad-mailbox .m-menu .mi{display:flex;align-items:center;gap:11px;padding:9px 11px;border-radius:9px;font-size:13.5px;
  color:var(--text);cursor:pointer}
.mad-mailbox .m-menu .mi:hover{background:var(--panel-2)}
.mad-mailbox .m-menu .mi svg{width:17px;height:17px;color:var(--text-soft)}
.mad-mailbox .m-menu .mi .sw{width:12px;height:12px;border-radius:4px}
.mad-mailbox .m-menu .mi.danger{color:var(--danger)}
.mad-mailbox .m-menu .mi.danger svg{color:var(--danger)}
.mad-mailbox .m-menu .mi .ck{margin-left:auto;color:var(--accent);width:16px;height:16px;opacity:0}
.mad-mailbox .m-menu .mi.on .ck{opacity:1}
.mad-mailbox .m-menu .sep{height:1px;background:var(--border);margin:5px 6px}
.mad-mailbox .m-menu .mh{font-size:11px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;color:var(--text-mut);padding:7px 11px 4px}

/* ---------- toast ---------- */
.mad-mailbox .m-toast-wrap{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:1400;display:flex;
  flex-direction:column;gap:9px;align-items:center;pointer-events:none}
.mad-mailbox .m-toast{display:flex;align-items:center;gap:13px;padding:11px 13px 11px 15px;background:var(--ink-btn);
  color:var(--surface);border-radius:12px;box-shadow:var(--shadow-lg);font-size:13.5px;font-weight:500;
  pointer-events:auto;animation:mmToastUp .3s cubic-bezier(.2,.8,.3,1)}
.mad-mailbox[data-theme="dark"] .m-toast{color:#16171d}
.mad-mailbox .m-toast.out{animation:mmToastDn .25s forwards}
.mad-mailbox .m-toast .tx{white-space:nowrap}
.mad-mailbox .m-toast .undo{background:transparent;border:0;color:var(--accent-ink);font-weight:700;font-size:13.5px;cursor:pointer;padding:2px 4px}
.mad-mailbox[data-theme="dark"] .m-toast .undo{color:var(--accent)}

/* empty list */
.mad-mailbox .m-list-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;
  text-align:center;padding:40px 28px;color:var(--text-soft)}
.mad-mailbox .m-list-empty .ic{width:56px;height:56px;border-radius:16px;background:var(--panel-2);color:var(--text-mut);
  display:flex;align-items:center;justify-content:center}
.mad-mailbox .m-list-empty .ic svg{width:26px;height:26px}
.mad-mailbox .m-list-empty p{margin:0;font-size:13.5px;max-width:220px;line-height:1.5}

/* pagination */
.mad-mailbox .m-pager{display:flex;align-items:center;justify-content:center;gap:14px;padding:10px;border-top:1px solid var(--border);font-size:12.5px;color:var(--text-soft)}
.mad-mailbox .m-pager button{width:30px;height:30px;border-radius:8px;border:1px solid var(--border-2);background:var(--surface);color:var(--text-soft);cursor:pointer;display:flex;align-items:center;justify-content:center}
.mad-mailbox .m-pager button:disabled{opacity:.4;cursor:default}
.mad-mailbox .m-pager button svg{width:15px;height:15px}

/* keyframes (prefixados mm* p/ não colidir com o tema global) */
@keyframes mmCompIn{from{transform:translateY(20px);opacity:0}to{transform:none;opacity:1}}
@keyframes mmToastUp{from{transform:translateY(16px);opacity:0}to{transform:none;opacity:1}}
@keyframes mmToastDn{to{transform:translateY(16px);opacity:0}}
@keyframes mmDdIn{from{transform:translateY(-6px);opacity:0}to{transform:none;opacity:1}}
@keyframes mmSpin{to{transform:rotate(360deg)}}
@keyframes mmPulse{0%,100%{opacity:1}50%{opacity:.35}}

/* responsive */
@media (max-width:1320px){.mad-mailbox .m-list-pane{width:340px}}
@media (max-width:1080px){.mad-mailbox .mail-folders{width:210px}}
@media (prefers-reduced-motion: reduce){
  .mad-mailbox .m-compose,.mad-mailbox .m-toast,.mad-mailbox .m-menu{animation:none !important}
}
