/* SisCob — design system "Data-Dense Dashboard" (UI/UX Pro Max, 17/11/2026).
   Azul de confiança + âmbar para destaque; tokens com modo claro/escuro; sem fontes ou recursos externos (CSP/LGPD). */
:root {
  color-scheme: light;
  --bg: #f1f5f9; --surface: #ffffff; --surface-2: #f8fafc; --surface-hover: #eff6ff;
  --text: #0f172a; --muted: #475569; --line: #e2e8f0; --line-strong: #cbd5e1;
  --primary: #1e40af; --primary-hover: #1e3a8a; --primary-soft: #dbeafe; --on-primary: #ffffff; --accent: #3b82f6; --highlight: #f59e0b;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #a16207; --warn-soft: #fef3c7; --danger: #b91c1c; --danger-soft: #fee2e2;
  --info: #1e40af; --info-soft: #dbeafe; --neutral-soft: #f1f5f9;
  --side-bg: #0b1730; --side-text: #cbd5e1; --side-muted: #8da2c0; --side-hover: #16264a; --side-active: #1e3a8a; --side-line: #23365f;
  --focus: #2563eb;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --t: 180ms ease;
  font-family: var(--font); color: var(--text); background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1120; --surface: #111a2e; --surface-2: #0f172a; --surface-hover: #172544;
    --text: #e2e8f0; --muted: #94a3b8; --line: #1e2b45; --line-strong: #334155;
    --primary: #3b82f6; --primary-hover: #60a5fa; --primary-soft: #172554; --on-primary: #0b1120; --accent: #60a5fa;
    --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #3a2a05; --danger: #f87171; --danger-soft: #3b0d0d;
    --info: #93c5fd; --info-soft: #172554; --neutral-soft: #1e293b;
    --side-bg: #070d1c; --side-hover: #121f3d; --side-active: #1d3a7a; --side-line: #1a2847;
    --focus: #60a5fa;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-size: 14px; line-height: 1.5; background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
p { margin: 0 0 8px; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
noscript { display: block; padding: 24px; }

/* ---------- login ---------- */
.login {
  width: min(400px, calc(100% - 32px)); margin: 12vh auto; background: var(--surface); padding: 32px 28px;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.login h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.login h1::before {
  content: ""; width: 30px; height: 30px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--primary));
}
.login > p { margin: 0 0 22px; color: var(--muted); }
.login label.field { margin-bottom: 14px; font-size: 13px; }
.login input { width: 100%; }
.login button { width: 100%; min-height: 42px; margin-top: 6px; font-weight: 600; }

/* ---------- estrutura ---------- */
.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side-bg); color: var(--side-text); padding: 20px 12px 16px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid var(--side-line);
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 0 10px 6px; color: #fff; letter-spacing: -.01em; }
.sidebar .brand::before {
  content: ""; width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #60a5fa, #1e40af); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15);
}
.sidebar .who {
  font-size: 12px; color: var(--side-muted); padding: 0 10px 14px; margin-bottom: 8px; border-bottom: 1px solid var(--side-line);
  overflow-wrap: anywhere;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px; color: var(--side-text); text-decoration: none; padding: 9px 10px; border-radius: var(--radius-sm);
  min-height: 38px; transition: background-color var(--t), color var(--t); position: relative;
}
.sidebar a:hover { background: var(--side-hover); color: #fff; }
.sidebar a.active { background: var(--side-active); color: #fff; font-weight: 600; }
.sidebar a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--highlight); }
.sidebar a:focus-visible, .sidebar button:focus-visible { outline-color: #93c5fd; }
.sidebar .icon { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar .spacer { flex: 1; min-height: 12px; }
.sidebar button {
  display: flex; align-items: center; justify-content: center; gap: 8px; background: transparent; color: var(--side-text);
  border: 1px solid var(--side-line); min-height: 38px;
}
.sidebar button:hover { background: var(--side-hover); color: #fff; border-color: #36518a; }

.main { padding: 28px 32px 48px; width: 100%; min-width: 0; }
.main > h2 { margin: 0 0 4px; font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.main h2 { font-size: 20px; }
.main .subtitle { color: var(--muted); margin: 0 0 20px; }

/* ---------- cartões e indicadores ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h3 { margin: 0; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; margin: 0 0 14px; padding: 14px 16px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.kv { min-width: 0; }
.kv dt { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.card .actions + div:empty { display: none; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px; min-height: 86px;
}
.stat .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat .value .badge { font-size: 13px; padding: 3px 10px; }

/* ---------- indicadores de envio ---------- */
.section-title { margin: 6px 0 10px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
a.stat-link { color: inherit; text-decoration: none; cursor: pointer; transition: border-color var(--t), background var(--t); }
a.stat-link:hover { border-color: var(--accent); background: var(--surface-hover); }
.stat .value.ok { color: var(--ok); } .stat .value.warn { color: var(--warn); } .stat .value.danger { color: var(--danger); }
.stat .hint { color: var(--muted); font-size: 12px; }
.bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--neutral-soft); gap: 2px; }
.bar .seg { min-width: 6px; flex-basis: 0; }
.seg.sent, .dot.sent { background: var(--ok); } .seg.skipped, .dot.skipped { background: var(--highlight); }
.seg.failed, .dot.failed { background: var(--danger); } .seg.queued, .dot.queued { background: var(--line-strong); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.two-col > .card { margin-bottom: 0; height: 100%; }
@media (max-width: 1100px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
.sub-title { margin: 20px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.reason-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.reason-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.reason-list li:first-child { border-top: 0; padding-top: 0; }
.reason-list .reason { flex: 1; min-width: 0; }
.table-wrap.flat { box-shadow: none; margin-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
table.compact .short { display: none; }
table.compact tr.today td { font-weight: 600; }
@media (max-width: 1100px) { .grid.kpis > :first-child { grid-column: 1 / -1; } }
@media (max-width: 600px) {
  table.compact .full { display: none; } table.compact .short { display: inline; }
  table.compact th, table.compact td { padding: 8px 6px; font-size: 13px; }
  table.compact th { letter-spacing: 0; }
  table.compact td.nowrap, table.compact th { white-space: normal; }
  table.compact.dense th, table.compact.dense td { padding: 7px 4px; font-size: 12px; }
  table.compact.dense td:first-child { min-width: 76px; }
}

.danger-text { color: var(--danger); font-weight: 600; }
p.small { font-size: 13px; margin: 12px 0 22px; }
.small-text { font-size: 13px; }
.stat .hint .up { color: var(--ok); font-weight: 700; } .stat .hint .down { color: var(--danger); font-weight: 700; }
details.method summary { cursor: pointer; font-weight: 600; }
details.method ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td, table tr:last-child td { border-bottom: 0; }
th {
  font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2);
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tr.clickable { cursor: pointer; }
tr.clickable td { transition: background-color var(--t); }
tr.clickable:hover td, tr.clickable:focus-within td { background: var(--surface-hover); }
.card table { border: 1px solid var(--line); border-radius: var(--radius-sm); }

td { overflow-wrap: normal; word-break: normal; }
td.nowrap, .nowrap { white-space: nowrap; }
td a { white-space: nowrap; }
td.wide { min-width: 200px; }
/* E-mail: fonte normal, quebra só depois do "@" quando não couber. */
.email { font-size: 13px; overflow-wrap: normal; word-break: normal; }
.email .part { display: inline-block; }
.kv dd { overflow-wrap: anywhere; }
.email-list { display: flex; flex-direction: column; gap: 2px; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; padding: 0 6px; margin-right: 6px; border-radius: 4px;
  background: var(--primary-soft); color: var(--primary); vertical-align: 1px; }
.stack { display: flex; flex-direction: column; gap: 2px; }
.stack .sub { font-size: 12.5px; color: var(--muted); }

/* ---------- unidades (cartões) ---------- */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: 14px; }
.unit-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.unit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.unit-title { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; }
.unit-code {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 28px; padding: 0 8px; border-radius: 7px;
  background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700;
}
.unit-meta { font-size: 12.5px; margin-top: 4px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.setting { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.setting-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.setting-hint { font-size: 12px; }
.control { display: flex; gap: 8px; align-items: center; min-width: 0; flex-wrap: wrap; }
.control > select, .control > input { flex: 1 1 180px; min-width: 0; width: 100%; }
.control > button { flex: none; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; margin-top: 6px; cursor: pointer; }
.unit-feedback:empty { display: none; }
.unit-feedback .msg { margin-bottom: 0; }

/* ---------- formulários ---------- */
form.inline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 4px; }
form.inline > label.field { flex: 1 1 190px; max-width: 320px; }
form.inline > label.field > input, form.inline > label.field > select { width: 100%; }
form.inline > button { flex: none; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  min-width: 0; min-height: 38px; transition: border-color var(--t), box-shadow var(--t);
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 16px; height: 16px; accent-color: var(--primary); }
input:disabled, select:disabled { opacity: .6; cursor: not-allowed; }

button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; min-height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--primary);
  background: var(--primary); color: var(--on-primary); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color var(--t), border-color var(--t), color var(--t), box-shadow var(--t);
}
button:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary { background: var(--surface); color: var(--primary); border-color: var(--line-strong); }
button.secondary:hover { background: var(--surface-hover); border-color: var(--accent); }
button.danger { background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button:disabled, button:disabled:hover { opacity: .55; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions > input, .actions > select { flex: 1 1 160px; min-width: 140px; }
.actions.period { margin-top: 14px; }
.actions.period button { min-height: 36px; padding: 6px 14px; white-space: nowrap; }
button.secondary[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
@media (max-width: 600px) {
  form.period-form { display: grid; grid-template-columns: 1fr 1fr; }
  form.period-form > label.field { max-width: none; min-width: 0; }
  form.period-form > label.field:first-child { grid-column: 1 / -1; }
  .actions.period { display: grid; grid-template-columns: 1fr 1fr; }
  .actions.period > span { grid-column: 1 / -1; }
}
.filter-note:empty { display: none; }
.filter-note { margin: 12px 0 0; }
.counter-row { margin: 14px 0 0; }
.actions.counter { align-items: center; gap: 8px 14px; margin: 0; }
td .actions { min-width: 220px; flex-wrap: nowrap; }
td .actions:has(input) { flex-wrap: wrap; min-width: 320px; }
td button { min-height: 34px; padding: 6px 12px; }
@media (min-width: 1400px) { td .email { white-space: nowrap; } }
td select { min-width: 140px; }

details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; padding: 4px 0; font-weight: 500; transition: color var(--t); }
summary:hover { color: var(--primary); }
details[open] > summary { margin-bottom: 10px; }

/* ---------- selos e mensagens ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--neutral-soft); color: var(--muted); line-height: 1.6; white-space: nowrap;
}
.badge.wrap { white-space: normal; }
td .badge + .badge { margin-left: 4px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.msg { padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px; border: 1px solid transparent; border-left-width: 4px; }
.msg.error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); border-left-color: var(--danger); }
.msg.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); border-left-color: var(--ok); }
.msg.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); border-left-color: var(--accent); }
.muted { color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
pre.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
pre.box { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; margin: 8px 0 0; overflow-x: auto; }

/* ---------- responsivo ---------- */
@media (max-width: 1024px) {
  .layout { grid-template-columns: 216px minmax(0, 1fr); }
  .main { padding: 22px 20px 40px; }
}
@media (max-width: 760px) {
  body { font-size: 15px; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar { min-width: 0;
    position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 4px;
    padding: 10px 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--side-line); scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { padding: 0 8px 0 2px; font-size: 16px; }
  .sidebar .spacer, .sidebar .who { display: none; }
  .sidebar a { white-space: nowrap; min-height: 44px; padding: 8px 12px; }
  .sidebar a.active::before { left: 10px; right: 10px; top: auto; bottom: 2px; width: auto; height: 3px; border-radius: 3px; }
  .sidebar button { min-height: 44px; white-space: nowrap; }
  .main { padding: 18px 16px 40px; }
  button, input, select { min-height: 44px; }
  form.inline > label.field { flex: 1 1 140px; max-width: none; }
  .stat .value { font-size: 20px; }
}

/* Tabelas viram cartões em telas estreitas (título da coluna vem de data-label). */
@media (max-width: 900px) {
  .table-wrap:has(table.stackable) { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: 100%; }
  table.stackable { background: transparent; }
  table.stackable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.stackable tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; padding: 6px 14px; }
  table.stackable td { border-bottom: 1px solid var(--line); padding: 8px 0; display: grid; grid-template-columns: minmax(96px, 38%) 1fr; gap: 10px; }
  table.stackable tr td:last-child { border-bottom: 0; }
  table.stackable td > .badge { justify-self: start; }
  table.stackable td.nowrap { white-space: normal; }
  table.stackable td.wide { min-width: 0; }
  table.stackable td .actions { min-width: 0; flex-wrap: wrap; }
  table.stackable td:has(.actions, select, input) { grid-template-columns: 1fr; gap: 6px; }
  table.stackable td::before { content: attr(data-label); font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  table.stackable td:not([data-label]) { display: block; }
  table.stackable td:not([data-label])::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}
@media print {
  .sidebar { display: none; }
  .layout { display: block; }
  .card, .stat, .table-wrap { box-shadow: none; }
  .no-print, .menu-toggle { display: none !important; }
  .table-wrap { overflow: visible; }
  table { font-size: 10.5px; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
