/* Identidade visual Onkos (extraída de onkos.com.br):
   Montserrat nos títulos, Roboto no texto; cores do logo e do degradê da home. */
:root {
  color-scheme: light;
  --paper: #f5f5f9;
  --surface: #ffffff;
  --ink: #2c2c2c;          /* --e-global-color-primary */
  --heading: #000000;
  --text: #666666;         /* cor de texto do site */
  --muted: #7a7a86;
  --line: #e4e3ec;

  /* Marketing: roxo da marca */
  --mkt: #5842bc;
  --mkt-2: #a115c1;        /* magenta do logo, linha secundária */
  --mkt-soft: rgba(88, 66, 188, 0.08);
  /* Conversas: azul/ciano do logo */
  --cv: #0c81e1;
  --cv-fill: #02b3e1;
  --cv-soft: rgba(2, 179, 225, 0.08);

  --brand-gradient: linear-gradient(90deg, #501e9c 0%, #8169f1 40%, #a44cee 75%, #ff847f 100%);
  --tag-bg: rgba(2, 179, 225, 0.08);
  --warn: #d4544e;
  --good: #198754;
  --focus: #5842bc;
  --shadow: 0 12px 40px rgba(72, 46, 224, 0.08);
  --on-accent: #ffffff;    /* texto sobre botão roxo selecionado */
  --logo-filter: none;
  --radius-panel: 28px;
  --radius-pill: 35px;

  --font-display: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --font-body: "Roboto", "Segoe UI", system-ui, -apple-system, sans-serif;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
}

/* Tema escuro: automático pelo sistema (sem escolha salva) ou forçado pelo seletor (data-theme no <html>).
   Os dois blocos têm os mesmos valores; ao mudar um, mude o outro. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #13111c; --surface: #1d1a2a; --ink: #ecebf3; --heading: #ffffff; --text: #b9b6c8; --muted: #9893ad; --line: #2e2a40;
    --mkt: #a99bf5; --mkt-2: #e07af0; --mkt-soft: rgba(169, 155, 245, 0.12);
    --cv: #4fcbef; --cv-fill: #2bbfe8; --cv-soft: rgba(79, 203, 239, 0.12); --tag-bg: rgba(79, 203, 239, 0.12);
    --warn: #ff8a7f; --good: #5fd39a; --focus: #a99bf5; --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    --on-accent: #13111c; --logo-filter: brightness(1.15);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #13111c; --surface: #1d1a2a; --ink: #ecebf3; --heading: #ffffff; --text: #b9b6c8; --muted: #9893ad; --line: #2e2a40;
  --mkt: #a99bf5; --mkt-2: #e07af0; --mkt-soft: rgba(169, 155, 245, 0.12);
  --cv: #4fcbef; --cv-fill: #2bbfe8; --cv-soft: rgba(79, 203, 239, 0.12); --tag-bg: rgba(79, 203, 239, 0.12);
  --warn: #ff8a7f; --good: #5fd39a; --focus: #a99bf5; --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --on-accent: #13111c; --logo-filter: brightness(1.15);
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--text);
  font: 400 15px/1.75 var(--font-body);
  font-variant-numeric: tabular-nums;
  /* Manchas suaves de lavanda e ciano, como no fundo da home */
  background-image:
    radial-gradient(600px 400px at 92% 4%, rgba(129, 105, 241, 0.10), transparent 70%),
    radial-gradient(500px 360px at 0% 30%, rgba(2, 179, 225, 0.07), transparent 70%);
  background-attachment: fixed;
}
h1, h2, h3 { font-family: var(--font-display); color: var(--heading); margin: 0; }
h1 { font-size: clamp(1.75rem, 3.4vw, 2.5rem); font-weight: 600; line-height: 1.25; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2.25rem); font-weight: 700; line-height: 1.2; }
h3 { font-size: 1rem; font-weight: 600; line-height: 1.35; margin-bottom: var(--s3); }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.gradient-text { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Etiqueta no estilo "Diagnósticos moleculares" do site */
.tag {
  display: inline-block; font-family: var(--font-display); font-size: 0.875rem; font-weight: 400;
  color: var(--ink); background: var(--tag-bg); padding: 5px 10px; border-radius: 5px; line-height: 1.4;
}

/* ---------- Cabeçalho (montado pelo header.js; o login usa a mesma base) ---------- */
.topbar {
  position: relative; z-index: 6;
  display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between;
  padding: var(--s4) clamp(var(--s4), 4vw, var(--s7));
  background: var(--surface);
  border-radius: 0 0 40px 40px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: var(--s4); min-width: 0; text-decoration: none; }
.logo { height: 44px; width: auto; display: block; }

/* Cabeçalho interno: altura fixa e mesma ordem em todas as páginas */
#topbar { flex-wrap: nowrap; min-height: 76px; padding-top: var(--s3); padding-bottom: var(--s3); }
#topbar .brand { flex: none; }
#topbar .menu { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex: 1; min-width: 0; }
/* Menu de páginas: trilho cinza com a página atual destacada (mesmo desenho do seletor de tema) */
.mainnav { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--paper); }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-weight: 600; font-size: 0.8125rem; line-height: 1.4; white-space: nowrap;
  color: var(--ink); text-decoration: none;
}
.nav-link[hidden] { display: none; }
.nav-link svg { width: 16px; height: 16px; flex: none; opacity: .7; }
.nav-link:hover { color: var(--mkt); }
.nav-link[aria-current="page"] { background: var(--surface); color: var(--mkt); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.nav-link[aria-current="page"] svg { opacity: 1; }
.nav-link--test::after { content: 'teste'; margin-left: 2px; font-size: 0.625rem; padding: 1px 5px; border-radius: 6px; background: #f5b400; color: #2c2c2c; }
.topbar-end { display: flex; align-items: center; gap: var(--s2); flex: none; }
.nav-link--account { background: var(--paper); }
/* Reserva o espaço do seletor de tema antes do theme.js preenchê-lo */
[data-theme-switch] { min-width: 100px; min-height: 36px; }

/* ---------- Barra de filtros: separada do menu, presa no topo ao rolar ---------- */
.filterbar {
  --gutter: clamp(var(--s4), 4vw, var(--s7));
  position: sticky; top: var(--s3); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  width: fit-content; max-width: calc(100% - 2 * var(--gutter));
  /* Alinhada à esquerda do conteúdo (main tem no máximo 1440px) */
  margin: var(--s5) 0 0 max(var(--gutter), calc((100% - 1440px) / 2 + var(--gutter)));
  padding: 6px 6px 6px var(--s5);
  background: var(--surface); border-radius: var(--radius-pill); box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.filterbar-label {
  font-family: var(--font-display); font-weight: 600; font-size: 0.6875rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
.filterbar-sep { width: 1px; height: 24px; background: var(--line); }
.filterbar .segmented button { padding: 5px 12px; font-size: 0.8125rem; }
.filterbar .date input { padding: 6px 12px; font-size: 0.8125rem; }
.filterbar .date-range { flex-wrap: nowrap; gap: 6px; }
.filterbar .btn { padding: 7px 16px; font-size: 0.8125rem; }
.filterbar ~ main { padding-top: var(--s6); }
.brand-sep { width: 1px; height: 28px; background: var(--line); }
.brand-name { font-family: var(--font-display); font-weight: 600; color: var(--ink); font-size: 0.9375rem; }
.logo { filter: var(--logo-filter); }

/* Título de tabela com botão de exportar ao lado */
.table-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.table-head--end { justify-content: flex-end; margin: var(--s3) 0; }
.btn--sm { padding: 4px 12px; font-size: 0.75rem; }
td.secondary { color: var(--muted); }

/* Seletor de tema: três ícones numa pílula */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--paper); }
.theme-switch button {
  display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); cursor: pointer;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--surface); color: var(--mkt); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12); }
