/* ===== The Orange Mail — tema laranja (inspirado em dashboards Materio) ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #ff6a00;
  --primary-d: #e85f00;
  --primary-light: #ffe7d4;
  --primary-soft: #fff6ef;
  --primary-grad: linear-gradient(72deg, #ff8a3d 0%, #ff6a00 100%);
  --bg: #f6f6f9;
  --panel: #ffffff;
  --border: #e7e7eb;
  --text: #2f2b3d;
  --muted: #8c8a99;
  --muted-2: #b5b3be;
  --green: #28c76f;
  --amber: #ff9f43;
  --red: #ea5455;
  --info: #00bad1;
  --radius: 10px;
  --shadow: 0 4px 18px rgba(47, 43, 61, .08);
  --shadow-sm: 0 2px 8px rgba(47, 43, 61, .06);
  --sidebar-w: 260px;
}
body {
  font-family: "Public Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; color: inherit; }

/* Scrollbars — discretas e arredondadas */
* { scrollbar-width: thin; scrollbar-color: rgba(140, 138, 153, .45) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background-color: rgba(140, 138, 153, .4); border-radius: 10px;
  border: 3px solid transparent; background-clip: padding-box; transition: background-color .15s; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(140, 138, 153, .7); }
::-webkit-scrollbar-corner { background: transparent; }
:root[data-theme="dark"] * { scrollbar-color: rgba(180, 180, 210, .35) transparent; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background-color: rgba(180, 180, 210, .28); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background-color: rgba(180, 180, 210, .5); }
svg { display: block; }
a { color: var(--primary); }

/* ===== Login ===== */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; position: relative; overflow: hidden;
  background:
    radial-gradient(600px 320px at 18% 12%, rgba(255,138,61,.18), transparent 60%),
    radial-gradient(680px 360px at 86% 88%, rgba(255,106,0,.14), transparent 60%),
    var(--bg); }
.login-card { position: relative; z-index: 1; width: 400px; max-width: 100%; background: var(--panel);
  border: 1px solid var(--border); border-radius: 18px; padding: 36px 34px;
  box-shadow: 0 20px 60px rgba(47,43,61,.14); }
.login-head { text-align: center; margin-bottom: 26px; }
.login-logo { width: 56px; height: 56px; object-fit: contain; margin: 0 auto 14px; display: block; }
.login-head h1 { font-size: 21px; font-weight: 700; }
.login-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input { width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
  background: var(--bg); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: var(--panel); }
.pwd-wrap { position: relative; display: flex; }
.pwd-wrap input { padding-right: 44px; }
.pwd-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; border: none; background: none; color: var(--muted-2); border-radius: 8px; }
.pwd-toggle:hover { color: var(--text); background: var(--bg); }
.pwd-toggle svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; }
.pwd-toggle .eye-off { display: none; }
.pwd-toggle.on .eye-on { display: none; }
.pwd-toggle.on .eye-off { display: block; }

.btn-login { width: 100%; padding: 13px; margin-top: 4px; background: var(--primary-grad); color: #fff; border: none;
  border-radius: 10px; font-weight: 600; font-size: 15px; box-shadow: 0 8px 20px rgba(255,106,0,.32); transition: filter .15s, box-shadow .15s; }
.btn-login:hover { filter: brightness(.97); box-shadow: 0 10px 26px rgba(255,106,0,.42); }
.err { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

.login-sep { display: flex; align-items: center; gap: 12px; color: var(--muted-2); font-size: 12px; margin: 20px 0; text-transform: uppercase; letter-spacing: .08em; }
.login-sep::before, .login-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.sso-btn-outline { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; font-weight: 600; font-size: 15px;
  text-decoration: none; transition: border-color .15s, box-shadow .15s, background .15s; }
.sso-btn-outline:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.sso-logo { width: 20px; height: 20px; object-fit: contain; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; padding: 16px; gap: 16px; }
.sidebar { width: var(--sidebar-w); background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; padding: 18px 14px; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 700; padding: 4px 8px 18px; }
.brand-logo { width: 31px; height: 31px; object-fit: contain; }

.compose-btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 12px; background: var(--primary-grad); color: #fff; border: none; border-radius: 8px; font-weight: 600;
  box-shadow: 0 6px 16px rgba(255,106,0,.35); margin-bottom: 18px; transition: filter .15s, box-shadow .15s; }
.compose-btn:hover { filter: brightness(.96); box-shadow: 0 8px 20px rgba(255,106,0,.45); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 6px; }
.nav-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 10px 12px;
  border: none; background: none; border-radius: 8px; color: var(--text); font-size: 15px; transition: background .12s, color .12s; }
.nav-btn svg { width: 20px; height: 20px; stroke: var(--muted); flex-shrink: 0; }
.nav-btn:hover { background: var(--bg); }
.nav-btn.active { background: var(--primary-grad); color: #fff; box-shadow: 0 5px 14px rgba(255,106,0,.4); }
.nav-btn.active svg { stroke: #fff; }
.nav-btn .label { flex: 1; }
.nav-btn .badge-count { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; background: var(--primary-light); color: var(--primary); }
.nav-btn.active .badge-count { background: rgba(255,255,255,.25); color: #fff; }

.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); padding: 16px 12px 6px; font-weight: 600; }
.legend { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.legend-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; font-size: 14px; color: var(--muted); }
.legend-item .ld { width: 10px; height: 10px; border-radius: 50%; }

.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.health { font-size: 12px; color: var(--muted); padding: 6px 8px; }
.current-user { font-size: 12px; color: var(--muted); padding: 2px 8px 10px; word-break: break-all; }
.logout { width: 100%; padding: 9px; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-weight: 500; }
.logout:hover { background: var(--bg); color: var(--text); }

.app-dl-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px;
  text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .12s, color .12s; }
.app-dl-btn:hover { background: var(--bg); color: var(--text); }
.app-dl-btn svg { flex-shrink: 0; }
.app-dl-btn .dl-label { flex: 1; }
.app-dl-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px;
  background: var(--primary); color: #fff; white-space: nowrap; }

.nav-divider { height: 1px; background: var(--border); margin: 6px 10px; flex-shrink: 0; }
:root[data-theme="dark"] .nav-divider { background: rgba(255,255,255,.1); }

.content { flex: 1; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; display: flex; flex-direction: column; }
.view { flex: 1; overflow-y: auto; }
.view-pad { padding: 24px 28px; }

