/* Painel do Oráculo RB Data — CSS próprio, sem CDN e sem build.
   Tokens em :root; o tema escuro troca só os tokens (prefers-color-scheme). */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9ecf1;
  --border: #e2e5eb;
  --border-strong: #cbd1da;
  --text: #151922;
  --text-2: #464e5c;
  --muted: #687182;
  --accent: #2b59c3;
  --accent-hover: #2249a6;
  --accent-soft: #e9effb;
  --accent-track: #dbe4f7;
  --on-accent: #ffffff;
  --focus: #2b59c3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .04);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, .10);

  --ok-bg: #e5f4ea;   --ok-fg: #17633a;   --ok-dot: #1f9d55;
  --warn-bg: #fcf1dc; --warn-fg: #7f4c00; --warn-dot: #d38b05;
  --danger-bg: #fcebeb; --danger-fg: #a12828; --danger-dot: #d03b3b;
  --info-bg: #e8eefb; --info-fg: #234a9c; --info-dot: #3a6fe0;
  --violet-bg: #efe9fc; --violet-fg: #5530a8; --violet-dot: #7b52db;
  --neutral-bg: #edf0f3; --neutral-fg: #4a5261; --neutral-dot: #8a93a3;

  --bubble-in: #f2f4f7;
  --bubble-out: #e3f3e6;
  --new-row: #fff6d6;

  --radius: 12px;
  --radius-sm: 8px;
  --gutter: 16px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1217;
    --surface: #161a21;
    --surface-2: #1c2129;
    --surface-3: #242a34;
    --border: #272d37;
    --border-strong: #38404d;
    --text: #e6e9ef;
    --text-2: #b6bdc9;
    --muted: #8b94a4;
    --accent: #7ea1ff;
    --accent-hover: #9ab5ff;
    --accent-soft: #1b2640;
    --accent-track: #233150;
    --on-accent: #0c1222;
    --focus: #8fb0ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .45);

    --ok-bg: rgba(46, 160, 90, .16);   --ok-fg: #82d7a4;   --ok-dot: #3fbf74;
    --warn-bg: rgba(217, 142, 4, .17); --warn-fg: #f0c266; --warn-dot: #e3a52b;
    --danger-bg: rgba(220, 70, 70, .18); --danger-fg: #f3a0a0; --danger-dot: #e25c5c;
    --info-bg: rgba(90, 140, 255, .17); --info-fg: #aac2ff; --info-dot: #6f97ff;
    --violet-bg: rgba(150, 110, 255, .19); --violet-fg: #cbb6ff; --violet-dot: #a283ff;
    --neutral-bg: rgba(150, 160, 175, .15); --neutral-fg: #c3c9d3; --neutral-dot: #8b94a4;

    --bubble-in: #1f252e;
    --bubble-out: #19352a;
    --new-row: #2e2a17;
  }
}

/* ----------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.02rem; font-weight: 620; }
h3 { font-size: .98rem; font-weight: 620; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, pre, .mono { font-family: var(--mono); }
code { font-size: .88em; }
img { max-width: 100%; height: auto; }
blockquote { margin: 0; }

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

.muted { color: var(--muted); }
.small { font-size: .84rem; }
.min0 { min-width: 0; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.is-hidden { display: none !important; }
.js .js-hidden { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 100;
  padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
}
.skip-link:focus { top: 8px; }

.icon { flex: none; width: 20px; height: 20px; vertical-align: -4px; }
.icon-sm { width: 16px; height: 16px; vertical-align: -3px; }
.icon-xs { width: 13px; height: 13px; vertical-align: -2px; }
.icon-lg { width: 32px; height: 32px; }

/* ----------------------------------------------------------------- topo e navegação */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1240px; margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 20px;
}

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand-name { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { color: var(--muted); font-weight: 500; }
.logo { display: block; }
.logo-bg { fill: var(--accent); }
.logo-ring { stroke: var(--on-accent); opacity: .9; }
.logo-dot { fill: var(--on-accent); }

.nav { display: flex; align-items: stretch; gap: 2px; flex: 1; min-width: 0; }
.nav-link {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 520; white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.nav-link .icon { width: 18px; height: 18px; }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--warn-dot); color: #fff;
  font-size: .72rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.badge.is-empty { display: none; }

.logout { margin: 0 0 0 auto; flex: none; }

/* ----------------------------------------------------------------- estrutura */

.container {
  width: 100%; max-width: 1240px;
  margin: 0 auto; padding: 24px var(--gutter) 40px;
  flex: 1;
}
.container:focus { outline: none; }

.footer {
  max-width: 1240px; width: 100%; margin: 0 auto;
  padding: 16px var(--gutter) 24px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: .8rem;
  border-top: 1px solid var(--border);
}

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 12px 16px; margin-bottom: 20px;
}
.page-head p { margin-top: 4px; }
.eyebrow { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }

