:root { --ink: #1f2933; --muted: #52606d; --line: #d9e2ec; --brand: #1f5f8b; --bg: #f7f9fb; --mark: #36443f; }
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--brand); text-decoration: none; letter-spacing: 0.02em; }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar a { color: var(--ink); text-decoration: none; }
.container { max-width: 56rem; margin: 0 auto; padding: 1.5rem 1rem; }
.inline { display: inline; }
button.link { background: none; border: 0; padding: 0; color: var(--ink); cursor: pointer; font: inherit; }
.form { display: grid; gap: 0.5rem; }
.form.narrow { max-width: 22rem; }
.form label { font-weight: 600; margin-top: 0.5rem; }
.form input { padding: 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.form button[type=submit] { margin-top: 0.75rem; padding: 0.7rem; background: var(--brand); color: #fff; border: 0; border-radius: 6px; font: inherit; cursor: pointer; }
/* Sem esta regra, a de cima (mais específica) pintava de primário todo botão secundário de formulário. */
.form button[type=submit].secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.error { color: #b42318; }
.list { list-style: none; padding: 0; }
.list li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
dl dt { font-weight: 600; color: var(--muted); margin-top: 0.5rem; }
dl dd { margin: 0; }
.messages { list-style: none; padding: 0; }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row input[type=search] { flex: 1 1 14rem; width: auto; }
.button, .button-link { display: inline-block; padding: 0.55rem 0.9rem; border-radius: 6px; text-decoration: none; font: inherit; }
.button { background: var(--brand); color: #fff; }
.button.secondary, button.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.button-link { color: var(--muted); }
button { font: inherit; }
/* Botão sem classe é ação principal. :where() zera a especificidade: regras de contexto vencem. */
:where(button:not(.link):not(.secondary)) { padding: 0.55rem 0.9rem; background: var(--brand); color: #fff; border: 0; border-radius: 6px; cursor: pointer; }
:where(button:disabled) { opacity: 0.5; cursor: not-allowed; }
button.secondary { padding: 0.55rem 0.9rem; border-radius: 6px; cursor: pointer; }
button.link.danger { color: #b42318; }
.table { width: 100%; border-collapse: collapse; margin: 0.5rem 0 1rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin: 1rem 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.warning { background: #fff4d6; border: 1px solid #f0c36d; padding: 0.6rem 0.9rem; border-radius: 8px; }
dl.compact dt { margin-top: 0.4rem; }
textarea, select, input[type=text], input[type=search], input[type=number], input[type=email], input[type=date] { padding: 0.55rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; width: 100%; max-width: 100%; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.issues li { margin: 0.3rem 0; }
.issues code, pre.code { background: #f0f4f8; border-radius: 4px; }
pre.code { padding: 1rem; overflow: auto; font-size: 0.85rem; }
label.check { display: flex; gap: 0.5rem; align-items: center; font-weight: 400; }
.answers li { margin: 0.6rem 0; }
.answers .q { color: var(--muted); }
svg.evolution { width: 100%; height: auto; }
svg.evolution text { font-size: 13px; fill: var(--muted); }
svg.evolution .grid { stroke: #ebefec; }
svg.evolution .axis { stroke: #d2ddd7; }
svg.evolution .tick, svg.evolution .date { font-size: 12px; fill: #8b9791; }
svg.evolution .area { fill: var(--brand); opacity: 0.07; }
svg.evolution .line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
svg.evolution .point { fill: #fff; stroke: var(--brand); stroke-width: 2.25; }
svg.evolution .point.last { fill: var(--brand); }
svg.evolution .last-value { font-size: 15px; font-weight: 650; fill: var(--ink); }
svg.evolution .version { stroke: #ccd8d1; stroke-dasharray: 3 4; }
svg.evolution .version-label { font-size: 11px; fill: #97a29d; }
svg.evolution .milestone .trace { stroke: var(--mark); stroke-width: 1; opacity: 0.16; stroke-dasharray: 2 5; }
svg.evolution .milestone .stem { stroke: #c3d0c9; stroke-width: 1; }
/* `.mark` não tem transform próprio: o aumento no celular gira em torno do próprio chip,
   que o grupo de fora já posicionou. */
svg .pill { fill: #fff; stroke: #c3d0c9; stroke-width: 1; }
svg .icon { fill: none; stroke: var(--mark); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
svg .icon.solid { fill: var(--mark); stroke: none; }
svg.evolution .number, .mark-badge .number { fill: var(--mark); font-size: 12.5px; font-weight: 700; }
.mark-badge { vertical-align: -5px; flex-shrink: 0; }
.empty-chart { color: var(--muted); font-style: italic; }
.messages li.success { color: #1a7f37; }
.messages li.error { color: #b42318; }
img.qr { width: 14rem; height: 14rem; image-rendering: pixelated; background: #fff; }
code.secret { word-spacing: 0.3rem; font-size: 1rem; }
ol.codes { columns: 2; max-width: 22rem; font-size: 1.1rem; }

/* Área clínica: hierarquia, navegação e componentes compartilhados. */
.workspace { --ink: #203c39; --muted: #5e716d; --line: #dde6e1; --brand: #216557; --bg: #f5f7f4; }
.workspace a { text-underline-offset: 4px; }
.workspace a:not(.button):not(.brand):not(.metric-card):not(.ao-vivo):not(.aviso-acao):not(.ajustes-cartao):not(.sessao-nome) { color: var(--brand); }
.workspace .topbar { min-height: 84px; padding: 1rem max(1.5rem, calc((100vw - 1160px) / 2)); gap: 2rem; }
.workspace .brand { display: inline-flex; align-items: center; gap: 0; font-size: 1.05rem; letter-spacing: .05em; white-space: nowrap; }
.brand-light { font-weight: 400; }
.brand-symbol { display: grid; place-items: center; width: 38px; height: 38px; margin-right: 12px; border-radius: 12px; background: var(--brand); color: white; font: 700 28px Georgia, serif; letter-spacing: -.06em; }
/* Quebra em vez de estourar: a navegação cresceu para sete itens e, entre 760 e ~950px,
   a linha única empurrava o botão de sair para fora da tela. */
.workspace .topbar nav { gap: .35rem; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.workspace .topbar nav > a { padding: .65rem .85rem; border-radius: 8px; font-size: .9rem; }
.workspace .topbar nav > a[aria-current=page] { background: #e8f0eb; font-weight: 650; }
.workspace .topbar nav > a:hover { background: #f0f4f0; }
/* Quem está logado e o botão de sair ficam juntos: o nome leva a Minha conta. */
.workspace .topbar .sessao { display: flex; align-items: center; gap: .9rem; border-left: 1px solid var(--line); margin-left: .6rem; padding-left: 1rem; min-width: 0; }
.workspace .topbar .sessao-nome { font-size: .9rem; font-weight: 600; color: var(--ink); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.workspace .topbar .sessao-nome:hover { color: var(--brand); text-decoration: underline; }
.workspace .container { max-width: 1160px; padding: 2.8rem 1.5rem 4rem; }
.workspace h1 { font-size: clamp(1.7rem, 3vw, 2.25rem); line-height: 1.2; letter-spacing: -.04em; font-weight: 650; margin: 0 0 .7rem; overflow-wrap: anywhere; }
.workspace h2 { font-size: 1.3rem; letter-spacing: -.025em; line-height: 1.3; }
.workspace h3 { font-size: 1rem; margin-bottom: .5rem; }
.workspace .page-heading { margin-bottom: 1.7rem; gap: 1.5rem; }
.page-heading p { margin: .6rem 0 0; }
.workspace .eyebrow { font-size: .72rem; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 0 0 .8rem; }
.workspace .button, .workspace button:not(.link) { min-height: 44px; border-radius: 8px; padding: .65rem 1rem; font-weight: 600; font-size: .9rem; }
.workspace .button { border: 1px solid transparent; }
.workspace .button.secondary { border-color: var(--line); }
.workspace .button:hover, .workspace button:not(.link):hover { filter: brightness(.95); }
.workspace :focus-visible { outline: 3px solid #a56722; outline-offset: 4px; }
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin: 2rem 0; }
.metric-card { display: flex; flex-direction: column; padding: 1.7rem 1.8rem; background: white; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); text-decoration: none; }
.metric-card:hover { border-color: var(--brand); }
.metric-card.attention { background: #fcf8ee; border-color: #e8dbbb; }
.metric-value { font-size: 3.3rem; font-weight: 550; letter-spacing: -.05em; line-height: 1.1; margin: .2rem 0 .6rem; font-variant-numeric: tabular-nums; }
.metric-link { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1rem; font-size: .85rem; font-weight: 600; color: var(--brand); }
.workspace .card { border-radius: 12px; padding: 1.5rem; }
.workspace .next-step { display: flex; align-items: center; justify-content: space-between; gap: 2rem; background: #eaf1ec; border-color: #d9e5dc; padding: 1.8rem; }
.next-step h2 { margin: 0 0 .5rem; }
.next-step p:last-child { margin-bottom: 0; max-width: 44rem; }
.next-step .button { flex-shrink: 0; }
.workflow-section { margin-top: 2.8rem; }
.workflow-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; padding-top: 1rem; }
.workflow-grid > div { border-top: 1px solid var(--line); padding-top: 1.3rem; }
.workflow-grid p { font-size: .9rem; }
.workflow-grid a { font-size: .85rem; font-weight: 600; }
.step-number { font-size: .8rem; font-weight: 650; color: var(--brand); display: inline-grid; place-items: center; width: 34px; height: 34px; background: #e7eee8; border-radius: 50%; }
.search-panel { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin: 1.5rem 0; }
.workspace input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .workspace select, .workspace textarea { background: white; color: var(--ink); min-height: 44px; }
.workspace .form { max-width: 48rem; padding: 1.5rem; background: white; border: 1px solid var(--line); border-radius: 12px; }
.workspace .form.narrow { max-width: 28rem; }
.patient-list { background: white; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.patient-list li { padding: 0; }
.patient-list li:last-child { border-bottom: 0; }
.patient-list a { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; text-decoration: none; font-weight: 600; }
.patient-list a:hover { background: #f2f6f2; }
.patient-list a > span { overflow-wrap: anywhere; }
.patient-avatar { display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; background: #eaf0ec; }
.patient-open { margin-left: auto; font-size: .8rem; color: var(--muted); font-weight: 400; flex-shrink: 0; }
.empty-state { text-align: center; padding: 3.5rem 1.5rem; background: white; border: 1px dashed #c6d5cc; border-radius: 12px; margin: 1.5rem 0; }
.empty-state h2 { margin-top: .8rem; }
.table-scroll { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 12px; margin: 1.5rem 0; }
.table-scroll .table { margin: 0; }
.workspace .table th, .workspace .table td { padding: 1rem; }
.workspace .table th { background: #eff3ef; font-size: .8rem; }
.workspace .table tbody tr:last-child td { border-bottom: 0; }
.workspace .table tbody tr:hover { background: #f8faf7; }
.workspace .messages li { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: white; margin: .5rem 0; }
.skip-link { position: absolute; left: 1rem; top: -100px; background: white; padding: .8rem; z-index: 20; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 760px) {
  .workspace .topbar { position: relative; align-items: flex-start; flex-direction: column; gap: 1rem; padding: 1rem; }
  .workspace .topbar nav { width: 100%; flex-wrap: wrap; gap: .2rem; }
  .workspace .topbar nav > a { padding: .65rem .6rem; font-size: .82rem; }
  .workspace .topbar .sessao { position: absolute; top: 1rem; right: 1rem; margin: 0; padding: .6rem; border-left: 0; gap: .7rem; }
  .workspace .topbar .sessao-nome { max-width: 9rem; font-size: .82rem; }
  .workspace .container { padding: 1.8rem 1rem 3rem; }
  .overview-grid { gap: .8rem; }
  .metric-card { padding: 1.2rem; }
  .metric-value { font-size: 2.6rem; }
  .workspace .next-step { flex-direction: column; align-items: flex-start; gap: 1.2rem; padding: 1.3rem; }
  .workflow-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .patient-open { font-size: 0; }
  .patient-open span { font-size: 1.2rem; }
  .workspace .table th, .workspace .table td { padding: .8rem; min-width: 110px; }
}
@media (max-width: 420px) {
  .overview-grid { grid-template-columns: 1fr; }
  .workspace .topbar nav > a { padding-inline: .45rem; }
  .workspace .topbar .sessao-nome { max-width: 6.5rem; }
}

/* Fila de revisão e leitura de uma resposta. */
.block { display: block; }
.score-cell .score { display: block; margin: .1rem 0; }
.score-cell .score strong { font-variant-numeric: tabular-nums; }
details.technical { margin: 2.5rem 0 0; border-top: 1px solid var(--line); padding-top: 1rem; }
details.technical summary { color: var(--muted); font-size: .9rem; cursor: pointer; }
details.technical p, details.technical ul { max-width: 44rem; }
/* Paleta das séries: cores distintas, nenhuma sugerindo gravidade. O traço acompanha a cor,
   porque cor sozinha não informa quem não a distingue. */
.s1 { --serie: #216557; }
.s2 { --serie: #2f6f9f; }
.s3 { --serie: #7d5ba6; }
.s4 { --serie: #5c6f7e; }
.s5 { --serie: #8a6d3b; }
/* As regras de cor e traço valem para o gráfico e para a amostra da legenda, que é o mesmo
   desenho em miniatura: a legenda nunca pode divergir da linha que ela explica. */
.s1 .line, .s2 .line, .s3 .line, .s4 .line, .s5 .line { stroke: var(--serie); }
svg.evolution .serie .line { stroke: var(--serie); }
svg.evolution .serie .area { fill: var(--serie); }
svg.evolution .serie .point { stroke: var(--serie); }
svg.evolution .serie .point.last { fill: var(--serie); }
.s2 .line { stroke-dasharray: 8 4; }
.s3 .line { stroke-dasharray: 2 4; }
.s4 .line { stroke-dasharray: 12 4 2 4; }
.s5 .line { stroke-dasharray: 5 3 1 3; }
svg.evolution .point { transition: r .12s ease-out; }
svg.evolution .point:hover { r: 9px; }
svg.evolution .serie { transition: opacity .12s ease-out; }
/* Passar o mouse na legenda destaca aquela série e apaga as outras. */
.chart-view:has(.chart-legend li.s1:hover) .serie:not(.s1),
.chart-view:has(.chart-legend li.s2:hover) .serie:not(.s2),
.chart-view:has(.chart-legend li.s3:hover) .serie:not(.s3),
.chart-view:has(.chart-legend li.s4:hover) .serie:not(.s4),
.chart-view:has(.chart-legend li.s5:hover) .serie:not(.s5) { opacity: .15; }
.chart-legend { list-style: none; padding: 0; margin: .2rem 0 .8rem; display: flex; flex-wrap: wrap; gap: .4rem 1.5rem; }
.chart-legend li { display: flex; align-items: center; gap: .5rem; font-size: .9rem; flex-wrap: wrap; }
.chart-legend .swatch { flex-shrink: 0; }
.chart-legend .swatch .line { fill: none; stroke-width: 3; stroke-linecap: round; }
.chart-legend .legend-label { font-weight: 600; }
.chart-legend .legend-value { color: var(--muted); }
.chart-head { align-items: flex-start; gap: 1rem; }
.chart-switch { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.chart-switch label { color: var(--muted); }
.chart-switch select { width: auto; max-width: 16rem; }

/* Página do paciente: o que espera por mim, depois os números, depois os gráficos. */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: #e8eeea; color: var(--muted); font-size: .75rem; font-weight: 650; vertical-align: middle; }
.status-panel h2 { margin-top: 0; }
.pending-list { list-style: none; padding: 0; margin: 0 0 1.2rem; display: grid; gap: .5rem; }
.pending-list li { padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfb; }
.pending-list li.attention { background: #fcf8ee; border-color: #e8dbbb; }
.latest-value { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.chart-card h3 { font-size: 1.15rem; margin: 0; }
.chart-block { margin-top: 1.1rem; }
.chart-caption { margin: 0 0 .4rem; font-weight: 600; }
.values summary, .subscales summary { color: var(--muted); font-size: .9rem; cursor: pointer; padding: .5rem 0; }
.values .table-scroll { margin-top: .5rem; }
.subscales { border-top: 1px solid var(--line); margin-top: 1.6rem; padding-top: .4rem; }
.milestone-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .6rem; }
.milestone-list li { display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 1.2rem; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.marks-legend { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .3rem; }
.marks-legend summary { color: var(--muted); font-size: .9rem; cursor: pointer; padding: .5rem 0; }
.marks-legend ul { list-style: none; padding: 0; margin: .3rem 0 .6rem; display: grid; gap: .45rem; }
.marks-legend li { display: flex; align-items: center; gap: .6rem; font-size: .9rem; }
.milestone-body { flex: 1; }
.milestone-when { margin: 0; color: var(--muted); font-size: .85rem; }
.milestone-title { margin: .15rem 0 0; font-weight: 600; }
.card-actions { margin-top: 1.3rem; border-top: 1px solid var(--line); padding-top: 1rem; }

@media (max-width: 760px) {
  /* Toda tabela marcada como `stack-table` vira lista de cartões no celular: nada de rolar de
     lado para alcançar a ação, e cada valor carrega o rótulo que estava no cabeçalho. */
  .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
  .stack-table thead { display: none; }
  .stack-table tr { padding: 1rem; }
  .workspace .stack-table td { min-width: 0; padding: .1rem 0; border: 0; }
  .workspace .stack-table .lead { font-size: 1.05rem; font-weight: 650; }
  .workspace .stack-table .stack-action { margin-top: .8rem; }
  .stack-table .stack-action .button { display: block; text-align: center; }
  .stack-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
  /* O SVG encolhe com a tela e levaria a tipografia junto. Os tamanhos abaixo estão em
     unidades do viewBox: crescem conforme a escala cai, para o texto chegar legível na tela. */
  svg.evolution text { font-size: 16px; }
  svg.evolution .tick, svg.evolution .date { font-size: 15px; }
  svg.evolution .last-value { font-size: 21px; }
  svg.evolution .mark { scale: 1.25; }
}
@media (max-width: 480px) {
  svg.evolution text { font-size: 24px; }
  svg.evolution .tick, svg.evolution .date { font-size: 23px; }
  svg.evolution .last-value { font-size: 30px; }
  svg.evolution .mark { scale: 1.8; }
}
#navigation-status { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; max-width: min(600px, 90vw); padding: 12px 18px; border-radius: 9px; background: #203c39; color: white; box-shadow: 0 4px 22px #0002; font-size: 13px; }
#navigation-status[hidden] { display: none; }
#navigation-status.navigation-error { background: #703d28; }
.is-navigating::before { content: ''; position: fixed; inset: 0 0 auto; height: 3px; background: #216557; z-index: 110; }
#main-content:focus { outline: none; }
#navigation-status:not(.navigation-error) { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border-radius: 50%; }
#navigation-status[hidden] { display: none; }
.navigation-spinner { display: block; width: 22px; height: 22px; border: 2px solid #ffffff45; border-top-color: #fff; border-radius: 50%; animation: navigation-spin .7s linear infinite; }
@keyframes navigation-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .navigation-spinner { animation: none; border-style: dotted; } }
#unsaved-dialog { max-width: min(440px, 90vw); border: 1px solid var(--line); padding: 26px; border-radius: 14px; color: var(--ink); box-shadow: 0 16px 70px #0003; }
#unsaved-dialog::backdrop { background: #12282366; }
#unsaved-dialog h2 { margin-top: 0; }
#unsaved-dialog .row { margin-top: 24px; }

/* Paciente que este vínculo não acompanha: aparece na lista administrativa, sem virar link. */
.patient-row-flat { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; font-weight: 600; }
.patient-row-flat .muted { margin-left: auto; font-weight: 400; }

.metric-note { margin: .6rem 0 0; font-size: .9rem; }

/* ---------- Atendimento ---------- */
.encounter-header { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; }
.encounter-header h1 { margin-bottom: .2rem; }
.encounter-state { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.encounter-list { list-style: none; margin: .8rem 0 0; padding: 0; }
.encounter-list li { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; padding: .9rem 0; border-top: 1px solid var(--line); }
.encounter-list li:first-child { border-top: 0; }
.encounter-list .quando { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 9rem; }
.encounter-list .quem { flex: 1 1 14rem; min-width: 0; }
.encounter-list .quem strong { display: block; }
.encounter-list .quem span { display: block; }
.encounter-list .button { margin-left: auto; }
.etiqueta { display: inline-block; padding: .12rem .5rem; border-radius: 6px; font-size: .75rem; font-weight: 650; border: 1px solid; white-space: nowrap; }
.etiqueta.rascunho { background: #fdf6e6; border-color: #e0cfa4; color: #7a5c1e; }
.etiqueta.final { background: #eef3ee; border-color: #cfdcd2; color: #33503f; }
.etiqueta.adendo { background: #eef1f6; border-color: #ccd5e2; color: #3a4a63; }
.nota-campo { margin-bottom: 1.1rem; }
.nota-campo label { display: block; font-weight: 650; font-size: .95rem; margin-bottom: .2rem; }
.nota-campo .ajuda { margin: 0 0 .35rem; color: var(--muted); font-size: .85rem; }
.workspace .encounter-form { max-width: 52rem; }
.encounter-actions { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 1px solid var(--line); }
.encounter-cancel { display: block; margin-top: 1.5rem; }
.registro-final { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.6rem 1.8rem; max-width: 46rem; margin-bottom: 1rem; }
.registro-final h3 { font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 1.3rem 0 .3rem; }
.registro-final h3:first-of-type { margin-top: 0; }
.registro-final p { margin: 0 0 .8rem; line-height: 1.65; white-space: pre-wrap; }
.registro-final .autoria { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.registro-final.adendo { border-left: 4px solid #7d8fb0; }
.patient-sections .section-link { font-weight: 650; }
@media (max-width: 760px) {
  .encounter-list li { align-items: flex-start; }
  .encounter-list .button { margin-left: 0; width: 100%; text-align: center; }
  .encounter-list .quando { min-width: 0; }
}

/* ---------- Avisos sobrepostos ----------
   Cartões escuros translúcidos no canto inferior: eles passam por cima do conteúdo, e vidro
   escuro deixa ver que há página embaixo em vez de fingir que o aviso é parte dela.

   Três cuidados que o vidro exige:
   - Fundo opaco como base. Onde não houver `backdrop-filter`, o cartão continua legível.
   - `prefers-reduced-transparency` desliga o efeito, como já fazem as barras persistentes.
   - Contraste medido sobre o fundo escuro, não sobre o desfoque: o texto é branco quase puro
     e as cores de estado são as claras da paleta, não as escuras usadas sobre branco. */
.avisos { position: fixed; z-index: 120; right: 1rem; bottom: 1rem; display: grid; gap: .55rem; width: min(26rem, calc(100vw - 2rem)); pointer-events: none; }
.aviso {
  pointer-events: auto;
  display: grid; grid-template-columns: auto 1fr auto; gap: .2rem .75rem; align-items: start;
  padding: .85rem 1rem;
  background: #16261f;
  color: #f2f6f3;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgb(8 20 15 / 38%);
  animation: aviso-entra .2s cubic-bezier(.2, .8, .3, 1);
}
.aviso-texto { margin: 0; color: #f2f6f3; font-size: .89rem; line-height: 1.5; overflow-wrap: anywhere; }
.aviso-sinal { width: 15px; height: 15px; margin-top: .2rem; border: 2px solid currentColor; border-radius: 50%; }
.aviso-fechar { align-self: start; padding: 0 .15rem; color: rgb(242 246 243 / 60%); font-size: 1.25rem; line-height: 1; }
.aviso-fechar:hover { color: #f2f6f3; }
/* A cor mora no cartão; o sinal a herda por `currentColor`. Estado é a forma do sinal —
   círculo cheio, quadrado, losango —, não uma tarja colorida na lateral. */
.aviso[data-tipo=info], .aviso[data-tipo=carregando] { color: #8fd3bd; }
.aviso[data-tipo=sucesso] { color: #7fd69a; }
.aviso[data-tipo=sucesso] .aviso-sinal { background: currentColor; }
.aviso[data-tipo=aviso] { color: #e8bd74; }
.aviso[data-tipo=aviso] .aviso-sinal { border-radius: 3px; }
.aviso[data-tipo=erro] { color: #f3a49b; }
.aviso[data-tipo=erro] .aviso-sinal { border-radius: 3px; transform: rotate(45deg); }
.aviso[data-tipo=carregando] .aviso-sinal { border-top-color: transparent; animation: navigation-spin .7s linear infinite; }
@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) {
  .aviso {
    background: rgb(20 34 28 / 72%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
  }
}
@keyframes aviso-entra { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  .aviso { animation: none; }
  .aviso[data-tipo=carregando] .aviso-sinal { animation: none; border-style: dotted; border-top-color: currentColor; }
}
@media (prefers-reduced-transparency: reduce) {
  .aviso { background: #16261f; -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (max-width: 760px) {
  .avisos { right: .5rem; left: .5rem; bottom: .5rem; width: auto; }
}

/* ---------- Atendimento em andamento ----------
   A forma diz o estado antes da cor: círculo com miolo pulsando enquanto a consulta está
   acontecendo; quadrado parado quando é um rascunho de outro dia esperando ser fechado. */
.ao-vivo { display: inline-flex; align-items: center; gap: .6rem; padding: .4rem .9rem .4rem .7rem; border: 1px solid #e7cdc7; border-radius: 999px; background: #fdf5f3; color: var(--ink); text-decoration: none; line-height: 1.25; }
.ao-vivo:hover { border-color: #d9b1a8; }
.ao-vivo .rec { display: grid; place-items: center; width: 17px; height: 17px; flex-shrink: 0; border: 2px solid #b42318; border-radius: 50%; }
.ao-vivo .rec::after { content: ''; width: 7px; height: 7px; background: #b42318; border-radius: 50%; }
.ao-vivo.gravando .rec::after { animation: rec-pulsa 1.5s ease-in-out infinite; }
.ao-vivo:not(.gravando) { border-color: #e0d3b4; background: #fdf9ef; }
.ao-vivo:not(.gravando) .rec { border-color: #8a6d3b; border-radius: 3px; }
.ao-vivo:not(.gravando) .rec::after { background: #8a6d3b; border-radius: 1px; }
.ao-vivo-texto { display: grid; }
.ao-vivo-texto strong { font-size: .82rem; }
.ao-vivo-detalhe { font-size: .76rem; color: var(--muted); }
@keyframes rec-pulsa { 0%, 100% { opacity: 1; } 50% { opacity: .1; } }
@media (prefers-reduced-motion: reduce) { .ao-vivo.gravando .rec::after { animation: none; } }
@media (max-width: 760px) { .ao-vivo { order: 3; width: 100%; } }

/* ---------- Cronologia de atendimentos ----------
   Mesmo desenho na aba do paciente e na página própria: são a mesma informação. */
.cronologia-bloco { padding: 1.2rem 0; border-top: 1px solid var(--line); }
.cronologia-bloco:first-child { border-top: 0; padding-top: .4rem; }
.cronologia-bloco > h3 { margin: 0 0 .3rem; font-size: 1rem; }
details.cronologia-bloco > summary { color: var(--muted); font-size: .9rem; cursor: pointer; padding: .4rem 0; }
.ultimo-registro { margin: 1.2rem 0; padding: 1.1rem 1.3rem; background: #eef3ef; border: 1px solid #d7e3da; border-radius: 12px; }
.ultimo-registro p { margin: .2rem 0; line-height: 1.6; }
.ultimo-registro .eyebrow { margin-bottom: .4rem; }
.aviso-acao { grid-column: 2; justify-self: start; margin-top: .4rem; color: currentColor; font-size: .85rem; font-weight: 600; text-underline-offset: 3px; }

/* Cronograma do acompanhamento de um paciente: marcos em ordem de tempo. */
.cronograma-linha { list-style: none; margin: 1rem 0 2rem; padding: 0 0 0 1.4rem; border-left: 2px solid var(--line); }
.cronograma-linha .marco { position: relative; padding: 0 0 1.4rem .9rem; }
.cronograma-linha .marco:last-child { padding-bottom: 0; }
.marco-ponto { position: absolute; left: calc(-1.4rem - .425rem); top: .35rem; width: .85rem; height: .85rem; border-radius: 50%; background: #fff; border: 2px solid var(--line); box-sizing: border-box; }
.marco-answered .marco-ponto { background: var(--brand); border-color: var(--brand); }
.marco-started .marco-ponto { background: #fff; border-color: var(--brand); box-shadow: inset 0 0 0 3px var(--brand); }
.marco-open .marco-ponto, .marco-ready .marco-ponto { background: #fff; border-color: #b45309; }
.marco-closed .marco-ponto { background: var(--line); border-color: var(--line); }
.marco-data { margin: 0; font-weight: 600; }
.marco-estado { font-weight: 400; color: var(--muted); font-size: .9rem; }
.marco-linhas, .marco-blocos { list-style: none; margin: .2rem 0 0; padding: 0; font-size: .92rem; }
.marco-blocos { margin-top: .3rem; color: var(--muted); }
.marco-blocos li { display: inline; }
.marco-blocos li + li::before { content: " · "; }

/* Ajustes: índice em cartões; cada página cuida de uma coisa só. */
.ajustes-grupo { margin: 2.2rem 0; }
.ajustes-grupo > h2 { margin-bottom: .3rem; }
.ajustes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.ajustes-cartao { display: flex; flex-direction: column; gap: .4rem; padding: 1.2rem 1.3rem; background: white; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.ajustes-cartao:hover { border-color: var(--brand); }
.ajustes-cartao .muted { font-size: .9rem; }
.ajustes-estado { margin-top: auto; padding-top: .4rem; font-size: .82rem; font-weight: 600; color: var(--brand); overflow-wrap: anywhere; }
.ajustes-estado.atencao { color: #8a5a00; }
.ajustes-colunas { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.25rem; align-items: start; margin-bottom: 2rem; }
.ajustes-colunas > .card, .ajustes-colunas > .form { margin: 0; max-width: none; }
.ajustes-colunas h2, .form > h2 { margin: 1.6rem 0 .2rem; }
.ajustes-colunas h2:first-of-type, .form > h2:first-of-type { margin-top: 0; }
.ajustes-colunas dd { overflow-wrap: anywhere; }
.previa-assinatura { padding: .8rem 1rem; background: #f3f6f3; border-radius: 8px; overflow-wrap: anywhere; }
/* Ficha com grupos de campos: cada grupo se reparte em colunas quando há largura. */
.form.ficha { max-width: 56rem; }
.form fieldset { border: 0; padding: 0; margin: 1.2rem 0 0; min-width: 0; }
.form fieldset:first-of-type { margin-top: 0; }
.form legend { font-weight: 650; font-size: 1.05rem; padding: 0; margin-bottom: .1rem; }
.form fieldset.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0 1.25rem; }
.form fieldset.grade > legend { grid-column: 1 / -1; }
.campo { display: grid; gap: .5rem; align-content: start; min-width: 0; }
.form .warning p { margin: .3rem 0; }