/* ===== Header (topbar) ===== */
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.topbar .search { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 460px; background: var(--bg); border-radius: 8px; padding: 9px 14px; }
.topbar .search svg { width: 18px; height: 18px; stroke: var(--muted); flex-shrink: 0; }
.topbar .search input { flex: 1; border: none; outline: none; background: none; font-size: 14px; color: var(--text); }
.topbar .search input::placeholder { color: var(--muted-2); }
.notif { position: relative; }
.notif-dot { position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid var(--panel); }
/* user-chip — só avatar, sem nome nem chevron */
.user-chip { display: flex; align-items: center; padding: 3px; background: none; border: none; cursor: pointer; border-radius: 50%; }
.user-chip:hover { background: var(--bg); }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.logout-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); background: none; border-radius: 8px; color: var(--muted); }
.logout-btn:hover { background: var(--bg); color: var(--red); border-color: var(--red); }

.btn-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 8px; font-weight: 500; }
.btn-ghost:hover { background: var(--bg); }
.btn-ghost.danger:hover { color: var(--red); border-color: var(--red); }
.detail-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* Popovers do header */
.hdr-pop { position: relative; }
.popover { position: absolute; right: 0; top: calc(100% + 10px); width: 330px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 40; overflow: hidden; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.pop-count { font-size: 11px; font-weight: 600; background: #ef6910; color: #ffffff; padding: 2px 9px; border-radius: 10px; }
.pop-list { max-height: 360px; overflow-y: auto; }
.pop-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 14px; }
.notif-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 16px; border: none; background: none; border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-soft); }
.ni-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ni-name { font-weight: 600; font-size: 14px; }
.ni-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ni-time { font-size: 11px; color: var(--muted-2); white-space: nowrap; }
.ni-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }
.pop-foot { width: 100%; padding: 12px; border: none; border-top: 1px solid var(--border); background: none; color: var(--primary); font-weight: 600; cursor: pointer; }
.pop-foot:hover { background: var(--bg); }

/* ===== User Menu estilo Google ===== */
.popover.um { width: 290px; overflow: visible; }
.um-email-hdr { padding: 12px 16px 10px; font-size: 13px; font-weight: 500; color: var(--muted); text-align: center; border-bottom: 1px solid var(--border); word-break: break-all; }
.um-profile { display: flex; flex-direction: column; align-items: center; padding: 20px 16px 16px; gap: 10px; border-bottom: 1px solid var(--border); }
.um-av-wrap { position: relative; display: inline-block; }
.um-av-lg { width: 64px !important; height: 64px !important; font-size: 24px !important; }
.um-av-edit { position: absolute; bottom: 0; right: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: var(--shadow-sm); color: var(--muted); }
.um-av-edit:hover { background: var(--bg); color: var(--text); }
.um-greeting { font-size: 15px; font-weight: 600; color: var(--text); }
.um-manage-btn { display: inline-block; padding: 7px 14px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; transition: background .12s; }
.um-manage-btn:hover { background: var(--bg); }
.um-name-row { display: flex; align-items: center; gap: 5px; }
.um-name-edit-btn { border: none; background: none; color: var(--muted-2); cursor: pointer; border-radius: 6px; padding: 4px; display: flex; align-items: center; transition: color .12s, background .12s; flex-shrink: 0; }
.um-name-edit-btn:hover { color: var(--primary); background: var(--primary-light); }
.um-name-input { width: 100%; text-align: center; border: 1px solid var(--primary); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 14px; font-weight: 600; background: var(--bg); color: var(--text); outline: none; box-shadow: 0 0 0 3px var(--primary-light); }

.um-storage { padding: 10px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); min-height: 0; }
.um-storage:empty { display: none; }
.um-storage-bar-wrap { margin-bottom: 6px; }
.um-storage-bar { height: 4px; background: var(--border); border-radius: 3px; overflow: hidden; }
.um-storage-bar span { display: block; height: 100%; background: var(--primary); border-radius: 3px; }
.um-storage-text { font-size: 12px; color: var(--muted); }
.um-storage-loading { color: var(--muted-2); font-style: italic; font-size: 12px; }
.um-sep { height: 1px; background: var(--border); margin: 0; }
.um-signout { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 16px; border: none;
  background: none; font-size: 14px; font-weight: 500; color: var(--red); cursor: pointer; }
.um-signout:hover { background: var(--bg); }
.um-footer { display: flex; gap: 6px; justify-content: center; padding: 10px 16px; font-size: 11px;
  color: var(--muted); border-top: 1px solid var(--border); flex-wrap: wrap; }
.um-footer a { color: var(--muted); text-decoration: none; }
.um-footer a:hover { text-decoration: underline; color: var(--text); }

/* ===== Apps panel ===== */
.apps-panel { width: 320px; padding: 16px 10px 10px; }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.app-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px 10px;
  border: none; background: none; border-radius: 10px; cursor: pointer; transition: background .12s; }
