/* JM Mail — estilos. Identidade JM: #202020, #0B673B, #FFFFFF; Bricolage Grotesque (títulos) e Poppins (textos). */

:root {
  --ink: #202020;
  --ink-2: #3a3f3c;
  --muted: #66706b;
  --faint: #8d9692;
  --green: #0b673b;
  --green-strong: #08532f;
  --green-soft: #e8f3ec;
  --green-line: #cfe4d7;
  --canvas: #f3f5f4;
  --surface: #ffffff;
  --line: #e2e6e4;
  --line-strong: #cdd3d0;
  --warn: #8f5b00;
  --warn-bg: #fff4dd;
  --warn-line: #f1d79f;
  --danger: #b42318;
  --danger-bg: #fdeceb;
  --danger-line: #f4c3be;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(32, 32, 32, .05), 0 4px 16px rgba(32, 32, 32, .04);
  --font-title: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --sidebar: 252px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green); }
.ti { font-size: 18px; line-height: 1; vertical-align: -3px; }

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

.h1, .h2, .h3 { font-family: var(--font-title); color: var(--ink); margin: 0; letter-spacing: -.01em; }
.h1 { font-size: 30px; font-weight: 600; line-height: 1.15; }
.h2 { font-size: 22px; font-weight: 600; line-height: 1.2; margin-bottom: 6px; }
.h3 { font-size: 17px; font-weight: 600; line-height: 1.3; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- marca ---------- */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand__mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--green); color: #fff;
  display: grid; place-items: center; flex: none;
}
.brand__mark .ti { font-size: 19px; vertical-align: 0; }
.brand__name { font-family: var(--font-title); font-weight: 700; font-size: 20px; letter-spacing: -.02em; }
.brand--large .brand__mark { width: 44px; height: 44px; border-radius: 13px; }
.brand--large .brand__mark .ti { font-size: 24px; }
.brand--large .brand__name { font-size: 26px; }

