/* OH Server Actions — ohsa.css (compartilhado)
   Sem estilos inline: a CSP do painel bloqueia style="" e <style>. */

:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --soft: #f6f8fa;
  --ink: #17212b;
  --muted: #5d6b79;
  --line: #dde3e9;
  --side: #1b2735;
  --side-ink: #b4c1ce;
  --side-hi: #ffffff;
  --accent: #2f7dd1;
  --accent-ink: #ffffff;
  --focus: #2f7dd1;

  --ok: #17703f;   --ok-bg: #e2f4e8;
  --err: #b42318;  --err-bg: #fde9e7;
  --warn: #8a5a00; --warn-bg: #fff2cf;
  --info: #0e5a9c; --info-bg: #e3eefa;
  --vio: #6a3ab0;  --vio-bg: #efe8fa;
  --org: #a8490a;  --org-bg: #fdebd9;
  --cyan: #0b6b78; --cyan-bg: #dcf3f5;
  --gray: #4b5866; --gray-bg: #e9edf1;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --r-sm: 4px;
  --r: 7px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161d; --panel: #18212b; --soft: #1d2833; --ink: #e3e9ef; --muted: #8e9bab; --line: #2a3644;
    --side: #0c1117; --side-ink: #8e9bab; --accent: #5aa2ec; --focus: #7cb6f2;
    --ok: #6fd39a;  --ok-bg: #143323;  --err: #ff8a80; --err-bg: #3a1a18; --warn: #f2c25b; --warn-bg: #3a2d0f;
    --info: #8cc0f5; --info-bg: #15304b; --vio: #c3a3f5; --vio-bg: #2b2042; --org: #f6a66a; --org-bg: #3c2513;
    --cyan: #7fd8e2; --cyan-bg: #12363b; --gray: #aeb9c5; --gray-bg: #26313c;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--sans); }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- estrutura */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 28px 6px; }
.top h1 { margin: 0; font-size: 21px; font-weight: 650; letter-spacing: -0.01em; }
.content { padding: 10px 28px 28px; display: flex; flex-direction: column; gap: 16px; }
.foot { margin-top: auto; padding: 14px 28px; color: var(--muted); font-size: 12px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; color: var(--side-hi); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r); background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px; letter-spacing: 0.02em; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-txt strong { font-size: 15px; }
.brand-txt small { color: var(--side-ink); font-size: 11.5px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); color: var(--side-ink); text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: var(--side-hi); }
.nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.1); color: var(--side-hi); box-shadow: inset 3px 0 0 var(--accent); }
.nav .ico { width: 20px; text-align: center; font-weight: 700; }
.side-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-foot .who { color: var(--side-hi); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.side-foot form { margin: 0; }
.btn-link { background: none; border: 0; color: var(--side-ink); cursor: pointer; padding: 4px; font: inherit; text-decoration: underline; }
.nav-toggle { display: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 18px; padding: 4px 10px; color: var(--ink); cursor: pointer; }

/* ---------- blocos */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.panel-flush { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
.empty { color: var(--muted); margin: 4px 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.health { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.health-item { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.health-item p { margin: 2px 0; }
.health-item small { color: var(--muted); }
.dot { flex: none; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--gray); }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot-err { background: var(--err); box-shadow: 0 0 0 3px var(--err-bg); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.tile { display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 12px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--accent); }
.tile-ico { grid-row: span 2; display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r); background: var(--soft); border: 1px solid var(--line); font-weight: 700; font-size: 17px; color: var(--accent); }
.tile span:last-child { color: var(--muted); font-size: 13px; }

/* ---------- formulários */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field-inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 7px 9px; min-height: 36px; width: 100%; }
input:focus, select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.form-row .field { flex: 0 1 180px; }
.form-row .grow { flex: 1 1 260px; }
.form-row .narrow { flex: 0 0 110px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; }

.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; }
.filters-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.quick { margin-left: auto; color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0; }
.toolbar .field-inline input { width: 260px; max-width: 60vw; }

/* ---------- mensagens */
.flash { padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--err-bg); color: var(--err); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.pre-plain { white-space: pre-wrap; margin: 6px 0 0; font: 12.5px/1.45 var(--mono); }

/* ---------- badges e chips */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; background: var(--gray-bg); color: var(--gray); }
.badge-ok, .badge-delivered { background: var(--ok-bg); color: var(--ok); }
.badge-err, .badge-bounced { background: var(--err-bg); color: var(--err); }
.badge-warn, .badge-deferred { background: var(--warn-bg); color: var(--warn); }
.badge-info, .badge-received { background: var(--info-bg); color: var(--info); }
.badge-rejected { background: var(--vio-bg); color: var(--vio); }
.badge-partial { background: var(--org-bg); color: var(--org); }
.badge-frozen { background: var(--cyan-bg); color: var(--cyan); }
.badge-gray, .badge-discarded { background: var(--gray-bg); color: var(--gray); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; font-size: 13px; }
.chip b { font-variant-numeric: tabular-nums; }
.chip.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.chip-delivered b { color: var(--ok); } .chip-bounced b { color: var(--err); } .chip-deferred b { color: var(--warn); }
.chip-rejected b { color: var(--vio); } .chip-partial b { color: var(--org); } .chip-frozen b { color: var(--cyan); }

.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 4px; }

/* ---------- tabelas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--soft); position: sticky; top: 0; white-space: nowrap; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--soft); }
.tbl tr.is-current td { background: var(--info-bg); }
.tbl-compact td { padding: 5px 10px; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
.tbl th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl td.two { line-height: 1.3; }
.tbl td.two > * { display: block; max-width: 220px; }
.tbl td.two small { color: var(--muted); font-size: 11.5px; }

/* tabela de e-mails: a coluna de direção é o elemento-assinatura */
.tbl.mail tbody tr { cursor: pointer; }
.tbl.mail td.obs { color: var(--err); max-width: 320px; font-size: 12.5px; }
.dir { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-weight: 800; font-size: 13px; }
.dir-in { background: var(--info-bg); color: var(--info); }
.dir-out { background: var(--org-bg); color: var(--org); }

.ingest { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: 13px; }
.ingest .dot { margin-top: 0; }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; }

/* ---------- job */
.job-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.job-head h2 { margin: 0; }
.job-wait { display: flex; align-items: center; gap: 10px; margin: 14px 0; font-weight: 600; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- listas chave/valor */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd.pre { white-space: pre-wrap; }
.kv-inline { grid-template-columns: repeat(auto-fill, minmax(90px, max-content) minmax(140px, 1fr)); }

/* ---------- diálogo */
.dlg { width: min(1000px, 96vw); max-height: 90vh; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); }
.dlg::backdrop { background: rgba(10, 16, 24, 0.55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.dlg-head h2 { margin: 0; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg-body { padding: 16px; display: flex; flex-direction: column; gap: 18px; }
.dlg-body h3 { margin: 0 0 8px; font-size: 14px; }
pre.headers { margin: 0; padding: 12px; background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-sm); font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.brand-login { padding: 0; color: var(--ink); }
.brand-login .brand-txt small { color: var(--muted); }

/* ---------- responsivo (celular e tablet) */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; left: 0; top: 0; width: 248px; transform: translateX(-100%); transition: transform 0.18s ease; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(10, 16, 24, 0.45); }
  .nav-toggle { display: inline-block; }
  .top { padding: 14px 16px 4px; }
  .content { padding: 8px 16px 20px; }
  .quick { margin-left: 0; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