.app-tile:hover { background: var(--bg); }
.app-tile-active { cursor: default; }
.app-tile-active:hover { background: none; }
.app-tile-icon { width: 40px; height: 40px; border-radius: 5px; color: #ef6910;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.75); box-shadow: 0 2px 8px rgba(239,105,16,.12); }
:root[data-theme="dark"] .app-tile-icon { background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.13); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.app-tile-name { font-size: 12px; color: var(--text); font-weight: 500; text-align: center; }

/* ===== Modal de foto de perfil ===== */
.photo-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.photo-modal-bd { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.photo-modal-box { position: relative; z-index: 1; background: var(--panel); border-radius: 16px;
  width: 340px; box-shadow: 0 24px 64px rgba(0,0,0,.2); overflow: hidden; }
.photo-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; }
.photo-modal-close { border: none; background: none; cursor: pointer; color: var(--muted); border-radius: 8px; padding: 4px; display: flex; }
.photo-modal-close:hover { color: var(--text); background: var(--bg); }
.photo-modal-preview { display: flex; justify-content: center; padding: 24px; }
.pm-av { width: 96px !important; height: 96px !important; font-size: 36px !important; }
.photo-modal-opts { display: flex; flex-direction: column; border-top: 1px solid var(--border); }
.photo-modal-opt { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border: none; background: none;
  color: var(--text); font-size: 14px; cursor: pointer; text-align: left; }
.photo-modal-opt:hover { background: var(--bg); }
.photo-modal-opt.photo-rm { color: var(--red); }

/* ===== Toolbar / busca ===== */
.searchbar { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.searchbar svg { width: 18px; height: 18px; stroke: var(--muted); }
.searchbar input { flex: 1; border: none; outline: none; font-size: 15px; background: none; color: var(--text); }
.searchbar input::placeholder { color: var(--muted-2); }
.list-toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-bottom: 1px solid var(--border); color: var(--muted); flex-wrap: wrap; }
.list-toolbar .tb-title { font-weight: 600; color: var(--text); font-size: 16px; }
/* Controle de seleção (master checkbox + dropdown) */
.sel-ctrl { position: relative; display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.master-chk { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; flex-shrink: 0; cursor: pointer;
  border: 2px solid var(--border); border-radius: 4px; background: transparent; position: relative;
  transition: border-color .15s, background .15s; }
.master-chk:hover { border-color: var(--primary); }
.master-chk:checked { background: var(--primary); border-color: var(--primary); }
.master-chk:checked::after { content: ''; position: absolute; left: 3px; top: 0px;
  width: 6px; height: 10px; border: 2px solid #fff; border-top: none; border-left: none; transform: rotate(45deg); }
.master-chk:indeterminate { background: var(--primary); border-color: var(--primary); }
.master-chk:indeterminate::after { content: ''; position: absolute; left: 2px; top: 5px; width: 9px; height: 2px; background: #fff; }
.sel-chevron { border: none; background: none; cursor: pointer; color: var(--muted); padding: 2px 3px; border-radius: 4px; display: flex; align-items: center; }
.sel-chevron:hover { background: var(--bg); color: var(--text); }
.sel-menu { position: absolute; top: calc(100% + 6px); left: 0; background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); z-index: 50; min-width: 160px; padding: 4px; }
.sel-menu button { display: block; width: 100%; text-align: left; padding: 7px 12px; border: none; background: none;
  border-radius: 5px; font-size: 13px; color: var(--text); cursor: pointer; }
.sel-menu button:hover { background: var(--bg); }
.sel-hr { border: none; border-top: 1px solid var(--border); margin: 3px 0; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: none; background: none; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.spacer { flex: 1; }

/* ===== Lista de mensagens ===== */
.message-list { display: flex; flex-direction: column; }
.mail-row { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: box-shadow .15s, transform .15s, background .12s; }
.mail-row:hover { box-shadow: 0 5px 16px rgba(47,43,61,.1); transform: translateY(-2px); z-index: 1; background: var(--panel); }
.mail-row.unread { background: #fff8f2; }
.mail-row.unread .mail-name, .mail-row.unread .mail-sub { font-weight: 700; color: var(--text); }
.mail-check {
  appearance: none; -webkit-appearance: none;
  width: 17px; height: 17px; flex-shrink: 0; cursor: pointer;
  border: 2px solid var(--border); border-radius: 5px;
  background: transparent; position: relative; transition: border-color .15s, background .15s, box-shadow .15s;
}
.mail-check:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.mail-check:checked { background: var(--primary); border-color: var(--primary); }
.mail-check:checked::after {
  content: ''; position: absolute; left: 3px; top: 0px;
  width: 6px; height: 10px; border: 2px solid #fff; border-top: none; border-left: none;
  transform: rotate(45deg);
}
.mail-star { border: none; background: none; color: var(--muted-2); font-size: 17px; line-height: 1; }
.mail-star.on { color: var(--amber); }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px; }
.mail-main { flex: 1; min-width: 0; }
.mail-name { font-size: 15px; color: var(--text); font-weight: 600; }
.mail-sub { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.mail-right svg { width: 16px; height: 16px; stroke: var(--muted-2); }
.mail-time { font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.mb-pill { display: inline-flex; align-items: center; font-size: 10px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 1px 6px; margin-left: 6px; font-weight: 400; vertical-align: middle; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.sdot { width: 9px; height: 9px; border-radius: 50%; }
.empty-state, .loading-state { padding: 48px; text-align: center; color: var(--muted); }

/* status dots/badges */
.dot-sent { background: var(--info); } .dot-delivered { background: var(--primary); }
.dot-opened { background: var(--green); } .dot-queued { background: var(--amber); }
.dot-failed, .dot-bounced { background: var(--red); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge.queued { background: #fff1e0; color: #cc7a16; }
.badge.sent { background: #e0f7fa; color: #008a9b; }
.badge.delivered { background: var(--primary-light); color: var(--primary); }
.badge.opened { background: #ddf6e8; color: #1f9d57; }
.badge.failed, .badge.bounced { background: #fde3e3; color: #d12f30; }

/* ===== Detalhe ===== */
.detail-head { display: flex; align-items: center; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.detail-head .back { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; color: var(--muted); font-weight: 500; }
.detail-head .back:hover { color: var(--text); }
.detail-head h2 { font-size: 17px; font-weight: 600; }
.message-detail { padding: 24px 28px; }
.detail-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px 24px; }
.detail-from { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.detail-from .who { flex: 1; }
.detail-from .who .n { font-weight: 600; }
.detail-from .who .e { color: var(--muted); font-size: 13px; word-break: break-all; min-width: 0; }
.detail-from .when { color: var(--muted-2); font-size: 13px; white-space: nowrap; }
.detail-meta { color: var(--muted); font-size: 13px; margin-bottom: 4px; word-break: break-word; overflow-wrap: anywhere; }
.detail-body { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); line-height: 1.7; word-break: break-word; }
.detail-body img { max-width: 100%; height: auto; }
.email-iframe { width: 100%; border: none; display: block; }
/* Attachment grid */
.att-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.att-card { width: 130px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: border-color .15s, box-shadow .15s; display: flex; flex-direction: column; }
.att-card:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(255,106,0,.15); }
.att-card-preview { width: 100%; height: 88px; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; background: var(--panel); flex-shrink: 0; }
.att-card-preview img { width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.att-card-preview img[src=""] { opacity: 0; }
.att-type-icon { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.att-type-icon svg { width: 28px; height: 28px; }
.att-img-icon { background: #ddf6e8; color: #1f9d57; }
.att-vid-icon { background: #e0f0ff; color: #1a6fb5; }
.att-aud-icon { background: #f3e6ff; color: #8a40c5; }
.att-pdf-icon { background: #fde3e3; color: #d12f30; font-size: 13px; }
.att-doc-icon { background: #e0f0ff; color: #1a6fb5; font-size: 12px; }
.att-file-icon { background: var(--border); color: var(--muted); }
.att-card-info { padding: 7px 8px; display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); }
.att-card-name { flex: 1; font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.att-card-dl { border: none; background: none; color: var(--muted); display: flex; align-items: center; padding: 2px; flex-shrink: 0; border-radius: 4px; }
.att-card-dl:hover { color: var(--primary); background: var(--primary-light); }
.att-card-dl svg { width: 13px; height: 13px; stroke: currentColor; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.lightbox.hidden { display: none; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.88); cursor: pointer; }
.lb-shell { position: relative; max-width: 92vw; max-height: 92vh; display: flex; flex-direction: column; align-items: center; }
.lb-close { position: absolute; top: -46px; right: 0; background: rgba(255,255,255,.12); border: none; border-radius: 8px; color: #fff; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; }
.lb-close:hover { background: rgba(255,255,255,.25); }
.lb-content { max-width: 88vw; max-height: 80vh; display: flex; align-items: center; justify-content: center; overflow: auto; }
.lb-content img { max-width: 88vw; max-height: 80vh; object-fit: contain; border-radius: 6px; display: block; }
.lb-content video { max-width: 88vw; max-height: 80vh; border-radius: 6px; }
.lb-content audio { width: 360px; }
.lb-content iframe { width: 80vw; height: 80vh; border: none; border-radius: 6px; background: #fff; }
.lb-loading { color: #fff; padding: 60px 40px; font-size: 15px; }
.lb-error { color: var(--red); padding: 40px; }
.lb-bar { display: flex; align-items: center; gap: 14px; margin-top: 12px; background: rgba(0,0,0,.5); border-radius: 10px; padding: 8px 14px; width: max-content; max-width: 88vw; }
.lb-name { color: rgba(255,255,255,.8); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.lb-dl { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; }
.lb-dl:hover { background: rgba(255,255,255,.2); }
.detail-actions { margin-top: 20px; }
.btn-primary { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; background: var(--primary-grad); color: #fff; border: none; border-radius: 8px; font-weight: 600; box-shadow: 0 5px 14px rgba(255,106,0,.35); transition: filter .15s; }
.btn-primary:hover { filter: brightness(.96); }

/* timeline */
.timeline { margin-top: 16px; padding: 14px 18px; background: var(--bg); border-radius: var(--radius); }
.timeline b { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.timeline ul { list-style: none; margin: 8px 0 0; }
.timeline li { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .tl-date { color: var(--muted); }

/* ===== Compor (card estilo modal) ===== */
.compose-wrap { padding: 24px 28px; }
.compose-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); max-width: 820px; margin: 0 auto; overflow: hidden; }
.compose-card .ch { background: var(--bg); padding: 14px 20px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; }
.compose-form { display: flex; flex-direction: column; }
.field-row { display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--border); }
.field-row label { color: var(--muted); font-size: 14px; width: 56px; flex-shrink: 0; }
.field-row input { flex: 1; border: none; outline: none; padding: 12px 0; font-size: 15px; background: none; color: var(--text); }
.field-row input::placeholder { color: var(--muted-2); font-size: 13px; }

/* Label com nome + subtítulo explicativo */
label.fr-label { display: flex; flex-direction: column; gap: 2px; width: 82px; color: inherit; font-size: inherit; flex-shrink: 0; }
label.fr-label b { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; }
label.fr-label small { font-size: 10px; color: var(--muted-2); font-weight: 400; line-height: 1.2; }

/* Custom dropdown (seletor De:) */
.compose-dropdown { position: relative; flex: 1; min-width: 0; }
.cd-trigger { display: flex; align-items: center; gap: 8px; padding: 12px 4px 12px 0; cursor: pointer; user-select: none; }
.cd-trigger > span { flex: 1; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-chevron { stroke: var(--muted); flex-shrink: 0; transition: transform .2s; }
.compose-dropdown.open .cd-chevron { transform: rotate(180deg); }
.cd-list { position: absolute; top: calc(100% + 2px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 30; overflow: hidden; }
.cd-option { padding: 10px 16px; font-size: 14px; color: var(--text); cursor: pointer; transition: background .1s; }
.cd-option:hover { background: var(--bg); }
.cd-option.selected { color: var(--primary); font-weight: 600; }

/* Tag input (Para / Cc / Bcc) */
.tag-field { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; flex: 1; padding: 6px 0; min-height: 44px; cursor: text; min-width: 0; }
.email-tag { display: inline-flex; align-items: center; gap: 3px; background: var(--primary-light); color: var(--primary); border-radius: 20px; padding: 3px 6px 3px 10px; font-size: 12px; font-weight: 500; max-width: 220px; flex-shrink: 0; }
.email-tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-tag > button { border: none; background: none; color: var(--primary); opacity: .65; font-size: 15px; line-height: 1; padding: 0 2px; display: flex; align-items: center; cursor: pointer; }
.email-tag > button:hover { opacity: 1; }
:root[data-theme="dark"] .email-tag { background: rgba(255, 106, 0, .2); }
.tag-input { border: none; outline: none; background: none; font: inherit; font-size: 15px; color: var(--text); min-width: 100px; flex: 1; padding: 0; }
.tag-input::placeholder { color: var(--muted-2); font-size: 13px; }

.editor-toolbar { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; padding: 7px 14px; border-bottom: 1px solid var(--border); background: var(--bg); }
.editor-toolbar button { min-width: 32px; height: 32px; border: 1px solid transparent; background: none; color: var(--text); border-radius: 6px; font-size: 14px; font-weight: 700; line-height: 1; display: inline-flex; align-items: center; justify-content: center; transition: background .12s, color .12s, border-color .12s; }
.editor-toolbar button:hover { background: var(--panel); border-color: var(--border); }
.editor-toolbar button.active { background: var(--primary-light); color: var(--primary); border-color: transparent; }
.editor-toolbar .tb-toggle.active { background: var(--primary); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .editor-toolbar button.active { background: rgba(255,106,0,.22); color: var(--primary); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor { min-height: 240px; padding: 16px 20px; font: inherit; line-height: 1.7; overflow-y: auto; outline: none; }
.editor:empty::before { content: 'Escreva sua mensagem…'; color: var(--muted-2); }
.editor h2 { font-size: 18px; margin: 8px 0; }
.editor-html { min-height: 240px; padding: 16px 20px; border: none; outline: none; font-family: ui-monospace, Consolas, monospace; font-size: 13px; resize: vertical; }
.compose-foot { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); }
.compose-foot .send { display: inline-flex; align-items: center; gap: 7px; padding: 10px 20px; background: var(--primary-grad); color: #fff; border: none; border-radius: 8px; font-weight: 600; font-size: 14px; box-shadow: 0 5px 14px rgba(255,106,0,.4); transition: filter .15s, box-shadow .15s; }
.compose-foot .send:hover { filter: brightness(.96); box-shadow: 0 7px 18px rgba(255,106,0,.5); }
.compose-foot .send:disabled { opacity: .6; }
.attach-btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; transition: border-color .15s, color .15s; }
.attach-btn:hover { border-color: var(--primary); color: var(--primary); }
.draft-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--border); background: none; border-radius: 8px; color: var(--muted); transition: border-color .15s, color .15s, background .15s; flex-shrink: 0; }
.draft-icon-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.compose-status { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Área de anexos */
.file-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 20px; }
.file-chips.has-files { padding: 10px 20px; border-top: 1px solid var(--border); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 5px 6px 5px 8px; max-width: 260px; }
.file-chip-icon { width: 30px; height: 30px; border-radius: 6px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 9px; font-weight: 700; letter-spacing: -.3px; }
.file-chip-info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.file-chip-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; color: var(--text); }
.file-chip-size { font-size: 10px; color: var(--muted); }
.file-chip-rm { border: none; background: none; color: var(--muted-2); flex-shrink: 0; border-radius: 4px; padding: 3px; display: flex; align-items: center; justify-content: center; transition: color .12s, background .12s; }
.file-chip-rm:hover { color: var(--red); background: rgba(234,84,85,.1); }

/* ===== Formulários de gestão (Contas/Usuários/API) ===== */
.section-title { font-size: 20px; font-weight: 600; margin-bottom: 18px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.inline-form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--bg); color: var(--text); }
.inline-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.inline-form button { padding: 10px 18px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-weight: 600; }
.inline-form button:hover { background: var(--primary-d); }

/* ── Input com sufixo de domínio ── */
.input-suffix-wrap { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); transition: border-color .15s, box-shadow .15s; overflow: hidden; }
.input-suffix-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.input-suffix-wrap input { border: none !important; box-shadow: none !important; outline: none !important; background: transparent; padding: 10px 2px 10px 12px; min-width: 80px; color: var(--text); font: inherit; }
.input-suffix { display: flex; align-items: center; padding: 0 12px 0 2px; color: var(--muted); font-size: 13px; white-space: nowrap; user-select: none; }

/* ── Select customizado ── */
.custom-select { position: relative; display: inline-flex; align-items: center; }
.custom-select select { appearance: none; -webkit-appearance: none; padding: 10px 34px 10px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); cursor: pointer; line-height: 1.4; transition: border-color .15s, box-shadow .15s; }
.custom-select select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.custom-select::after { content: ''; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; width: 16px; height: 16px; background-color: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/16px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") center/16px no-repeat; }

/* Select dentro de field-row (compose De:) */
.field-row .custom-select { flex: 1; }
.field-row .custom-select select { width: 100%; border: none; border-radius: 0; box-shadow: none !important; padding: 13px 28px 13px 0; font-size: 15px; background: none; }
.field-row .custom-select::after { right: 4px; }
.hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.hint code { background: var(--bg); padding: 1px 6px; border-radius: 5px; }

.mailbox-list { display: flex; flex-direction: column; gap: 10px; }
.mailbox-item { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; }
.mailbox-item .addr { font-weight: 600; }
.mailbox-item .name { color: var(--muted); font-size: 13px; }
.mailbox-item.inactive { opacity: .55; }
.mailbox-item button { padding: 7px 14px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; }
.mailbox-item button:hover { border-color: var(--primary); color: var(--primary); }
.tag { font-size: 10px; background: var(--bg); color: var(--muted); padding: 1px 6px; border-radius: 4px; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.u-status { font-size: 12px; }
.u-status-ok      { color: #22c55e; }
.u-status-pending { color: #f59e0b; }
.u-status-warn    { color: #f97316; }

/* API */
.app-list { display: flex; flex-direction: column; gap: 16px; }
.app-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px 20px; }
.app-card.inactive { opacity: .6; }
.app-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.app-name { font-weight: 600; font-size: 16px; }
.app-head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.app-head button { padding: 6px 12px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; }
.app-head button:hover { border-color: var(--primary); color: var(--primary); }
.app-section { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.app-section > b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 8px; }
.key-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13px; flex-wrap: wrap; }
.key-row code { background: var(--bg); padding: 2px 8px; border-radius: 6px; }
.key-row.revoked { opacity: .5; }
.key-meta { color: var(--muted); flex: 1; }
.key-row button, .add-sender button, .gen-key { padding: 5px 12px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; }
.gen-key { margin-top: 8px; color: var(--primary); border-color: var(--primary); }
.senders { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sender-chip { background: var(--bg); border-radius: 16px; padding: 4px 8px 4px 12px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.sender-chip button { border: none; background: none; color: var(--muted); font-size: 16px; line-height: 1; }
.add-sender { display: flex; gap: 8px; }
.add-sender .custom-select { flex: 1; }
.add-sender .custom-select select { width: 100%; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* ===== Armazenamento ===== */
.st-cards { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 14px; }
.st-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.st-k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.st-v { font-size: 24px; font-weight: 700; margin-top: 4px; }
.st-sub { font-size: 12px; color: var(--muted); }
.st-empty { margin-top: 8px; padding: 5px 12px; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 8px; font-size: 13px; }
.st-empty:hover { border-color: var(--red); color: var(--red); }
.st-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--bg); margin: 12px 0 8px; }
.st-bar span { display: block; height: 100%; }
.st-att { background: var(--primary); }
.st-body { background: var(--info); }
.st-sig { background: var(--amber); }
.st-leg { display: flex; gap: 16px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.st-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: middle; }
.st-h { font-size: 15px; font-weight: 600; margin: 24px 0 10px; }
.st-row { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.st-row-main { flex: 1; min-width: 0; }
.st-mini { height: 6px; border-radius: 4px; background: var(--bg); margin-top: 6px; overflow: hidden; }
.st-mini span { display: block; height: 100%; background: var(--primary-grad); border-radius: 4px; }
.st-mini.over span { background: var(--red); }
.st-row-meta { font-size: 13px; color: var(--muted); white-space: nowrap; }
.st-row-meta.st-over { color: var(--red); font-weight: 600; }
@media (max-width: 820px) { .st-cards { grid-template-columns: 1fr 1fr; } }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(47,43,61,.5); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: var(--panel); border-radius: 14px; padding: 28px; width: 480px; max-width: 92vw; box-shadow: 0 16px 50px rgba(0,0,0,.25); }
.modal-box h3 { margin-bottom: 8px; }
.modal-box p { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.key-value { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; word-break: break-all; font-size: 13px; margin-bottom: 10px; }
.key-sync { font-size: 13px; min-height: 16px; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button { padding: 9px 18px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); }
#keyCopy { background: var(--primary); color: #fff; border: none; }

/* ===== Dark mode ===== */
:root[data-theme="dark"] {
  --bg: #232333;
  --panel: #2b2c40;
  --border: #3b3c54;
  --text: #d6d6e5;
  --muted: #9a9bb5;
  --muted-2: #6e7090;
  --primary-light: #4a3322;
  --primary-soft: #33291f;
  --shadow: 0 4px 18px rgba(0, 0, 0, .35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .3);
  color-scheme: dark;
}
:root[data-theme="dark"] body { background: #1c1c29; }
:root[data-theme="dark"] .mail-row.unread { background: #30314a; }
:root[data-theme="dark"] .mail-row:hover { box-shadow: 0 5px 16px rgba(0, 0, 0, .4); }
:root[data-theme="dark"] .login { background:
  radial-gradient(600px 320px at 18% 12%, rgba(255,138,61,.16), transparent 60%),
  radial-gradient(680px 360px at 86% 88%, rgba(255,106,0,.12), transparent 60%),
  #1c1c29; }
:root[data-theme="dark"] .login-card { box-shadow: 0 20px 60px rgba(0,0,0,.45); }
:root[data-theme="dark"] .field input { background: #21222f; }
:root[data-theme="dark"] .field input:focus { background: #262738; }
/* Prevent OS-forced white on compose/search inputs in dark mode */
:root[data-theme="dark"] .field-row input,
:root[data-theme="dark"] .tag-input,
:root[data-theme="dark"] .topbar .search input,
:root[data-theme="dark"] .inline-form input,
:root[data-theme="dark"] .inline-form textarea,
:root[data-theme="dark"] textarea:not(.editor-html) {
  background-color: transparent;
  color: var(--text);
}
:root[data-theme="dark"] .tag-field { background: transparent; }
:root[data-theme="dark"] .editor-html { background: #21222f; color: var(--text); }
:root[data-theme="dark"] .badge.queued { background: #4a3a1c; color: #ffc987; }
:root[data-theme="dark"] .badge.sent { background: #16414a; color: #6fe0ef; }
:root[data-theme="dark"] .badge.delivered { background: #4a3322; color: #ffb27a; }
:root[data-theme="dark"] .badge.opened { background: #1c4a30; color: #74e6a3; }
:root[data-theme="dark"] .badge.failed, :root[data-theme="dark"] .badge.bounced { background: #4a2222; color: #ff9d9d; }

/* ===== Marcadores (labels) ===== */
.nav-section-head { display: flex; align-items: center; padding: 14px 12px 4px; gap: 6px; }
.nav-section-head .nav-title { flex: 1; padding: 0; margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-2); font-weight: 600; }
.nav-add-btn { display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border: none; background: none; color: var(--muted); border-radius: 6px; padding: 0; }
.nav-add-btn:hover { background: var(--bg); color: var(--primary); }
.nav-add-btn svg { width: 14px; height: 14px; stroke: currentColor; flex-shrink: 0; }
.nav-btn-sm { font-size: 13px; padding: 7px 12px; color: var(--muted); }
.nav-btn-sm svg { stroke: var(--muted-2); width: 17px; height: 17px; }
.nav-btn-sm:hover { color: var(--text); }
.nav-btn-sm:hover svg { stroke: var(--text); }
.nav-btn-sm.active { color: #fff; }
.nav-btn-sm.active svg { stroke: #fff; }

.lbl-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* Label chips on message rows */
.msg-labels { display: inline-flex; gap: 3px; margin-left: 5px; vertical-align: middle; }
.msg-lbl-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; vertical-align: middle; flex-shrink: 0; }

/* Label chips in message detail */
.detail-labels { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; align-items: center; }
.detail-lbl { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.detail-lbl-dot { width: 8px; height: 8px; border-radius: 50%; }
.detail-lbl-rm { border: none; background: none; color: inherit; opacity: .55; font-size: 14px; cursor: pointer; padding: 0; margin-left: 1px; line-height: 1; }
.detail-lbl-rm:hover { opacity: 1; }
.detail-lbl-add { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 12px; border: 1px dashed var(--border); background: none; color: var(--muted); cursor: pointer; }
.detail-lbl-add:hover { border-color: var(--primary); color: var(--primary); }

/* Labels quick-picker dropdown */
.lbl-picker { position: relative; }
.lbl-picker-list { position: absolute; top: calc(100% + 4px); left: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 40; min-width: 160px; overflow: hidden; }
.lbl-picker-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer; color: var(--text); }
.lbl-picker-item:hover { background: var(--bg); }
.lbl-picker-item.applied { font-weight: 600; color: var(--primary); }

/* Labels management panel */
.lbl-mgr-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 10px; background: var(--panel); transition: box-shadow .12s;
}
.lbl-mgr-item:hover { box-shadow: var(--shadow-sm); }
.lbl-mgr-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.lbl-mgr-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.lbl-mgr-name { font-weight: 600; font-size: 14px; }
.lbl-mgr-rules { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lbl-mgr-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.lbl-mgr-actions button { padding: 5px 11px; border: 1px solid var(--border); background: var(--bg); border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text); transition: background .12s, border-color .12s, color .12s; }
.lbl-mgr-actions button:hover { background: var(--panel); border-color: var(--primary); color: var(--primary); }
.lbl-mgr-actions button.danger:hover { color: var(--red); border-color: var(--red); }

.lbl-rule-list { padding: 10px 16px 4px; display: flex; flex-direction: column; gap: 6px; }
.lbl-rule-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.lbl-rule-item code { background: var(--bg); padding: 2px 7px; border-radius: 5px; font-size: 12px; color: var(--text); border: 1px solid var(--border); }
.lbl-rule-rm { border: none; background: none; color: var(--muted-2); cursor: pointer; font-size: 16px; padding: 0 3px; line-height: 1; transition: color .12s; }
.lbl-rule-rm:hover { color: var(--red); }

.lbl-rule-form { display: flex; gap: 8px; margin-top: 12px; padding: 12px 16px; background: var(--bg); border-radius: 8px; flex-wrap: wrap; align-items: center; }
.lbl-rule-form select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); outline: none; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.lbl-rule-form select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.lbl-rule-form input[type="text"] { flex: 1; min-width: 130px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
.lbl-rule-form input[type="text"]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.lbl-rule-form button { padding: 8px 14px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: filter .15s; white-space: nowrap; }
.lbl-rule-form button:hover { filter: brightness(.9); }
:root[data-theme="dark"] .lbl-rule-form { background: rgba(255,255,255,.04); }
:root[data-theme="dark"] .lbl-rule-form select,
:root[data-theme="dark"] .lbl-rule-form input[type="text"] { background: var(--panel); }

/* ===== Assinaturas ===== */
.sig-view-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.sig-item { border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; transition: box-shadow .15s; }
.sig-item:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.sig-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sig-name-input { flex: 1; font-weight: 600; font-size: 14px; background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 4px 8px; color: var(--text); transition: border-color .15s, background .15s; }
.sig-name-input:hover { border-color: var(--border); background: var(--bg); }
.sig-name-input:focus { border-color: var(--primary); background: var(--bg); outline: none; box-shadow: 0 0 0 3px var(--primary-light); }
.sig-default-badge { font-size: 11px; padding: 2px 8px; background: #ef691022; color: var(--primary); border-radius: 10px; font-weight: 600; white-space: nowrap; }
.sig-editor { min-height: 100px; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; font-size: 14px; line-height: 1.6; background: var(--bg); color: var(--text); outline: none; }
.sig-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.sig-preview { margin-top: 10px; padding: 12px 14px; background: var(--bg); border-radius: 8px; border: 1px dashed var(--border); }
.sig-preview-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.sig-preview-content { font-size: 13px; color: var(--text); }
.sig-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sig-actions button { padding: 7px 14px; border: 1px solid var(--border); background: var(--panel); border-radius: 8px; font-size: 13px; cursor: pointer; color: var(--text); }
.sig-actions button.primary { background: var(--primary); color: #fff; border-color: transparent; }
.sig-actions button:hover:not(.primary):not(.danger-ghost) { background: var(--bg); }
.sig-actions button.primary:hover { filter: brightness(.95); }
.sig-actions button.danger-ghost { color: var(--red, #ea5455); margin-left: auto; }
.sig-actions button.danger-ghost:hover { background: #ea545512; }
.mail-sig { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; color: var(--muted); font-size: 13px; }
/* Toolbar do editor de assinatura */
.sig-toolbar { display: flex; align-items: center; gap: 2px; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: 8px 8px 0 0; flex-wrap: wrap; row-gap: 3px; }
.sig-tb-btn { padding: 4px 7px; border: 1px solid transparent; border-radius: 5px; background: none; color: var(--text); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 3px; line-height: 1; transition: background .1s, border-color .1s, color .1s; }
.sig-tb-btn:hover { background: var(--panel); border-color: var(--border); }
.sig-tb-btn.active { background: #ef691018; color: var(--primary); border-color: #ef691040; }
.sig-tb-sep { width: 1px; height: 16px; background: var(--border); margin: 0 2px; flex-shrink: 0; }
.sig-toolbar + .sig-editor { border-radius: 0 0 8px 8px; }
.sig-tb-tpl { font-size: 12px; color: var(--muted); }
.sig-tb-sel {
  font-size: 12px; padding: 3px 22px 3px 7px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text); cursor: pointer; height: 26px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888888'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 8px 5px;
}
.sig-tb-sel:focus { outline: none; border-color: var(--primary); }
.sig-font-sel { max-width: 112px; }
.sig-size-sel { max-width: 66px; }
/* Dot indicador de cor ativa no botão */
.sig-color-dot { display: block; width: 14px; height: 3px; border-radius: 2px; margin-top: 1px; }
/* Color picker panel */
.sig-cpicker { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 28px rgba(0,0,0,.22); padding: 10px; width: 204px; user-select: none; }
.sig-cpicker-grid { display: grid; grid-template-columns: repeat(8,1fr); gap: 3px; margin-bottom: 10px; }
.sig-cpicker-swatch { width: 20px; height: 20px; border-radius: 4px; border: 1px solid rgba(0,0,0,.12); cursor: pointer; padding: 0; transition: transform .1s, box-shadow .1s; }
.sig-cpicker-swatch:hover { transform: scale(1.25); box-shadow: 0 2px 6px rgba(0,0,0,.3); z-index: 1; position: relative; }
.sig-cpicker-custom { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--border); padding-top: 8px; }
.sig-cpicker-native { width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 5px; padding: 1px; cursor: pointer; background: none; flex-shrink: 0; }
.sig-cpicker-hex { flex: 1; font-family: 'Courier New',monospace; font-size: 12px; padding: 4px 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); min-width: 0; }
.sig-cpicker-hex:focus { outline: none; border-color: var(--primary); }
.sig-cpicker-ok { padding: 4px 10px; background: var(--primary); color: #fff; border: none; border-radius: 5px; font-size: 12px; cursor: pointer; flex-shrink: 0; }
.sig-cpicker-ok:hover { filter: brightness(.92); }
/* Image resize panel */
.sig-img-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.22); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text); user-select: none; white-space: nowrap; min-width: 300px; }
.sig-img-panel-row { display: flex; align-items: center; gap: 6px; }
.sig-img-panel-lbl { color: var(--muted); }
.sig-img-panel-inp { width: 54px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--bg); color: var(--text); font-size: 12px; text-align: right; }
.sig-img-panel-inp:focus { outline: none; border-color: var(--primary); }
.sig-img-panel-px { color: var(--muted); }
.sig-img-panel-presets { display: flex; gap: 3px; }
.sig-img-panel-presets button { padding: 2px 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); font-size: 11px; cursor: pointer; }
.sig-img-panel-presets button:hover { background: var(--primary); color: #fff; border-color: transparent; }
.sig-img-panel-remove { background: none; border: none; color: var(--red,#ea5455); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; margin-left: 2px; }
.sig-img-panel-remove:hover { color: #c0392b; }
/* Textarea modo HTML */
.sig-html-area { display: none; width: 100%; box-sizing: border-box; min-height: 120px; font-family: 'Courier New', Courier, monospace; font-size: 12px; line-height: 1.6; border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; padding: 12px 14px; background: var(--bg); color: var(--text); resize: vertical; outline: none; }
.sig-html-area:focus { border-color: var(--primary); }
.sig-item.html-mode .sig-editor { display: none; }
.sig-item.html-mode .sig-html-area { display: block; }
/* Galeria de modelos */
.sig-gallery-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.sig-gallery { background: var(--panel); border-radius: 14px; max-width: 820px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.sig-gallery-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.sig-gallery-title { font-weight: 700; font-size: 16px; }
.sig-gallery-close { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; padding: 0 4px; }
.sig-gallery-close:hover { color: var(--text); }
.sig-gallery-hint { margin: 0; padding: 8px 20px 0; font-size: 12px; color: var(--muted); }
.sig-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 14px 20px 20px; }
.sig-tpl-card { border: 2px solid var(--border); border-radius: 10px; overflow: hidden; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; }
.sig-tpl-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); transform: translateY(-1px); }
.sig-tpl-preview { height: 120px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 10px; overflow: hidden; }
.sig-tpl-iframe { width: 100%; height: 100%; border: none; pointer-events: none; }
.sig-tpl-name { padding: 8px 12px; font-size: 13px; font-weight: 600; border-top: 1px solid var(--border); background: var(--bg); }
/* Picker de assinatura no compose */
.sig-bar { display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); background: var(--panel); }
.sig-bar.hidden { display: none; }
.sig-select { font-size: 12px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; max-width: 220px; }

/* ===== Send toast (envio em background) ===== */
.send-toast {
  position: fixed; bottom: 24px; left: 24px; z-index: 1000;
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 8px 32px rgba(47,43,61,.22);
  padding: 13px 14px 13px 16px; min-width: 270px; max-width: 400px;
}
.send-toast.hidden { display: none; }
@keyframes toast-in  { from { transform: translateY(70px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateY(0); opacity: 1; } to { transform: translateY(70px); opacity: 0; } }
.send-toast.entering { animation: toast-in  .28s cubic-bezier(.34,1.4,.64,1) forwards; }
.send-toast.leaving  { animation: toast-out .2s ease-in forwards; }

.send-toast-icon { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.send-toast-icon.sending { background: rgba(255,106,0,.13); }
.send-toast-icon.success { background: rgba(40,199,111,.13); }
.send-toast-icon.error   { background: rgba(234,84,85,.13); }
.send-toast-spinner { width: 18px; height: 18px; border: 2px solid rgba(255,106,0,.25); border-top-color: #ff6a00; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.send-toast-body { flex: 1; min-width: 0; }
.send-toast-msg  { font-size: 13.5px; font-weight: 500; color: var(--text); line-height: 1.4; }
.send-toast-close { border: none; background: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: flex; flex-shrink: 0; }
.send-toast-close:hover { color: var(--text); background: var(--bg); }
:root[data-theme="dark"] .send-toast { box-shadow: 0 8px 32px rgba(0,0,0,.45); }

/* ===== Mobile responsivo ===== */
.mob-menu-btn { display: none; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(47,43,61,.45); z-index: 29; }
.sidebar-overlay.active { display: block; }

@media (max-width: 820px) {
  :root { --sidebar-w: 280px; }
  .app { padding: 0; gap: 0; flex-direction: column; height: auto; min-height: 100dvh; }
  .sidebar {
    position: fixed; z-index: 30; height: 100dvh; top: 0; left: 0;
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    border-radius: 0; box-shadow: 4px 0 24px rgba(47,43,61,.18);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .content { border-radius: 0; width: 100%; min-height: 100dvh; display: flex; flex-direction: column; }
  .topbar { padding: 10px 12px; gap: 8px; position: sticky; top: 0; z-index: 20; background: var(--panel); }
  .mob-menu-btn { display: inline-flex; flex-shrink: 0; }
  .search { flex: 1; min-width: 0; }
  /* Lista de mensagens */
  .mail-row { padding: 12px 14px; gap: 10px; }
  .mail-right { flex-shrink: 0; }
  /* Detalhe da mensagem */
  .message-detail { padding: 14px; overflow-x: hidden; }
  .detail-card { padding: 16px 14px; }
  .email-iframe { overflow-x: auto; }
  .detail-actions { gap: 6px; }
  .detail-actions button { padding: 7px 10px; font-size: 13px; }
  /* Compor */
  .compose-card { padding: 16px 12px; }
  /* Barra de busca — ocupa todo o espaço disponível */
  .topbar .spacer { display: none; }
  /* Popover — fixo abaixo do header, não vaza pelas bordas */
  .popover {
    position: fixed;
    left: 12px;
    right: 12px;
    width: auto;
    top: 58px;
    max-height: calc(100dvh - 80px);
    overflow-y: auto;
  }
  .popover.um { width: auto; }
  .apps-panel { width: auto; }
  /* Lista-toolbar */
  .list-toolbar { padding: 10px 14px; gap: 8px; }
  /* Toolbar de assinatura — wrap em mobile */
  .sig-toolbar { flex-wrap: wrap; gap: 3px; }
  /* Botão voltar mobile (aparece no detail) */
  .mob-back-btn { display: inline-flex; }
  /* Storage cards */
  .st-cards { grid-template-columns: 1fr !important; }
  /* Armazenamento — tabela com scroll horizontal */
  .mailbox-list { overflow-x: auto; }
  /* Compose toolbar */
  .compose-toolbar { flex-wrap: wrap; gap: 3px; }
}

/* Botão voltar mobile — escondido em desktop */
.mob-back-btn { display: none; background: none; border: none; cursor: pointer; color: var(--primary);
  font-size: 14px; font-weight: 600; padding: 6px 4px 6px 0; gap: 4px; align-items: center; }
.mob-back-btn svg { flex-shrink: 0; }