.section { margin-top: 28px; }
.section:first-of-type { margin-top: 0; }
.section-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px 16px; margin-bottom: 12px;
}
.section-note { font-size: .84rem; }

.stack { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px; margin-bottom: 12px;
}
.card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.card-note { font-size: .78rem; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.card-head + .card-note { margin-top: 0; }
.card-danger { border-color: color-mix(in srgb, var(--danger-dot) 45%, var(--border)); }
.card-danger h2 { color: var(--danger-fg); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: .88rem; margin-bottom: 12px;
}
.back-link:hover { color: var(--accent); }

/* ----------------------------------------------------------------- pílulas e chips */

.pills { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--pill-dot, var(--neutral-dot)); flex: none;
}
.pill-outline { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 35%, transparent); }
.pill-outline::before { display: none; }
a.pill:hover { text-decoration: none; filter: brightness(.97); }
.pills-lg .pill { font-size: .84rem; padding: 4px 12px; }

.pill-ok { background: var(--ok-bg); color: var(--ok-fg); --pill-dot: var(--ok-dot); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); --pill-dot: var(--warn-dot); }
.pill-danger { background: var(--danger-bg); color: var(--danger-fg); --pill-dot: var(--danger-dot); }
.pill-info { background: var(--info-bg); color: var(--info-fg); --pill-dot: var(--info-dot); }
.pill-violet { background: var(--violet-bg); color: var(--violet-fg); --pill-dot: var(--violet-dot); }
.pill-neutral { background: var(--neutral-bg); color: var(--neutral-fg); --pill-dot: var(--neutral-dot); }
.pill-pending { background: var(--neutral-bg); color: var(--neutral-fg); --pill-dot: var(--info-dot); }
.pill-pending::before { animation: pulse 1.4s ease-in-out infinite; }
.pill-outline.pill-ok, .pill-outline.pill-warn, .pill-outline.pill-danger,
.pill-outline.pill-info, .pill-outline.pill-neutral { background: transparent; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2);
  font-size: .8rem; font-weight: 520;
}

.qa-id {
  font-size: .8rem; color: var(--text-2);
  background: var(--surface-2); padding: 1px 6px; border-radius: 5px;
  overflow-wrap: break-word; -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* ----------------------------------------------------------------- botões e formulários */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 560; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: .86rem; }
.btn-block { width: 100%; }

.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  margin-top: 12px;
}
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; position: relative; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field-help { font-size: .78rem; }
.field-error { font-size: .8rem; color: var(--danger-fg); font-weight: 520; }

input[type="text"], input[type="search"], input[type="tel"], input[type="password"], select, textarea {
  width: 100%; min-height: 38px;
  padding: 8px 11px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: .94rem;
  transition: border-color .15s, box-shadow .15s;
}
select { padding-right: 30px; cursor: pointer; }
input::placeholder { color: var(--muted); opacity: .85; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
[aria-invalid="true"] { border-color: var(--danger-dot) !important; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; flex: 1 1 420px; justify-content: flex-end; }
.filters .field-select { flex: 0 1 190px; }
.filters .field-search { flex: 1 1 220px; max-width: 380px; }
.field-search .field-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.field-search input { padding-left: 34px; }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: .9rem; margin-bottom: 14px;
}
.alert .icon { margin-top: 1px; }
.alert-danger { background: var(--danger-bg); color: var(--danger-fg); }
.alert-warn { background: var(--warn-bg); color: var(--warn-fg); }

/* ----------------------------------------------------------------- flash messages */

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: .92rem;
}
.flash-ok { background: var(--ok-bg); color: var(--ok-fg); }
.flash-erro { background: var(--danger-bg); color: var(--danger-fg); }
.flash-text { flex: 1; min-width: 0; }
.flash-close {
  display: inline-flex; padding: 4px; border: 0; border-radius: 6px;
  background: transparent; color: inherit; cursor: pointer; opacity: .7;
}
.flash-close:hover { opacity: 1; background: color-mix(in srgb, currentColor 10%, transparent); }

/* ----------------------------------------------------------------- indicador ao vivo */