.theme-switch svg { width: 16px; height: 16px; }

.controls, .menu, .date-range { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.menu-toggle {
  display: none; width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: var(--paper); color: var(--ink); cursor: pointer; place-items: center;
}
.menu-toggle svg { width: 22px; height: 22px; }
.menu-toggle .i-close, .menu-toggle[aria-expanded="true"] .i-open { display: none; }
.menu-toggle[aria-expanded="true"] .i-close { display: inline; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-pill); background: var(--paper); }
.segmented button {
  white-space: nowrap; /* "30 dias" nunca quebra em duas linhas */
  border: 0; background: none; padding: 6px 14px; cursor: pointer; font-size: 0.875rem;
  border-radius: var(--radius-pill); color: var(--ink);
}
.segmented button[aria-pressed="true"] { background: var(--mkt); color: var(--on-accent); }
.date input {
  border: 0; border-radius: var(--radius-pill); padding: 7px 14px; background: var(--paper); font-size: 0.875rem; color: var(--ink);
}
.date-sep { color: var(--muted); font-size: 0.875rem; }
.btn {
  display: inline-block; border: 0; border-radius: var(--radius-pill); padding: 8px 20px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 0.875rem; text-decoration: none;
  background: var(--brand-gradient); color: #fff;
}
.btn:hover { filter: brightness(1.05); }
.btn[disabled] { opacity: .6; cursor: progress; }

.notice {
  margin: var(--s5) clamp(var(--s4), 4vw, var(--s7)) 0;
  padding: var(--s4) var(--s5); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow);
  display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; color: var(--ink);
}
.notice[hidden] { display: none; }

main { padding: var(--s7) clamp(var(--s4), 4vw, var(--s7)) var(--s8); max-width: 1440px; margin: 0 auto; }

