/* ============================================================
   Ficha Clínica (106) — grelha e alinhamento (owner 2026-09-05)
   Só afecta #tab-clinica. Princípios: uma grelha de 12 colunas por
   card, etiquetas em cima e iguais, OD|OE sempre em tabela, cards
   com largura de leitura, botão Guardar no rodapé do card.
   ============================================================ */

/* cabeçalho do paciente */
.fc-cab { display: grid; grid-template-columns: minmax(18rem, max-content) max-content; justify-content: start; gap: .6rem 3.5rem; align-items: start; padding: 1rem 1.25rem; }
.fc-cab h3 { margin: 0 0 .3rem; font-size: 1.15rem; }
.fc-cab .meta { color: var(--muted); font-weight: 400; font-size: .92rem; }
.fc-cab .chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.fc-kv { display: grid; grid-template-columns: auto auto; gap: .25rem 1.2rem; font-size: .9rem; align-content: start; padding-top: .2rem; }
.fc-kv dt { color: var(--muted); text-align: left; margin: 0; }
.fc-kv dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fc-kv dd small { color: var(--muted); font-size: .78rem; }
@media (max-width: 800px) { .fc-cab { grid-template-columns: 1fr; } .fc-kv dt { text-align: left; } }

/* sub-separadores */
#fc-nav { gap: .25rem; margin: .5rem 0; }
#fc-nav button[data-fct] { padding: .45rem .9rem; border-radius: 8px; }
#fc-nav button[data-fct].ghost { border-color: transparent; }
#fc-nav button[data-fct].ghost:hover { background: var(--tint); color: var(--accent-2); }

/* cards da consulta */
.fc-card { padding: 0; overflow: hidden; margin-bottom: .8rem; }
.fc-card-h { display: flex; align-items: center; gap: .6rem; padding: .75rem 1.25rem; cursor: pointer; background: var(--soft-2); user-select: none; }
.fc-card-h:hover { background: var(--soft); }
.fc-card.aberto .fc-card-h { border-bottom: 1px solid var(--line); }
.fc-card-h .seta { color: var(--muted); width: 1rem; text-align: center; }
.fc-card-h b { flex: 1; font-size: .98rem; }
.fc-card-b { padding: 1.1rem 1.25rem 1.2rem; }
.fc-card-b .grupo-titulo { margin: 1.2rem 0 .5rem; }
.fc-card-b .grupo-titulo:first-child { margin-top: 0; }

/* grelha de 12 colunas */
.fc-form { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: .85rem 1.25rem; align-items: start; }
.fc-form + .fc-form { margin-top: .85rem; }
.fc-form .f { display: flex; flex-direction: column; gap: .3rem; min-width: 0; margin: 0; }
.fc-form .f > .l { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-form .f > input, .fc-form .f > select, .fc-form .f > textarea { width: 100%; }
.fc-form .f > textarea { min-height: 4.6rem; }
.fc-form .f.chk { flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--text); padding-top: 1.45rem; min-height: 2.2rem; }
.fc-form .f.chk input { width: auto; margin: 0; }
.fc-form .f.acc { flex-direction: row; align-items: end; gap: .5rem; }
.fc-form .f > .l + button { align-self: flex-start; }
.fc-form .w1 { grid-column: span 1; } .fc-form .w2 { grid-column: span 2; } .fc-form .w3 { grid-column: span 3; }
.fc-form .w4 { grid-column: span 4; } .fc-form .w5 { grid-column: span 5; } .fc-form .w6 { grid-column: span 6; }
.fc-form .w8 { grid-column: span 8; } .fc-form .w9 { grid-column: span 9; } .fc-form .w12 { grid-column: span 12; }
@media (max-width: 900px) { .fc-form .w1, .fc-form .w2, .fc-form .w3 { grid-column: span 4; } .fc-form .w4, .fc-form .w5, .fc-form .w6 { grid-column: span 6; } .fc-form .w8, .fc-form .w9 { grid-column: span 12; } }

/* tabela OD | OE */
table.fc-t { width: auto; border-collapse: collapse; margin: 0; }
table.fc-t th, table.fc-t td { padding: .3rem .6rem; border: none; background: none; text-align: left; vertical-align: middle; }
table.fc-t thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: center; padding-bottom: .1rem; }
table.fc-t tbody th { font-weight: 600; font-size: .88rem; color: var(--text); white-space: nowrap; padding-right: .9rem; }
table.fc-t td input, table.fc-t td select { width: 7rem; }
table.fc-t td input.txt, table.fc-t td select.txt { width: 11rem; }
table.fc-t td input.num { text-align: right; }
table.fc-t + .fc-form { margin-top: .6rem; }
.fc-tt { display: flex; gap: 1.2rem 3.5rem; flex-wrap: wrap; align-items: flex-start; }
.fc-tt > .fc-form { flex: 0 1 28rem; min-width: 0; margin: 0; }
.fc-tt > div > .grupo-titulo { margin-top: 0; }

/* estruturas (segmentos) */
table.fc-seg { width: 100%; border-collapse: collapse; }
table.fc-seg th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--soft-2); padding: .4rem .5rem; text-align: left; }
table.fc-seg th.od, table.fc-seg th.oe { text-align: center; }
table.fc-seg td { padding: .35rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.fc-seg td.est { width: 18rem; font-weight: 600; font-size: .9rem; }
table.fc-seg td.est small { display: block; font-weight: 400; color: var(--muted); font-size: .74rem; }
table.fc-seg td.olho { width: calc((100% - 18rem) / 2); }
table.fc-seg td.olho .cel { display: flex; align-items: center; gap: .4rem; }
table.fc-seg td.olho label { display: inline-flex; flex: 0 0 auto; flex-direction: row; align-items: center; gap: .3rem; margin: 0; font-size: .85rem; color: var(--muted); white-space: nowrap; }
table.fc-seg td.olho input[type=checkbox] { margin: 0; }
table.fc-seg td.olho input.grau { width: 4.2rem; flex: 0 0 4.2rem; padding: .35rem .45rem; }
table.fc-seg td.olho input.desc { flex: 1; min-width: 6rem; width: auto; padding: .35rem .45rem; }
@media (max-width: 900px) { table.fc-seg td.est { width: 9rem; } table.fc-seg td.olho .cel { flex-wrap: wrap; } }
table.fc-seg tr.alt td { background: #FFF3D6; }
table.fc-seg td.olho.alt input.desc { border-color: var(--amber); }

/* rodapé de cada card e barra de acções */
.fc-foot { display: flex; align-items: center; gap: .6rem; margin-top: 1.2rem; padding-top: .85rem; border-top: 1px dashed var(--line); }
.fc-foot .msg { flex: 1; font-size: .88rem; color: var(--muted); }
.fc-acc { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .6rem; }
.fc-barra { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: .6rem 1rem; display: flex; gap: .6rem; align-items: center; z-index: 3; border-radius: 12px; box-shadow: 0 -6px 18px rgb(0 0 0 / .06); }
.fc-barra .esq { display: flex; gap: .5rem; align-items: center; flex: 1; }
.fc-flag { color: var(--danger); font-weight: 600; font-size: .86rem; }
.fc-lock { font-size: .85rem; color: var(--muted); }

/* listas dentro da ficha */
#tab-clinica table.lista th.num, #tab-clinica table.lista td.num { text-align: right; font-variant-numeric: tabular-nums; }
#tab-clinica .fc-card-b table.lista { margin-top: .6rem; }