.live {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: .84rem; font-weight: 560;
  cursor: pointer; box-shadow: var(--shadow);
}
.live:hover { border-color: var(--border-strong); }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok-dot);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-dot) 50%, transparent);
  animation: ring 2s ease-out infinite;
}
.live-time { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 500; }
.live[data-state="paused"] .live-dot, .live[data-state="hidden"] .live-dot { background: var(--neutral-dot); animation: none; }
.live[data-state="offline"] .live-dot { background: var(--danger-dot); animation: none; }
.live[data-state="offline"] { color: var(--danger-fg); }

/* ----------------------------------------------------------------- KPIs */

/* celular: 2 colunas · tablet: 3 · desktop: 6 de volume + 3 largos (desempenho e fila) */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .kpis .kpi-link { grid-column: 1 / -1; } }
@media (min-width: 761px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) {
  .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpis .kpi-wide { grid-column: span 2; }
}
.kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; min-width: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text);
}
.kpi-label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: .8rem; font-weight: 580; color: var(--text-2);
}
.kpi-label::before {
  content: ""; display: none; width: 7px; height: 7px; border-radius: 50%;
  background: var(--kpi-dot); flex: none;
}
.kpi-ok { --kpi-dot: var(--ok-dot); }
.kpi-warn { --kpi-dot: var(--warn-dot); }
.kpi-danger { --kpi-dot: var(--danger-dot); }
.kpi-violet { --kpi-dot: var(--violet-dot); }
.kpi-ok .kpi-label::before, .kpi-warn .kpi-label::before,
.kpi-danger .kpi-label::before, .kpi-violet .kpi-label::before { display: inline-block; }
.kpi-value { font-size: 1.65rem; font-weight: 640; letter-spacing: -.02em; line-height: 1.2; overflow-wrap: anywhere; }
.kpi-sub { font-size: .78rem; color: var(--muted); }
.kpi-share { color: var(--text-2); font-weight: 560; }
.kpi-hint { font-size: .74rem; color: var(--muted); margin-top: 2px; }
.kpi-flag {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 4px; font-size: .78rem; font-weight: 620; color: var(--danger-fg);
}
.kpi-alert { border-color: color-mix(in srgb, var(--danger-dot) 55%, var(--border)); background: color-mix(in srgb, var(--danger-bg) 55%, var(--surface)); }
.kpi-alert .kpi-value { color: var(--danger-fg); }
.kpi-link { transition: border-color .15s, transform .15s; }
.kpi-link:hover { text-decoration: none; border-color: var(--accent); }
.kpi-link .kpi-sub { color: var(--accent); font-weight: 560; display: inline-flex; align-items: center; gap: 4px; }

/* ----------------------------------------------------------------- feed (tabela → cards) */