/* ---------- Jornada ---------- */
.journey { margin-bottom: var(--s7); }
.journey > .tag { margin-bottom: var(--s4); }
.journey h1 { max-width: 22ch; }
.journey .sub { margin: var(--s2) 0 var(--s6); color: var(--muted); font-size: 0.9375rem; }
.journey-track {
  list-style: none; margin: 0; padding: var(--s2);
  display: grid; grid-template-columns: repeat(var(--steps, 7), minmax(0, 1fr)); gap: var(--s2);
  background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow);
}
.step {
  position: relative; padding: var(--s5) var(--s4) var(--s4); border-radius: 20px;
  min-height: 168px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
}
.step--mkt { background: var(--mkt-soft); }
.step--cv { background: var(--cv-soft); }
.step--bridge { background: linear-gradient(135deg, rgba(129, 105, 241, 0.14), rgba(255, 132, 127, 0.14)); }
.step-value { font-family: var(--font-display); font-weight: 700; line-height: 1.05; font-size: clamp(1.6rem, 2.8vw, 2.4rem); }
.step--mkt .step-value { color: var(--mkt); }
.step--cv .step-value { color: var(--cv); }
.step--bridge .step-value { background: var(--brand-gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
.step-label { font-family: var(--font-display); font-weight: 600; font-size: 0.875rem; color: var(--ink); line-height: 1.35; }
.step-rate { color: var(--muted); font-size: 0.8125rem; min-height: 1.2em; line-height: 1.4; }
.step-bar { height: 5px; border-radius: 3px; margin-bottom: var(--s3); align-self: flex-start; opacity: .55; }
.step--mkt .step-bar { background: var(--mkt); }
.step--cv .step-bar { background: var(--cv-fill); }
.step--bridge .step-bar { background: var(--brand-gradient); opacity: .8; }
.journey-note { margin-top: var(--s4); color: var(--muted); font-size: 0.8125rem; max-width: 80ch; line-height: 1.6; }

@media (max-width: 960px) {
  .journey-track { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step { min-height: 128px; }
}

/* ---------- Blocos (painéis brancos arredondados, como as seções do site) ---------- */
.block {
  margin-bottom: var(--s6); padding: clamp(var(--s5), 3vw, var(--s7));
  background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow);
}
.block--mkt { --accent: var(--mkt); --accent-fill: var(--mkt); }
.block--cv { --accent: var(--cv); --accent-fill: var(--cv-fill); }
.block-head { margin-bottom: var(--s6); }
.block-head .tag { margin-bottom: var(--s3); }
.block--mkt .block-head .tag { background: var(--mkt-soft); }

.figures { display: flex; flex-wrap: wrap; gap: var(--s3); margin: 0 0 var(--s6); padding: 0; }
.figure { padding: var(--s3) var(--s5); margin: 0; border-radius: 18px; background: var(--paper); min-width: 150px; }
.figure dt { color: var(--muted); font-size: 0.8125rem; line-height: 1.4; }
.figure dd { margin: 4px 0 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px var(--s2); }
.figure .value { font-family: var(--font-display); font-weight: 700; font-size: 1.6rem; line-height: 1.15; color: var(--heading); }
.delta { font-size: 0.8125rem; font-weight: 500; }
.delta.up { color: var(--good); }
.delta.down { color: var(--warn); }
.delta.flat { color: var(--muted); }

.chart { margin: 0 0 var(--s6); }
.chart figcaption { font-family: var(--font-display); font-weight: 600; color: var(--ink); margin-bottom: var(--s3); }
.chart-box { position: relative; height: 260px; }

.split { display: grid; gap: var(--s6); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: var(--s6); }
.split--wide { grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); }
@media (max-width: 860px) { .split--wide { grid-template-columns: 1fr; } }

.ranked { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.ranked li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s3); align-items: baseline; font-size: 0.875rem; line-height: 1.4; }
.ranked .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.ranked .count { font-weight: 500; color: var(--heading); }
.ranked .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--paper); overflow: hidden; }
.ranked .bar span { display: block; height: 100%; background: var(--accent-fill); border-radius: 4px; }
.block--mkt .ranked .bar span { background: linear-gradient(90deg, #501e9c, #8169f1); }
.ranked .meta { grid-column: 1 / -1; color: var(--muted); font-size: 0.75rem; }
.conv { margin-bottom: var(--s6); padding-top: var(--s5); border-top: 1px solid var(--line); }
.conv > h3 { font-size: 1.125rem; }
.figures--compact { margin-bottom: var(--s5); }
.ranked .meta strong { color: var(--good); font-weight: 500; }
.empty { color: var(--muted); font-size: 0.875rem; }

.more summary { cursor: pointer; font-family: var(--font-display); font-weight: 600; color: var(--accent); padding: var(--s2) 0; }
.more[open] summary { margin-bottom: var(--s3); }

/* position: relative segura textos ocultos (visually-hidden) dentro da rolagem */
.table-wrap { overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; line-height: 1.5; }
th, td { text-align: left; padding: var(--s3); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { color: var(--ink); }
th { color: var(--muted); font-weight: 500; font-size: 0.8125rem; }
td:first-child, th:first-child { padding-left: 0; }
.num { text-align: right; }
.sortable th[data-key] { cursor: pointer; user-select: none; }
.sortable th[aria-sort="descending"]::after { content: " ↓"; }
.sortable th[aria-sort="ascending"]::after { content: " ↑"; }
.slow { color: var(--warn) !important; font-weight: 500; }

/* Mapa de calor */
.heat { margin-bottom: var(--s6); }
.hint { color: var(--muted); font-size: 0.8125rem; margin: -6px 0 var(--s3); line-height: 1.5; }
.heatmap { display: grid; grid-template-columns: 40px repeat(24, minmax(18px, 1fr)); gap: 3px; min-width: 560px; font-size: 0.6875rem; line-height: 1.2; }
.heatmap .hlabel { color: var(--muted); display: flex; align-items: center; }
.heatmap .hcol { color: var(--muted); text-align: center; }
.heatmap .cell { aspect-ratio: 1.4; border-radius: 5px; background: color-mix(in srgb, var(--cv-fill) calc(var(--v, 0) * 100%), var(--paper)); }
/* Fora do expediente: contorno tracejado em cor de alerta */
.heatmap .cell.off { outline: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent); outline-offset: -1px; }

/* Status */
.status { padding: var(--s6) clamp(var(--s5), 3vw, var(--s7)); background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow); }
.status h2 { font-size: 1.25rem; display: inline; }
.status summary { cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; }
.status summary::-webkit-details-marker { display: none; }
.status summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.status[open] summary { margin-bottom: var(--s5); }
.status[open] summary::after { content: '▴'; }
.status-sum { font-size: 0.875rem; color: var(--muted); }
.status-sum .err { color: var(--warn); }
.status[hidden] { display: none; }
.status-grid { display: grid; gap: var(--s6); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.sources { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s4); }
.sources li { display: grid; grid-template-columns: 12px 1fr; gap: 2px var(--s3); font-size: 0.875rem; line-height: 1.5; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--muted); }
.dot.ok { background: var(--good); }
.dot.bad { background: var(--warn); }
.sources .src-name { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.sources .src-detail { grid-column: 2; color: var(--muted); }
.events { list-style: none; padding: 0; margin: 0; font-size: 0.8125rem; line-height: 1.5; }
.events li { display: grid; grid-template-columns: 9.5em 1fr auto; gap: var(--s3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.events time { color: var(--muted); }
.events .ev-src-mkt { color: var(--mkt); font-weight: 500; }
.events .ev-src-cv { color: var(--cv); font-weight: 500; }
.events .err { color: var(--warn); }

body.loading main { opacity: .55; transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Notebook (1201–1560px, ex.: 15,6" 1080p com zoom de 125% ≈ 1536px): sem o nome ao lado do
   logo e menu um pouco mais justo, para tudo caber numa linha */
@media (min-width: 1201px) and (max-width: 1560px) {
  #topbar .brand-sep, #topbar .brand-name { display: none; }
  #topbar .logo { height: 40px; }
  #topbar .nav-link { padding: 6px 11px; }
}

/* Até 1200px (tablet, celular deitado, janela estreita): logo + sanduíche; o menu abre embaixo */
@media (max-width: 1200px) {
  #topbar { flex-wrap: wrap; min-height: 0; border-radius: 0 0 28px 28px; padding: var(--s3) clamp(var(--s4), 3vw, var(--s6)); }
  #topbar .brand-sep, #topbar .brand-name { display: none; }
  #topbar .logo { height: 38px; }
  .menu-toggle { display: grid; width: 40px; height: 40px; }
  #topbar .menu {
    display: none; flex: 1 0 100%; flex-direction: column; align-items: stretch; gap: var(--s3);
    padding-top: var(--s3); border-top: 1px solid var(--line);
  }
  #topbar .menu.open { display: flex; }
  /* Colunas iguais, quantas forem as páginas visíveis (leitura vê menos) */
  .mainnav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border-radius: 20px; }
  .mainnav .nav-link { justify-content: center; padding: 9px 12px; white-space: normal; text-align: center; line-height: 1.25; }
  .topbar-end { justify-content: flex-end; }
  .topbar-end .theme-switch { margin-right: auto; }
}

/* Barra de filtros em telas médias: ocupa a largura e distribui os grupos */
@media (max-width: 900px) {
  .filterbar { width: auto; margin-left: var(--gutter); margin-right: var(--gutter); max-width: none; border-radius: 24px; padding: var(--s2) var(--s2) var(--s2) var(--s4); }
}

@media (max-width: 640px) {
  .topbar { border-radius: 0 0 28px 28px; }
  #topbar { padding: var(--s3) var(--s4); border-radius: 0 0 24px 24px; }
  .logo { height: 34px; }
  #topbar .logo { height: 34px; }
  .brand-sep, .brand-name { display: none; }
  .menu-toggle { width: 38px; height: 38px; }
  .mainnav { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
  /* Celular em pé: filtros em grade, sem prender no topo (ocupariam meia tela) */
  .filterbar { position: static; display: grid; grid-template-columns: 1fr; padding: var(--s3); gap: var(--s2); }
  .filterbar-label, .filterbar-sep { display: none; }
  .filterbar .segmented { display: grid; grid-template-columns: repeat(4, 1fr); }
  .filterbar .segmented button { padding: 6px 4px; }
  .filterbar .date-range { display: grid; grid-template-columns: 1fr auto 1fr; }
  .filterbar .date input { width: 100%; padding: 7px 10px; }
  .filterbar .btn { width: 100%; }
  .figure { min-width: calc(50% - 6px); flex: 1; padding: var(--s3) var(--s4); }

  /* Tabelas viram cartões: uma linha por item, rótulo da coluna ao lado do valor (data-label) */
  /* Tabelas viram cartões em grade: nome em cima e os campos lado a lado (rótulo pequeno sobre o valor) */
  table.stack-table, .stack-table tbody { display: block; width: 100%; }
  .stack-table thead { display: none; }
  .stack-table tr {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2) var(--s3);
    padding: var(--s3) 0; border-bottom: 1px solid var(--line);
  }
  .stack-table td { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 0; border: 0; text-align: left; overflow-wrap: anywhere; }
  .stack-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.6875rem; letter-spacing: .02em; text-transform: uppercase; }
  .stack-table td:first-child { grid-column: 1 / -1; font-family: var(--font-display); font-weight: 600; color: var(--heading); }
  .stack-table td:first-child::before, .stack-table td.empty::before, .stack-table td[data-label=""]::before { content: none; }
  .stack-table td.empty, .stack-table td.actions { grid-column: 1 / -1; }
  .stack-table td.secondary { font-size: 0.8125rem; }

  /* Mapa de calor cabe na tela: colunas encolhem e só aparecem os rótulos de 6 em 6 horas */
  .heatmap { min-width: 0; grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 0.625rem; }
  .heatmap .cell { aspect-ratio: auto; height: 16px; border-radius: 3px; }
  .heatmap .hcol { text-align: left; overflow: visible; white-space: nowrap; }
  .heatmap .hcol:nth-child(6n+5) { visibility: hidden; }
}

/* ---------- Página de acesso (conta e usuários) ---------- */
.account { max-width: 1040px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
.account > .tag { justify-self: start; }
/* .panel (Admin) usa o mesmo cartão que .block (painel e Contatos) */
.panel { background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow); padding: clamp(var(--s5), 3vw, var(--s7)); }
.panel[hidden], .stack-form[hidden] { display: none; }
.panel h2 { margin-bottom: var(--s3); }
/* Mesmo tamanho de título em todos os cartões do sistema */
.block h2, .panel h2, .status h2 { font-size: clamp(1.375rem, 2.2vw, 1.875rem); }
.panel .hint { margin-bottom: var(--s4); }
.section-gap { margin-top: var(--s6); }
.stack-form { display: grid; gap: 6px; max-width: 360px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); gap: var(--s3); align-items: end; }
/* Busca de contatos: campo de texto ocupa a linha toda no celular; selects ficam em 2 colunas */
@media (max-width: 640px) { #filters label:first-child, #filters .btn { grid-column: 1 / -1; } }
.stack-form label, .grid-form label { font-family: var(--font-display); font-weight: 600; font-size: 0.8125rem; color: var(--ink); display: grid; gap: 6px; }
.stack-form input, .grid-form input, .grid-form select, .panel td select {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0 16px; background: var(--paper); color: var(--ink); font: 400 1rem var(--font-body);
}
.panel td select { height: 34px; font-size: 0.875rem; width: auto; }
.stack-form input { margin-bottom: var(--s2); }
.stack-form .btn, .grid-form .btn { height: 42px; justify-self: start; }
.form-msg { grid-column: 1 / -1; font-size: 0.875rem; min-height: 1.4em; }
.form-msg.ok { color: var(--good); }
.form-msg.err { color: var(--warn); }
.panel tr.inactive td { color: var(--muted); }
.panel td.actions { white-space: nowrap; text-align: right; }
.panel td.actions .btn + .btn { margin-left: 4px; }
.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin-top: var(--s4); font-size: 0.875rem; }
.pager .btn[disabled] { opacity: .4; cursor: default; }
/* Contatos: página larga e tabela compacta para caber as 10 colunas */
.account--wide { max-width: 1440px; }
#contacts-table th, #contacts-table td { font-size: 0.8125rem; padding: 8px 6px; vertical-align: top; }
.grid-form .custom-range[hidden] { display: none; }
@media (min-width: 1301px) {
  /* Largura fixa por coluna (soma 100%): a tabela sempre cabe, sem rolagem lateral.
     Texto longo corta com "…" e o valor inteiro aparece ao passar o mouse (title). */
  #contacts-table { width: 100%; table-layout: fixed; }
  #contacts-table th, #contacts-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #contacts-table th:nth-child(1) { width: 18%; }  /* Nome */
  #contacts-table th:nth-child(2) { width: 10%; }  /* Telefone */
  #contacts-table th:nth-child(3) { width: 15%; }  /* E-mail */
  #contacts-table th:nth-child(4) { width: 8%; }   /* Público */
  #contacts-table th:nth-child(5) { width: 12%; }  /* Especialidade / CRM */
  #contacts-table th:nth-child(6) { width: 7%; }   /* Temperatura */
  #contacts-table th:nth-child(7) { width: 5%; }   /* Exame */
  #contacts-table th:nth-child(8) { width: 10%; }  /* Atendente */
  #contacts-table th:nth-child(9) { width: 5%; }   /* Atend. */
  #contacts-table th:nth-child(10) { width: 10%; } /* Último contato */
  /* "em aberto" vai para baixo da data em vez de alargar a última coluna */
  #contacts-table td:nth-child(10) small { display: block; color: var(--warn); font-size: 0.6875rem; line-height: 1.2; }
  /* Lista longa rola dentro de uma área com a altura da tela e cabeçalho fixo */
  .table-wrap:has(#contacts-table) { max-height: calc(100vh - 160px); overflow: auto; }
  #contacts-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
}
/* Entre celular e notebook pequeno (até 1300px) a tabela de 10 colunas também vira cartões */
@media (max-width: 1300px) {
  #contacts-table, #contacts-table tbody { display: block; width: 100%; }
  #contacts-table thead { display: none; }
  #contacts-table tr {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: var(--s2) var(--s3);
    padding: var(--s3) 0; border-bottom: 1px solid var(--line);
  }
  #contacts-table td { display: flex; flex-direction: column; gap: 1px; min-width: 0; max-width: none; padding: 0; border: 0; text-align: left; white-space: normal; overflow: visible; overflow-wrap: anywhere; }
  #contacts-table td::before { content: attr(data-label); color: var(--muted); font-size: 0.6875rem; letter-spacing: .02em; text-transform: uppercase; }
  #contacts-table td:first-child { grid-column: 1 / -1; font-family: var(--font-display); font-weight: 600; font-size: 0.9375rem; color: var(--heading); }
  #contacts-table td:first-child::before, #contacts-table td.empty::before { content: none; }
  #contacts-table td.empty { grid-column: 1 / -1; }
}
#contacts-table strong.ok { color: var(--good); font-weight: 500; }
.segmented--sm button { padding: 4px 12px; font-size: 0.8125rem; }

/* Piloto (Temas): aviso de teste e lista de resumos */
.pilot-banner {
  margin: 0 0 var(--s5); padding: var(--s4) var(--s5); border-radius: 18px; font-size: 0.875rem; line-height: 1.55;
  background: color-mix(in srgb, #f5b400 14%, var(--surface)); border: 1px dashed color-mix(in srgb, #f5b400 60%, transparent); color: var(--ink);
}
.pilot-examples { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.pilot-examples li { background: var(--paper); border-radius: 14px; padding: var(--s3) var(--s4); font-size: 0.875rem; }
.pilot-examples p { margin-top: var(--s2); color: var(--ink); }
.ex-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.ex-tags .tag { font-size: 0.6875rem; padding: 2px 8px; }
/* ---------- Relatório do mês (tela + impressão A4) ---------- */
body.report-page { background: var(--paper); padding: var(--s5) var(--s4) var(--s7); }
.report-toolbar { max-width: 210mm; margin: 0 auto var(--s4); display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; font-size: 0.875rem; }
.report-toolbar input[type="month"] { border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 6px 12px; font: inherit; }
.report-check { display: flex; gap: 6px; align-items: center; }
.report { max-width: 210mm; margin: 0 auto; background: #fff; color: #2c2c2c; padding: 14mm; border-radius: 10px; box-shadow: var(--shadow); font-size: 10pt; line-height: 1.45; }
.report h1 { font-size: 20pt; color: #111; }
.report h2 { font-size: 13pt; color: #111; margin: 6mm 0 3mm; padding-top: 3mm; border-top: 1px solid #e4e3ec; }
.report h2 small { font-size: 9pt; font-weight: 400; color: #6b6b78; margin-left: 6px; }
.report h3 { font-size: 10pt; color: #111; margin: 3mm 0 2mm; }
.report-head { display: flex; gap: 6mm; align-items: center; }
.report-meta { color: #6b6b78; font-size: 8.5pt; }
.report-bar { height: 4px; border-radius: 2px; background: var(--brand-gradient); margin: 4mm 0; }
.report .change-note { margin: 0 0 3mm; box-shadow: none; background: #f5f5f9; color: #2c2c2c; font-size: 9.5pt; max-width: none; }
.r-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(38mm, 1fr)); gap: 3mm; }
.r-kpi { background: #f5f5f9; border-radius: 8px; padding: 2.5mm 3mm; display: grid; gap: 1px; }
.r-kpi span { font-size: 8pt; color: #6b6b78; }
.r-kpi b { font-family: var(--font-display); font-size: 15pt; color: #111; }
.r-kpi em { font-style: normal; font-size: 8pt; color: #6b6b78; }
.r-delta { font-size: 8pt; } .r-delta.up { color: #198754; } .r-delta.down { color: #c2453f; }
.r-chart { width: 100%; height: auto; } .r-chart text { font-size: 9px; fill: #6b6b78; }
.r-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; margin-top: 2mm; }
.r-list ol { margin: 0; padding-left: 1.2em; display: grid; gap: 1.2mm; font-size: 8.8pt; }
.r-list li span { display: inline-block; max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.r-list li b { float: right; }
.r-list li small { display: block; color: #6b6b78; font-size: 7.5pt; }
.r-table { width: 100%; border-collapse: collapse; font-size: 8.8pt; }
.r-table th, .r-table td { text-align: left; padding: 1.4mm 2mm; border-bottom: 1px solid #e4e3ec; }
.r-table th { color: #6b6b78; font-weight: 500; }
.r-empty { color: #6b6b78; }
.report-foot { margin-top: 5mm; font-size: 7.5pt; color: #6b6b78; }
.r-sec { break-inside: auto; } .r-cols, .r-kpis, .r-table, .r-chart { break-inside: avoid; }
@media print {
  @page { size: A4; margin: 10mm; }
  body.report-page { background: #fff; padding: 0; }
  .no-print { display: none !important; }
  .report { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
  .report * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Modo TV ---------- */
body.tv { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; padding: 2vh 3vw; gap: 2vh; background: var(--paper); overflow: hidden; }
.tv-top { display: flex; align-items: center; gap: 2vw; }
.tv-top .logo { height: 5vh; min-height: 32px; }
.tv-top h1 { font-size: clamp(1.5rem, 3.4vw, 3.5rem); flex: 1; }
.tv-right { display: flex; align-items: center; gap: var(--s3); }
#tv-clock { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.25rem, 2.4vw, 2.5rem); color: var(--heading); }
.tv-slide { display: grid; align-content: center; }
.tv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2vw; }
.tv-grid--2 { grid-template-columns: repeat(2, 1fr); }
.tv-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: 3vw; align-items: center; }
.tv-kpi { background: var(--surface); border-radius: 28px; padding: 3vh 2vw; display: grid; gap: 1vh; box-shadow: var(--shadow); }
.tv-label { font-family: var(--font-display); font-size: clamp(0.9rem, 1.4vw, 1.5rem); color: var(--muted); }
.tv-value { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.5rem, 6vw, 7rem); line-height: 1; color: var(--heading); }
.tv-hint { color: var(--muted); font-size: clamp(0.8rem, 1.1vw, 1.25rem); }
.tv-kpi.good .tv-value { color: var(--good); }
.tv-kpi.warn .tv-value, .tv-table td.warn { color: var(--warn); }
.tv-chart, .tv-list { background: var(--surface); border-radius: 28px; padding: 3vh 2vw; box-shadow: var(--shadow); }
.tv-bars { width: 100%; height: 30vh; margin-top: 2vh; }
.tv-bars rect { fill: var(--cv-fill); }
.tv-bar-labels { display: flex; justify-content: space-around; color: var(--muted); font-size: clamp(0.8rem, 1vw, 1.1rem); }
.tv-list ol { margin: 2vh 0 0; padding-left: 1.4em; display: grid; gap: 1.5vh; font-size: clamp(1rem, 1.6vw, 1.8rem); color: var(--ink); }
.tv-list li { display: flex; justify-content: space-between; gap: 1em; }
.tv-list li b { color: var(--mkt); }
.tv-table { width: 100%; border-collapse: collapse; font-size: clamp(1rem, 1.8vw, 2rem); background: var(--surface); border-radius: 28px; overflow: hidden; box-shadow: var(--shadow); }
.tv-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.6em; padding: 2vh 2vw; }
.tv-table td { padding: 1.6vh 2vw; border-top: 1px solid var(--line); color: var(--heading); font-family: var(--font-display); }
.tv-empty { font-size: clamp(1.5rem, 3vw, 3rem); color: var(--muted); text-align: center; }
.tv-bottom { display: flex; align-items: center; gap: 2vw; color: var(--muted); font-size: clamp(0.8rem, 1vw, 1.1rem); }
.tv-dots { display: flex; gap: 8px; }
.tv-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.tv-dots i.on { background: var(--mkt); }
.tv-progress { flex: 1; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.tv-progress span { display: block; height: 100%; width: 0; background: var(--brand-gradient); }
@media (max-width: 900px) { .tv-grid, .tv-split { grid-template-columns: 1fr 1fr; } body.tv { overflow: auto; } }

/* "O que mudou" no painel: faixa de cartões; a cor da borda indica a origem do dado */
.changes { margin: 0 0 var(--s6); }
.changes[hidden] { display: none; }
.changes-head { display: flex; align-items: baseline; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.changes-head h2 { font-size: 1.125rem; }
.changes-sub { color: var(--muted); font-size: 0.8125rem; }
.changes-list {
  list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3);
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.6fr);
}
.chg {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: var(--s4) var(--s4) var(--s3); border-radius: 20px;
  background: var(--surface); box-shadow: var(--shadow); border-top: 3px solid var(--accent);
}
.chg--mkt { --accent: var(--mkt); }
.chg--cv { --accent: var(--cv-fill); }
.chg-label { font-size: 0.8125rem; color: var(--muted); line-height: 1.35; }
.chg-value { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; line-height: 1.2; color: var(--heading); }
.chg-value--text { font-size: 1rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--mkt); }
.chg-foot { margin-top: auto; padding-top: var(--s2); }
.chg-delta { display: inline-block; font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--paper); color: var(--muted); }
.chg-delta.up { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.chg-delta.down { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
@media (max-width: 1100px) { .changes-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } .chg--wide { grid-column: 1 / -1; } }
@media (max-width: 640px) { .chg { padding: var(--s3); } .chg-value { font-size: 1.25rem; } }

/* "O que mudou" no relatório mensal (texto) */
.change-note {
  margin: -16px 0 var(--s5); padding: var(--s3) var(--s4); border-radius: 14px; max-width: 980px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink); font-size: 0.9375rem; line-height: 1.55;
  border-left: 4px solid; border-image: var(--brand-gradient) 1;
}
.change-note[hidden] { display: none; }

/* Fila de retomada */
.followups { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); }
.fu { background: var(--paper); border-radius: 16px; padding: var(--s3) var(--s4); font-size: 0.875rem; display: grid; gap: 6px; }
.fu--done { opacity: .6; }
.fu-head { display: flex; flex-wrap: wrap; gap: 4px; }
.fu-head .tag { font-size: 0.6875rem; padding: 2px 8px; }
.fu-who { color: var(--ink); }
.fu-who a { color: var(--cv); }
.fu-topic { color: var(--muted); font-size: 0.8125rem; }
.fu-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: 2px; }
.tag--ok { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.pilot-filters { margin: var(--s4) 0 var(--s5); }
.pilot-filters .btn[hidden] { display: none; }
.ranked li.clickable { cursor: pointer; border-radius: 8px; }
.ranked li.clickable:hover .label { color: var(--cv); text-decoration: underline; }
.ex-sub { font-weight: 500; color: var(--heading); }
#ex-count { font-size: 0.875rem; font-weight: 400; color: var(--muted); }
.tag--warn { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.nav-pill--test::after { content: 'teste'; margin-left: 4px; font-size: 0.625rem; padding: 1px 5px; border-radius: 6px; background: #f5b400; color: #2c2c2c; }

/* Botão "?" de ajuda e balão (help.js) */
.help {
  display: inline-grid; place-items: center; width: 16px; height: 16px; padding: 0; margin-left: 2px;
  border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted);
  font: 600 10px/1 var(--font-display); cursor: help; vertical-align: 1px;
}
.help:hover, .help:focus-visible { color: var(--on-accent); background: var(--mkt); border-color: var(--mkt); }
.help-tip {
  position: fixed; z-index: 50; max-width: min(300px, calc(100vw - 16px)); padding: 10px 12px; border-radius: 12px;
  background: var(--heading); color: var(--surface); font: 400 0.8125rem/1.45 var(--font-body);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); pointer-events: none;
}
.help-tip[hidden] { display: none; }

/* Atalhos Contatos/Admin: pílula com contorno roxo, mais visível que um link */
.nav-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-weight: 600; font-size: 0.8125rem; text-decoration: none;
  color: var(--mkt); background: var(--mkt-soft); border: 1px solid color-mix(in srgb, var(--mkt) 35%, transparent);
}
.nav-pill:hover { background: var(--mkt); color: var(--on-accent); }
.nav-pill[hidden] { display: none; }
.nav-pill svg { width: 16px; height: 16px; flex: none; }
.nav-pill[aria-current="page"] { background: var(--mkt); color: var(--on-accent); }
.user-chip { font-size: 0.8125rem; color: var(--muted); text-decoration: none; padding: 0 var(--s2); }
.user-chip:hover { color: var(--mkt); }

/* ---------- Login (mesmo herói da home: etiqueta, título com degradê e pontos) ---------- */
.btn--ghost { background: var(--paper); color: var(--ink); }
.btn--block { display: block; width: 100%; padding: 12px 20px; font-size: 0.9375rem; }
.logout { margin: 0; }

.login-page {
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 12% 62%, rgba(129, 105, 241, 0.55) 0 3px, transparent 4px),
    radial-gradient(circle at 38% 78%, rgba(2, 179, 225, 0.5) 0 2px, transparent 3px),
    radial-gradient(circle at 46% 34%, rgba(164, 76, 238, 0.45) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 82%, rgba(255, 132, 127, 0.5) 0 3px, transparent 4px),
    radial-gradient(600px 400px at 92% 4%, rgba(129, 105, 241, 0.12), transparent 70%),
    radial-gradient(500px 360px at 0% 40%, rgba(2, 179, 225, 0.08), transparent 70%);
}
/* Desktop: herói à esquerda e cartão estreito à direita */
/* Mesma largura do sistema interno (1440px) e espaçamento vertical pela altura da tela,
   para login + cartões caberem numa página em notebook */
.login {
  max-width: 1440px; margin: 0 auto;
  padding: clamp(var(--s4), 3.5vh, var(--s7)) clamp(var(--s4), 4vw, var(--s7));
  /* Proporcional à tela: o bloco ocupa ~90% da largura (até 1280px), texto 3/5 e login 2/5.
     Tudo escala junto, em vez de larguras fixas que sobravam ou faltavam */
  /* Bloco contido (até 1080px): em monitor grande não cresce mais. O login fica entre
     300 e 360px e o texto ocupa o resto */
  width: min(1080px, 90vw); box-sizing: border-box; padding-left: 0; padding-right: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: clamp(var(--s5), 4vw, var(--s7)); align-items: center;
}
.login-hero .tag { margin-bottom: var(--s4); }
.login-hero h1 { font-size: clamp(1.75rem, 2.6vw, 2.5rem); font-weight: 600; line-height: 1.2; max-width: 20ch; }
.login-lead { font-size: 1rem; }
.login-lead { margin-top: var(--s5); font-size: 1.0625rem; max-width: 46ch; }
.login-sources { list-style: none; margin: var(--s6) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.login-source {
  font-family: var(--font-display); font-weight: 600; font-size: 0.8125rem;
  padding: 6px 14px; border-radius: var(--radius-pill);
}
.login-source--mkt { color: var(--mkt); background: var(--mkt-soft); }
.login-source--cv { color: var(--cv); background: var(--cv-soft); }

/* Topo do login: volta ao site + tema */
.login-top-actions { display: flex; align-items: center; gap: var(--s3); }

/* Bloco informativo abaixo do login */
/* Mesma largura do bloco texto + login acima, para tudo ficar alinhado */
.login-info { width: min(1080px, 90vw); padding-left: 0 !important; padding-right: 0 !important; margin: 0 auto; padding: 0 clamp(var(--s4), 4vw, var(--s7)) var(--s5); }
.login-info h2 { font-size: clamp(1.125rem, 1.6vw, 1.375rem); margin-bottom: var(--s4); }
.info-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
/* Cartão compacto: ícone ao lado do título, texto curto embaixo */
.info-card { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: var(--s4) var(--s5);
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--s3); align-items: center; }
.info-card h3 { margin: 0; font-size: 1rem; }
.info-card p { grid-column: 1 / -1; margin-top: var(--s2); }
.info-card p { font-size: 0.875rem; line-height: 1.55; }
.info-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; }
.info-icon svg { width: 22px; height: 22px; }
.info-icon--mkt { color: var(--mkt); background: var(--mkt-soft); }
.info-icon--cv { color: var(--cv); background: var(--cv-soft); }
.info-icon--both { color: #fff; background: var(--brand-gradient); }
.info-icon--lock { color: var(--ink); background: var(--paper); }
.login-footer {
  display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); justify-content: center; text-align: center;
  padding: var(--s4) var(--s4) var(--s5); font-size: 0.8125rem; color: var(--muted); border-top: 1px solid var(--line);
}
.login-footer a { color: var(--mkt); text-decoration: none; }
@media (max-width: 560px) {
  .login-top-actions .nav-pill { padding: 6px 10px; font-size: 0.75rem; }
  .login-info { padding-bottom: var(--s6); }
}

.login-card {
  /* Ocupa a coluna dele (300–360px); espaçamento fixo, não cresce com a tela */
  width: 100%; max-width: 360px; justify-self: end;
  background: var(--surface); border-radius: var(--radius-panel); box-shadow: var(--shadow);
  padding: var(--s5);
}
.login-card h2 { font-size: 1.375rem; margin-bottom: var(--s4); }
.login-form { display: grid; gap: 6px; }
.login-form label { font-family: var(--font-display); font-weight: 600; font-size: 0.8125rem; color: var(--ink); }
.login-form input {
  width: 100%; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-pill);
  padding: 0 18px; background: var(--paper); color: var(--ink); margin-bottom: var(--s2);
  font-size: 1rem; /* 16px evita o zoom automático do iOS */
}
.login-form input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px var(--mkt-soft); }
.login-form .btn { margin-top: var(--s2); height: 46px; padding: 0 20px; }
.login-error {
  margin-bottom: var(--s4); padding: var(--s3) var(--s4); border-radius: 14px;
  background: rgba(212, 84, 78, 0.1); color: var(--warn); font-size: 0.875rem;
}
.login-error--info { background: var(--tag-bg); color: var(--ink); }
.login-error[hidden] { display: none; }
.login-help { margin-top: var(--s4); font-size: 0.8125rem; line-height: 1.5; color: var(--muted); text-align: center; }

/* Tablet: uma coluna centralizada, cartão com largura fixa */
@media (max-width: 1024px) {
  .login { grid-template-columns: 1fr; max-width: 560px; gap: var(--s6); padding-top: var(--s7); text-align: center; }
  .login-hero h1 { font-size: clamp(1.875rem, 4.6vw, 2.5rem); max-width: 20ch; margin: 0 auto; }
  .login-lead { margin-left: auto; margin-right: auto; font-size: 1rem; }
  .login-sources { justify-content: center; margin-top: var(--s5); }
  .login-card { justify-self: center; max-width: 400px; text-align: left; }
}

/* Celular: herói compacto para o formulário caber na primeira tela */
@media (max-width: 560px) {
  .login-page .topbar { padding: var(--s3) var(--s4); }
  .login-page .logo { height: 36px; }
  .login { padding: var(--s5) var(--s4) var(--s6); gap: var(--s5); }
  .login-hero .tag { margin-bottom: var(--s3); font-size: 0.8125rem; }
  .login-hero h1 { font-size: 1.5rem; line-height: 1.3; }
  .login-lead, .login-sources { display: none; }
  .login-card { padding: var(--s5); border-radius: 22px; }
  .login-card h2 { font-size: 1.25rem; margin-bottom: var(--s3); }
  .login-form input { height: 42px; padding: 0 16px; }
  .login-form .btn { height: 44px; }
}

/* ---------- Quadro de retornos (retornos.html) ---------- */
.board-page { max-width: 1600px; }
.board-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.board-bar-label { font-size: 0.8125rem; color: var(--muted); }
.segmented button[hidden] { display: none; }
.board-bar .segmented { flex-wrap: wrap; max-width: 100%; border-radius: 18px; }
.board-select select, .board-search input {
  border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 6px 14px; background: var(--surface);
  font-size: 0.8125rem; color: var(--ink);
}
.board-search { flex: 1 1 220px; }
.board-search input { width: 100%; }
.board-check { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--muted); cursor: pointer; }
.board-summary { color: var(--muted); font-size: 0.8125rem; margin: var(--s2) 0 var(--s4); line-height: 1.5; }

/* Colunas: 4 lado a lado na prioridade; nos outros agrupamentos, rolagem lateral só dentro do quadro */
.board { display: grid; gap: var(--s3); align-items: start; }
.board--prioridade { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board--atendente, .board--temperatura { grid-auto-flow: column; grid-auto-columns: minmax(270px, 1fr); overflow-x: auto; padding-bottom: var(--s2); }
.board.loading { opacity: .55; }
.bcol { background: var(--paper); border-radius: 20px; border-top: 4px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.bcol--late { border-top-color: var(--warn); }
.bcol--today { border-top-color: #f0a020; }
.bcol--todo { border-top-color: var(--line); }
.bcol--later, .bcol--cold { border-top-color: var(--good); }
.bcol--hot { border-top-color: var(--warn); }
.bcol--warm { border-top-color: #f0a020; }
.bcol--cold { border-top-color: var(--cv-fill); }
.bcol-head { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s2); padding: var(--s3) var(--s4) var(--s2); }
.bcol-head h3 { margin: 0; font-size: 0.9375rem; }
.bcol-n { font-family: var(--font-display); font-weight: 700; color: var(--heading); }
.bcol-head p { grid-column: 1 / -1; font-size: 0.75rem; color: var(--muted); line-height: 1.4; }
.bcol-list { list-style: none; margin: 0; padding: var(--s2); display: grid; gap: var(--s2); max-height: 70vh; overflow-y: auto; }
.bcol-empty { color: var(--muted); font-size: 0.8125rem; padding: var(--s3); text-align: center; }
.bcol-more { margin: 0 var(--s2) var(--s2); }

/* Cartão: borda esquerda = aquecimento */
.rcard {
  display: flex; flex-direction: column; gap: 1px; width: 100%; text-align: left; cursor: pointer;
  padding: var(--s3); border: 0; border-left: 4px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 0.8125rem; line-height: 1.45;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.rcard:hover { box-shadow: 0 4px 14px rgba(72, 46, 224, 0.14); }
.rcard--hot { border-left-color: var(--warn); }
.rcard--warm { border-left-color: #f0a020; }
.rcard--cold { border-left-color: var(--cv-fill); }
.rcard-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.rcard-n { color: var(--muted); font-size: 0.75rem; }
.rcard-name { font-family: var(--font-display); font-weight: 600; font-size: 0.9375rem; color: var(--heading); overflow-wrap: anywhere; }
.rcard-phone { color: var(--muted); }
.rcard-cat { font-weight: 500; }
.rcard-foot { display: flex; justify-content: space-between; color: var(--muted); margin-top: 2px; }
.rcard-al { color: #c77d00; font-weight: 500; }
.rcard-alert { color: var(--warn); font-size: 0.75rem; }
.temp { display: inline-block; font-size: 0.6875rem; font-weight: 500; padding: 1px 8px; border-radius: var(--radius-pill); background: var(--paper); color: var(--muted); }
.temp--hot { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.temp--warm { color: #c77d00; background: color-mix(in srgb, #f0a020 14%, transparent); }
.temp--cold { color: var(--cv); background: var(--cv-soft); }
.st { color: var(--muted); }
.st--late { color: var(--warn); font-weight: 500; }
.st--today { color: #c77d00; font-weight: 500; }
.st--later { color: var(--good); font-weight: 500; }

/* Detalhe do cartão */
.card-dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 0; border-radius: 24px; padding: var(--s5);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.card-dialog::backdrop { background: rgba(19, 17, 28, 0.45); }
.dlg-close { position: absolute; top: var(--s3); right: var(--s3); }
.dlg-tags { display: flex; gap: var(--s2); align-items: center; font-size: 0.8125rem; margin-bottom: var(--s2); }
.card-dialog h2 { font-size: 1.375rem; padding-right: var(--s6); }
.dlg-phone { color: var(--muted); margin-bottom: var(--s3); }
.dlg-links { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.dlg-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s2) var(--s4); margin: 0 0 var(--s3); font-size: 0.8125rem; }
.dlg-facts dt { color: var(--muted); font-size: 0.75rem; }
.dlg-facts dd { margin: 0; color: var(--ink); }
.dlg-alerts { list-style: none; margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: 12px; font-size: 0.8125rem; color: var(--warn); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.dlg-form { border-top: 1px solid var(--line); padding-top: var(--s4); display: grid; gap: var(--s3); }
.dlg-form h3 { margin: 0; }
.dlg-result { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.dlg-result legend { font-size: 0.8125rem; color: var(--muted); margin-bottom: var(--s2); padding: 0; }
.dlg-result label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-pill); background: var(--paper); font-size: 0.8125rem; cursor: pointer; }
.dlg-result label:has(input:checked) { background: var(--mkt); color: var(--on-accent); }
.dlg-result input { accent-color: var(--mkt); }
.dlg-next { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.dlg-next[hidden] { display: none; }
.dlg-label { font-size: 0.8125rem; color: var(--muted); width: 100%; }
.dlg-note { display: grid; gap: 4px; font-size: 0.8125rem; color: var(--muted); }
.dlg-note textarea { font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; resize: vertical; }
.dlg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.dlg-actions .btn[hidden] { display: none; }

@media (max-width: 1100px) { .board--prioridade { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .board--prioridade { grid-template-columns: 1fr; }
  .bcol-list { max-height: 60vh; }
  .card-dialog { padding: var(--s4); }
}