/* ---------- estrutura ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 14px 14px;
}
.sidebar .brand { padding: 0 8px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__group { margin: 18px 10px 6px; font-size: 12px; color: var(--faint); font-weight: 500; }
.nav__item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 10px; border-radius: var(--radius-sm); border: 0; background: none;
  color: var(--ink-2); text-decoration: none; cursor: pointer; text-align: left; font-weight: 500;
}
.nav__item:hover { background: var(--canvas); color: var(--ink); }
.nav__item.is-active { background: var(--green-soft); color: var(--green-strong); }
.nav__item.is-active .ti { color: var(--green); }
.nav__item.is-soon { color: var(--faint); cursor: default; }
.nav__item.is-soon:hover { background: none; color: var(--faint); }
.nav__soon { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--faint); }

/* sinal de vida do envio automático: o detalhe que acompanha o app inteiro */
.pulse {
  margin-top: auto; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line);
  display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; background: var(--canvas);
  text-decoration: none; color: var(--ink-2);
}
.pulse:hover { border-color: var(--line-strong); }
.pulse__dot { position: relative; width: 10px; height: 10px; margin-top: 5px; flex: none; border-radius: 50%; background: var(--faint); }
.pulse.is-ok .pulse__dot { background: var(--green); }
.pulse.is-ok .pulse__dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--green);
  opacity: 0; animation: beat 2.4s ease-out infinite;
}
.pulse.is-aviso .pulse__dot { background: #d29200; }
.pulse.is-erro .pulse__dot { background: var(--danger); }
.pulse strong { display: block; color: var(--ink); font-weight: 600; }
@keyframes beat { 0% { transform: scale(.6); opacity: .7; } 70% { transform: scale(1.6); opacity: 0; } 100% { opacity: 0; } }

.sidebar__foot { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; font-size: 12px; color: var(--faint); }
.sidebar__user { flex: 1; min-width: 0; }
.sidebar__user { text-decoration: none; color: var(--faint); }
.sidebar__user span { display: block; }
.sidebar__user strong { display: block; color: var(--ink); font-weight: 500; font-size: 13px; }
.sidebar__user:hover strong { color: var(--green); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 32px;
  border-bottom: 1px solid var(--line); background: rgba(243, 245, 244, .92);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.topbar__menu { display: none; }
.topbar__crumb { font-size: 13px; color: var(--muted); }
.topbar__actions { margin-left: auto; display: flex; gap: 8px; }
.content { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head__text { flex: 1; min-width: 260px; }
.page-head__text p { margin: 6px 0 0; color: var(--muted); max-width: 64ch; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* modo foco */
.btn.focus-exit {
  position: fixed; top: 14px; right: 16px; z-index: 40; display: none;
}
body.is-focus .shell { grid-template-columns: minmax(0, 1fr); }
body.is-focus .sidebar, body.is-focus .topbar { display: none; }
body.is-focus .btn.focus-exit { display: inline-flex; }
body.is-focus .content { margin: 0 auto; padding-top: 40px; }

/* ---------- componentes ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 16px; }
.panel__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel__head .h3 { margin: 0; flex: 1; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.span-2 { grid-column: span 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 38px; padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--canvas); }
.btn:disabled, .btn.is-busy { opacity: .6; cursor: not-allowed; }
.btn--primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-strong); border-color: var(--green-strong); }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: rgba(32, 32, 32, .05); }
.btn--danger { color: var(--danger); border-color: var(--danger-line); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn--icon { padding: 0; width: 38px; }
.btn--sm.btn--icon { width: 32px; }
.btn .spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
}
textarea.input { min-height: 90px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(11, 103, 59, .14); }
.input[readonly] { background: var(--canvas); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--green); flex: none; }
.check span { font-size: 13.5px; }
.check small { display: block; color: var(--muted); font-size: 12px; }
.form .h3:first-child, .form > .h3:first-of-type { margin-top: 0; }
.form__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fieldset { border: 0; padding: 0; margin: 0 0 6px; }
.fieldset + .fieldset { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.fieldset__title { float: left; width: 100%; padding: 0; font-family: var(--font-title); font-weight: 600; font-size: 16px; margin: 0 0 4px; }
.fieldset__title + * { clear: both; }
.fieldset__hint { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; border: 1px solid var(--line); background: var(--canvas); color: var(--ink-2);
  white-space: nowrap;
}
.chip .ti { font-size: 14px; vertical-align: -2px; }
.chip--ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-strong); }
.chip--aviso { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.chip--erro { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }

.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin: 0 0 16px; }
.callout > .ti { margin-top: 2px; }
.callout--danger { background: var(--danger-bg); border-color: var(--danger-line); color: #7d1a12; }
.callout--warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6b4500; }
.callout--ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-strong); }
.callout p { margin: 0; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.checklist__item { display: flex; gap: 12px; padding: 12px 2px; border-top: 1px solid var(--line); align-items: flex-start; }
.checklist__item:first-child { border-top: 0; }
.checklist__item > .ti { font-size: 20px; margin-top: 1px; flex: none; }
.checklist__item div { display: flex; flex-direction: column; min-width: 0; }
.checklist__item strong { font-weight: 500; }
.checklist__item span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.checklist__item.is-ok > .ti { color: var(--green); }
.checklist__item.is-aviso > .ti { color: #c28800; }
.checklist__item.is-erro > .ti { color: var(--danger); }
.checklist__item.is-pend > .ti { color: var(--faint); }
.checklist__item .btn { margin-left: auto; flex: none; }

/* passos de configuração do painel */
.steps { counter-reset: step; }
.steps .checklist__item { align-items: center; }

/* tabela */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th { text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfa; white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.cell-msg { max-width: 520px; overflow-wrap: anywhere; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: #fafbfa; }
.table .ctx { margin: 8px 0 0; padding: 10px; background: var(--canvas); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow-y: auto; }

/* remetentes */
.sender-list { display: grid; gap: 12px; }
.sender {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 18px; align-items: center;
  padding: 16px 18px; border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; text-align: left; width: 100%;
}
.sender:hover { border-color: var(--line-strong); }
.sender__name { font-family: var(--font-title); font-weight: 600; font-size: 17px; display: flex; gap: 8px; align-items: center; min-width: 0; }
.sender__mail { color: var(--muted); font-size: 13px; }
.sender__chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.kind { font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--canvas); color: var(--ink-2); border: 1px solid var(--line); }

.detail-grid > .panel { margin-top: 0; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.test-row { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-top: 1px solid var(--line); }
.test-row:first-of-type { border-top: 0; padding-top: 4px; }
.test-row > .ti { font-size: 22px; margin-top: 2px; flex: none; color: var(--faint); }
.test-row.is-ok > .ti { color: var(--green); }
.test-row.is-erro > .ti { color: var(--danger); }
.test-row__body { flex: 1; min-width: 0; }
.test-row__body strong { font-weight: 500; display: block; }
.test-row__body span { color: var(--muted); font-size: 13px; display: block; overflow-wrap: anywhere; }
.test-row__body .err { color: var(--danger); }
.test-row .btn { flex: none; }

.dns-list { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.dns-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.dns-item__top { display: flex; gap: 8px; align-items: center; }
.dns-item__top strong { font-weight: 500; }
.dns-item p { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }

.code-box { display: flex; gap: 8px; align-items: stretch; }
.code-box code { flex: 1; min-width: 0; display: block; padding: 10px 12px; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius-sm); overflow-x: auto; white-space: nowrap; font-size: 12.5px; }

/* estado vazio */
.empty { text-align: center; padding: 48px 24px; }
.empty .ti { font-size: 34px; color: var(--green); }
.empty h3 { font-family: var(--font-title); font-size: 19px; margin: 12px 0 6px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 18px; }

.skeleton { height: 64px; border-radius: var(--radius-lg); background: linear-gradient(90deg, #eceeed 0%, #f6f7f6 50%, #eceeed 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton + .skeleton { margin-top: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters .input { width: auto; min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; color: var(--muted); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--green-strong); border-bottom-color: var(--green); }

/* avisos (toasts) */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; border-radius: var(--radius); background: var(--ink); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); animation: rise .2s ease-out; }
.toast .ti { margin-top: 2px; }
.toast--ok .ti:first-child { color: #7fd3a5; }
.toast--erro { background: #fff; color: var(--ink); border: 1px solid var(--danger-line); }
.toast--erro .ti:first-child { color: var(--danger); }
.toast__body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast__actions { display: flex; gap: 6px; margin-top: 8px; }
.toast__close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 2px; }
.toast__close:hover { opacity: 1; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* janela de confirmação */
.modal-backdrop { position: fixed; inset: 0; background: rgba(32, 32, 32, .42); z-index: 90; display: grid; place-items: center; padding: 18px; animation: fade .15s ease-out; }
.modal { width: min(460px, 100%); background: var(--surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal p { color: var(--ink-2); margin: 8px 0 0; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* login e instalação */
.auth-page { min-height: 100vh; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth__card { width: min(400px, 100%); }
.auth__card .brand { margin-bottom: 26px; }
.auth__card .panel { padding: 26px; }
.auth__card .field + .field { margin-top: 14px; }
.auth__card .btn--primary { width: 100%; margin-top: 20px; }
.install { width: min(760px, 100%); margin: 0 auto; padding: 40px 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.install .brand { margin-bottom: 8px; }
.install .panel + .panel { margin-top: 0; }
.version { text-align: center; color: var(--faint); font-size: 12px; }

.boot-error { max-width: 560px; margin: 80px auto; padding: 0 20px; }

/* ---------- telas menores ---------- */
@media (max-width: 960px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); z-index: 60;
    transform: translateX(-100%); transition: transform .2s ease-out; box-shadow: 0 0 40px rgba(0, 0, 0, .15);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(32, 32, 32, .35); z-index: 50; }
  .topbar { padding: 12px 16px; }
  .topbar__menu { display: inline-flex; }
  .content { padding: 22px 16px 56px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .h1 { font-size: 25px; }
  .sender { grid-template-columns: minmax(0, 1fr); }
  .sender__chips { justify-content: flex-start; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .test-row { flex-wrap: wrap; }
  .test-row .btn { margin-left: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