.feed { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.feed-meta { padding: 10px 16px; font-size: .8rem; border-top: 1px solid var(--border); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .76rem; font-weight: 620; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.feed-row { cursor: pointer; transition: background-color .2s; }
.feed-row:hover { background: var(--surface-2); }
.feed-row.row-danger { box-shadow: inset 3px 0 0 var(--danger-dot); }
.feed-row.is-new { animation: new-row 6s ease-out; }

.cell-sub { display: block; font-size: .76rem; color: var(--muted); margin-top: 1px; }
.c-when { white-space: nowrap; width: 1%; }
.c-when time { font-weight: 560; }
.c-contact { white-space: nowrap; width: 1%; }
.contact-name { font-weight: 580; }
.c-question { min-width: 220px; }
.row-link { display: flex; gap: 8px; color: var(--text); }
.row-link:hover { text-decoration: none; color: var(--accent); }
.input-icon { color: var(--muted); padding-top: 1px; flex: none; }
.question-text {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
}
.c-status { width: 1%; }
.c-status { min-width: 120px; }
.c-qa { width: 1%; min-width: 150px; max-width: 240px; }
.c-time { width: 1%; color: var(--text-2); }
.c-time.is-slow { color: var(--danger-fg); font-weight: 620; }
.slow-icon { display: inline-flex; vertical-align: -1px; margin-right: 2px; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.empty .icon-lg { color: var(--border-strong); margin-bottom: 8px; }
.empty-title { color: var(--text); font-weight: 600; margin-bottom: 4px; }
.empty-page { max-width: 520px; margin: 40px auto; text-align: center; padding: 32px 24px; }
.empty-page h1 { margin: 4px 0 8px; }
.empty-page p:last-child { margin-top: 20px; }
.empty-code { font-size: 2.6rem; font-weight: 700; color: var(--border-strong); letter-spacing: -.03em; }

/* ----------------------------------------------------------------- detalhe da interação */

.detail-grid {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
}
.bubble {
  padding: 11px 14px; border-radius: 14px;
  white-space: pre-wrap; overflow-wrap: anywhere;
  line-height: 1.55;
}
.bubble-in { background: var(--bubble-in); border-top-left-radius: 4px; }
.bubble-out { background: var(--bubble-out); border-top-right-radius: 4px; }
.whatsapp strong { font-weight: 680; }
.whatsapp code { background: color-mix(in srgb, var(--text) 8%, transparent); padding: 0 4px; border-radius: 4px; }

.media { margin: 14px 0 0; }
.media img {
  display: block; max-height: 520px; width: auto;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: #fff;
}
.media figcaption { margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.dl { display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); font-size: .84rem; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dd-sub { display: block; font-size: .82rem; color: var(--text-2); margin-top: 2px; }
.dl-compact { font-size: .86rem; gap: 6px 12px; margin-top: 12px; }

.code {
  margin: 0; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .8rem; line-height: 1.55; color: var(--text);
  overflow: auto; max-height: 440px; max-width: 100%;
  tab-size: 2;
}
.code-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }

.latency { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 14px; }
.latency-value { font-size: 1.6rem; font-weight: 640; letter-spacing: -.02em; }
.latency.is-slow .latency-value { color: var(--danger-fg); }
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; font-size: .84rem; color: var(--text-2); margin-bottom: 4px; }
.bar-head .num { color: var(--text); font-weight: 560; }
.bar-track { display: block; width: 100%; height: 8px; overflow: visible; }
.bar-bg { fill: var(--accent-track); }
.bar-fill { fill: var(--accent); }

/* ----------------------------------------------------------------- candidatos */

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: .88rem; font-weight: 560;
}
.tab:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.tab[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.tab-count {
  min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center;
  background: color-mix(in srgb, currentColor 16%, transparent); font-size: .76rem; font-weight: 700;
}

.candidate-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.candidate-link { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; }
.candidate-question {
  margin: 12px 0 8px; padding: 2px 0 2px 12px;
  border-left: 3px solid var(--border-strong);
  font-size: 1rem; overflow-wrap: anywhere;
}
.note { background: var(--surface-2); padding: 8px 10px; border-radius: var(--radius-sm); margin-top: 6px; overflow-wrap: anywhere; }
.candidate-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.candidate-form .field-select { flex: 0 1 170px; }
.candidate-form .field-grow { flex: 1 1 240px; }

/* ----------------------------------------------------------------- contatos */

.split { display: grid; gap: 20px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
.split-side { position: sticky; top: calc(var(--topbar-h) + 16px); }
.contact-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.contact { padding: 14px 16px; }
.contact.is-inactive { background: var(--surface-2); }
.contact.is-inactive .contact-name { color: var(--muted); }
.contact-main {
  display: grid; gap: 4px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "id actions" "meta actions";
  align-items: center;
}
.contact-id { grid-area: id; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.contact-meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); }
.contact-actions { grid-area: actions; }
.contact-actions form { margin: 0; }
.contact-edit { margin-top: 10px; }
.contact-edit summary {
  display: inline-flex; cursor: pointer; font-size: .84rem; font-weight: 560; color: var(--accent);
  list-style: none;
}
.contact-edit summary::-webkit-details-marker { display: none; }
.contact-edit summary::before { content: "▸"; margin-right: 6px; transition: transform .15s; display: inline-block; }
.contact-edit[open] summary::before { transform: rotate(90deg); }

/* ----------------------------------------------------------------- catálogo */

.catalog-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); }
.qa { display: flex; flex-direction: column; gap: 6px; }
.qa.is-unavailable { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.qa-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 8px; }
.qa-head h3 { flex: 1 1 200px; }
.qa .qa-id { align-self: flex-start; }
.qa-desc { color: var(--text-2); font-size: .9rem; }
.qa .alert { margin: 4px 0 0; }
.qa-examples ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: .88rem; }
.qa-examples li + li { margin-top: 2px; }
.inline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sql { margin-top: 8px; }
.sql summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: .84rem; font-weight: 560; color: var(--accent); list-style: none;
}
.sql summary::-webkit-details-marker { display: none; }
.sql[open] summary { margin-bottom: 8px; }
:target { scroll-margin-top: calc(var(--topbar-h) + 16px); }
.card:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.glossary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.term p { color: var(--text-2); font-size: .9rem; margin-top: 8px; }
.term-head { display: flex; align-items: center; gap: 10px; }
.term-id {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 26px; padding: 0 6px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .82rem;
}

/* ----------------------------------------------------------------- login */

.page-login { background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), var(--bg) 60%); }
.page-login .container { display: flex; align-items: flex-start; justify-content: center; padding-top: max(48px, 10vh); }
.login-card { width: 100%; max-width: 400px; padding: 28px 24px 22px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .logo { width: 40px; height: 40px; }
.login-brand h1 { font-size: 1.2rem; }
.login-brand p { font-size: .86rem; margin-top: 2px; }
.login-card .btn-primary { margin-top: 4px; min-height: 42px; }
.login-foot { margin-top: 16px; font-size: .78rem; text-align: center; }

/* ----------------------------------------------------------------- animações */

@keyframes ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok-dot) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes pulse { 50% { opacity: .35; } }
@keyframes new-row {
  0%, 35% { background-color: var(--new-row); }
  100% { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ----------------------------------------------------------------- responsivo */

@media (max-width: 1000px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .split-side { position: static; }
  .brand-sub { display: none; }
}

/* feed: tabela vira cards no celular e no tablet em pé */
@media (max-width: 900px) {
  .feed-table, .feed-table tbody { display: block; }
  .feed-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .feed-row {
    display: grid; gap: 6px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "contact when" "question question" "status time" "qa qa";
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .feed-row:last-child { border-bottom: 0; }
  .feed-table td { display: block; padding: 0; border: 0; width: auto; min-width: 0; }
  .c-contact { grid-area: contact; display: flex !important; flex-wrap: wrap; align-items: baseline; gap: 0 8px; white-space: normal; }
  .c-contact .cell-sub { margin: 0; }
  .c-when { grid-area: when; text-align: right; font-size: .8rem; color: var(--muted); }
  .c-when .cell-sub { display: none; }
  .c-question { grid-area: question; }
  .c-status { grid-area: status; align-self: center; }
  .c-status .pills { flex-wrap: wrap; }
  .c-time { grid-area: time; align-self: center; font-size: .84rem; }
  .c-qa { grid-area: qa; white-space: normal; }
  .c-qa:not(:has(code)) { display: none !important; }
  .c-qa::before { content: "Catálogo "; color: var(--muted); font-size: .76rem; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  h1 { font-size: 1.3rem; }
  .container { padding-top: 16px; }

  .topbar-inner { flex-wrap: wrap; gap: 0 12px; padding-top: 6px; }
  .brand { min-height: 44px; }
  .logout-label { display: none; }
  .nav {
    order: 3; flex-basis: 100%;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
    margin: 0 calc(-1 * var(--gutter));
    border-top: 1px solid var(--border);
  }
  .nav-link {
    flex-direction: column; gap: 2px; justify-content: center;
    padding: 7px 2px 8px; border-radius: 0;
    font-size: .7rem; font-weight: 600;
  }
  .nav-link[aria-current="page"] { background: transparent; box-shadow: inset 0 -2px 0 var(--accent); }
  .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav-link .badge { position: absolute; top: 3px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: .64rem; padding: 0 4px; }

  /* iOS não dá zoom em campos com fonte >= 16px */
  input[type="text"], input[type="search"], input[type="tel"], input[type="password"], select, textarea { font-size: 16px; }

  .page-head { align-items: flex-start; }
  .filters { flex-basis: 100%; justify-content: stretch; }
  .filters .field-select { flex: 0 0 auto; max-width: 52%; }
  .filters .field-search { flex: 1 1 130px; max-width: none; }


  .contact-main { grid-template-columns: minmax(0, 1fr); grid-template-areas: "id" "meta" "actions"; }
  .contact-actions { margin-top: 6px; }
  .candidate-link { margin-left: 0; }
  .candidate-form .btn { flex: 1 1 100%; }
  .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .dl dd + dt { margin-top: 8px; }
  .live { padding: 5px 10px; }
}

@media (max-width: 380px) {
  :root { --gutter: 14px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 1.4rem; }
  .brand-name { font-size: .95rem; }
}

@media (forced-colors: active) {
  .pill, .badge, .chip, .tab { border: 1px solid CanvasText; }
  .bar-fill { fill: Highlight; }
  .bar-bg { fill: Canvas; stroke: CanvasText; }
}

@media print {
  .topbar, .footer, .filters, .live, .candidate-form, .contact-actions, .contact-edit { display: none !important; }
  body { background: #fff; }
}
