/* BOC Track — folha de estilos (desktop primeiro)
   Leitura fácil para todas as idades: texto grande, contraste alto, alvos de clique largos. */
/* Tipo de letra Inter (licença OFL, ver /static/fonts/OFL.txt), incluído na plataforma */
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('/static/fonts/inter-400.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('/static/fonts/inter-600.woff') format('woff'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap; src: url('/static/fonts/inter-700.woff') format('woff'); }
@font-face { font-family: 'Inter Display'; font-weight: 300; font-style: normal; font-display: swap; src: url('/static/fonts/inter-display-300.woff') format('woff'); }
@font-face { font-family: 'Inter Display'; font-weight: 800; font-style: normal; font-display: swap; src: url('/static/fonts/inter-display-800.woff') format('woff'); }

:root {
  --ink: #18272A;
  --ink-2: #3F5155;
  --ink-3: #5F7175;
  --bg: #EEF2F1;
  --surface: #FFFFFF;
  --line: #CCD6D4;
  --line-2: #E1E8E6;
  --brand: #17524D;
  --brand-2: #0F3B37;
  --action: #1D6A64;
  --action-hover: #13504B;
  --pend: #A45F00;
  --pend-bg: #FFF4E0;
  --pend-line: #F0B44C;
  --fin: #23703F;
  --fin-bg: #E5F4EA;
  --fin-line: #5DB27C;
  --ster: #1C5F8C;
  --ster-bg: #E4F0F9;
  --st-blue: #1F5FA8;
  --st-blue-bg: #E3EEFA;
  --st-blue-line: #7FAEE3;
  --st-orange: #B85A00;
  --st-orange-bg: #FFEEDB;
  --st-orange-line: #F4A14A;
  --st-green: #23703F;
  --st-green-bg: #E3F3E8;
  --st-green-line: #5DB27C;
  --red: #B42318;
  --red-bg: #FDECEA;
  --radius: 8px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Inter Display", "Inter", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.5 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--action); text-underline-offset: 3px; }
a:hover { color: var(--action-hover); }
h1, h2 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.9rem; font-weight: 750; letter-spacing: -0.015em; }
h2 { font-size: 1.25rem; font-weight: 700; }
p { margin: 0 0 .75rem; }
:focus-visible { outline: 3px solid #2B7FD9; outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); font-weight: 400; }
.small { font-size: .9rem; }
.lead { color: var(--ink-2); font-size: 1.05rem; }
.mt { margin-top: 1rem; }
.nowrap { white-space: nowrap; }
.warn { color: var(--pend); font-weight: 600; }
.plain { margin: 0; padding-left: 1.2rem; }

/* ---------- Cabeçalho ---------- */
.top { background: var(--brand-2); color: #fff; }
.top-in { max-width: 1000px; margin: 0 auto; padding: .7rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.wide { max-width: 1840px !important; }
.brand { display: flex; align-items: center; gap: 1rem; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }

.mainnav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.mainnav a, .linklike {
  color: #fff; text-decoration: none; font: 500 1rem var(--font);
  padding: .55rem .9rem; border-radius: 6px; background: none; border: 0; cursor: pointer;
}
.mainnav a:hover, .linklike:hover { background: rgba(255,255,255,.12); color: #fff; }
.mainnav a[aria-current="page"] { background: rgba(255,255,255,.2); }
form.inline { display: inline; margin: 0; }

main { max-width: 1000px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.foot { max-width: 1000px; margin: 0 auto; padding: 0 1.5rem 2rem; color: var(--ink-3); font-size: .85rem; }

/* ---------- Mensagens ---------- */
.flash-wrap { max-width: 1000px; margin: 0 auto; padding: 1rem 1.5rem 0; }
.flash { padding: .8rem 1.1rem; border-radius: var(--radius); font-weight: 600; }
.flash-ok { background: var(--fin-bg); color: var(--fin); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-info { background: var(--ster-bg); color: var(--ster); }
.error-box, .ok-box, .notice { padding: .8rem 1.1rem; border-radius: var(--radius); margin: 0 0 1rem; }
.error-box { background: var(--red-bg); color: var(--red); font-weight: 600; }
.ok-box { background: var(--fin-bg); color: var(--fin); }
.notice { background: var(--pend-bg); border-left: 5px solid var(--pend-line); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 46px; padding: .6rem 1.2rem; border-radius: var(--radius);
  font: 650 1rem/1.2 var(--font); text-decoration: none; cursor: pointer; border: 2px solid transparent;
}
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--action-hover); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--action); color: var(--action-hover); }
.btn-danger { background: var(--red); color: #fff; }
.btn-big { min-height: 54px; padding: .8rem 1.7rem; font-size: 1.1rem; }
.btn-small { min-height: 40px; padding: .4rem .85rem; font-size: .95rem; }
.btn-icon { min-width: 42px; min-height: 42px; padding: 0; background: var(--surface); border-color: var(--line); color: var(--ink-2); font-size: 1.1rem; }
.btn-icon:disabled { opacity: .3; cursor: default; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; }
.btnrow { display: flex; gap: .4rem; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .5rem; }

/* O botão mais importante do painel */
.btn-new {
  min-height: 56px; padding: .8rem 1.8rem; font-size: 1.2rem; font-weight: 750;
  background: var(--action); color: #fff; box-shadow: 0 2px 0 var(--brand-2);
}
.btn-new:hover { background: var(--action-hover); color: #fff; }
.btn-new span { font-size: 1.5rem; line-height: 1; font-weight: 600; }

/* ---------- Painel ---------- */
.esp + .esp { margin-top: 3rem; }
.esp-head { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.esp-head h1 { margin: 0; font-size: 2.1rem; }
.tablewrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1.5px solid var(--line); }
.board { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 1rem; }
.board thead th {
  text-align: left; font-size: 1.125rem; font-weight: 700; color: var(--ink-2);
  padding: .9rem .5rem; border-bottom: 1.5px solid var(--line); white-space: nowrap; background: var(--surface);
  position: sticky; top: 0;
}
.board thead th:first-child { padding-left: 1.1rem; }
.board th.c-num, .board td.c-num, .board th.c-center, .board td.c-center { text-align: center; }
.board td.c-center .cell-act { align-items: center; }
.board td.c-short .v { white-space: nowrap; }
.board td { padding: 0; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.board tr.grp th {
  text-align: left; padding: .75rem 1.1rem; font-size: 1.05rem; font-weight: 750;
  border-bottom: 1.5px solid var(--line);
}
.grp .n { display: inline-block; min-width: 1.9rem; text-align: center; padding: 0 .5rem; margin-left: .4rem; border-radius: 999px; font-size: .9rem; background: var(--ink-2); color: #fff; }
.grp-note { display: block; font-size: .88rem; font-weight: 400; color: var(--ink-2); margin-top: .15rem; }
.board tr.grp th { background: #E4EBEA; color: var(--ink); border-top: 1.5px solid var(--line); }
/* Cada secção com a sua cor, para se reconhecer de relance */
.grp-pendente tr.grp th { background: #E3EBF5; box-shadow: inset 6px 0 0 #3A5F8C; }
.grp-pendente .grp-t { color: #24456B; }
.grp-pendente .grp .n { background: #3A5F8C; }
.grp-pos tr.grp th { background: #FCEEDD; box-shadow: inset 6px 0 0 #D9731A; }
.grp-pos .grp-t { color: #8A4706; }
.grp-pos .grp .n { background: #C2650F; }
.grp-finalizado tr.grp th { background: #E1F0E5; box-shadow: inset 6px 0 0 var(--st-green); }
.grp-finalizado .grp-t { color: #1C5B33; }
.grp-finalizado .grp .n { background: var(--st-green); }
.board tbody + tbody tr.grp th { border-top: 10px solid var(--surface); }

/* Três níveis de letra: especialidade (título) > secção (subtítulo) > material (corpo) */
.esp-head h1 { font-size: 2rem; line-height: 1.1; text-transform: uppercase; letter-spacing: .03em; }
.esp-head { align-items: center; gap: 1rem; }
.esp-head .btn-new { min-height: 0; height: 2.2rem; padding: 0 .9rem; font-size: .95rem; font-weight: 700; box-shadow: none; border-radius: 8px; }
.esp-head .btn-new span { font-size: 1.15rem; }
.board tr.grp th { font-size: 1.25rem; font-weight: 750; padding-top: 1rem; padding-bottom: 1rem; }
.grp .n { font-size: .95rem; vertical-align: .15em; }
.board td .cell .v { font-size: 1rem; }
td.c-first .cell .v { font-weight: 700; }
.cell .sub { font-size: .88rem; color: var(--ink-3); }
.day { font-weight: 750; }

/* Atraso: só texto, sem cor */
.flag { display: block; white-space: nowrap; margin-top: .25rem; font-size: .8rem; font-weight: 400; color: var(--ink-3); }
.board tbody:first-of-type tr.grp th { border-top: 0; }
.board tr.none td { padding: .9rem 1.1rem; color: var(--ink-3); }
/* Barra à esquerda de cada linha, na cor do estado atual */
.grp-pendente td.c-first { box-shadow: inset 6px 0 0 #3A5F8C; }
.grp-pos td.c-first { box-shadow: inset 6px 0 0 #D9731A; }
.grp-finalizado td.c-first, .archive td.c-first { box-shadow: inset 6px 0 0 var(--st-green); }

/* Cada célula é clicável */
.cell {
  display: block; height: 100%; min-height: 58px; padding: .7rem .5rem;
  color: var(--ink); text-decoration: none; border-radius: 4px;
}
td.c-first .cell { padding-left: 1.1rem; font-weight: 650; }
a.cell:hover { background: #E9F3F1; color: var(--ink); box-shadow: inset 0 0 0 2px var(--action); }
a.cell:focus-visible { outline-offset: -3px; }
.cell .v { display: block; }
.cell .sub { display: block; font-size: .88rem; color: var(--ink-2); margin-top: .1rem; }
.empty-cell { color: var(--action); font-size: .9rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.cell-ro .empty-cell { color: var(--ink-3); text-decoration: none; }
.cell-who .v { font-size: .95rem; }
td.c-last { min-width: 150px; }
tr.just-saved td { animation: saved 2.4s ease-out; }
@keyframes saved { 0%, 40% { background: #FFF6C9; } 100% { background: transparent; } }

.chip { display: inline-block; padding: .2rem .65rem; border-radius: 999px; font-size: .92rem; font-weight: 650; white-space: nowrap; }
.chip.ph-0 { background: var(--st-blue-bg); color: var(--st-blue); box-shadow: inset 0 0 0 1.5px var(--st-blue-line); }
.chip.ph-1 { background: var(--st-orange-bg); color: var(--st-orange); box-shadow: inset 0 0 0 1.5px var(--st-orange-line); }
.chip.ph-final { background: var(--st-green); color: #fff; }
.chip.ph-none { background: var(--line-2); color: var(--ink-2); }
.done-mark { font-weight: 650; color: var(--ink-2); }
td.c-surg { white-space: normal; min-width: 150px; }
td.c-surg .sub { font-size: .8rem; }
.board thead th.th-act { padding-left: .6rem; }
td.c-surg .cell { padding-left: .6rem; padding-right: .6rem; }
td.c-surg .cell { min-height: 58px; }
.btn-surg { font-size: .92rem; min-height: 38px; }
.cell-act { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; }
.btn-act { white-space: nowrap; }
/* Botões de confirmação com a mesma altura das etiquetas de estado */
.cell-act .btn-act { min-height: 0; padding: .2rem .7rem; font-size: .92rem; line-height: 1.35; border-width: 1.5px; border-radius: 6px; }
.btn-again { font-size: .88rem; color: var(--action); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; padding: .15rem 0; }
.act-row { display: inline-flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; align-items: center; }
.act-row .btn-again { margin-left: .3rem; }
.again-tag { font-weight: 650; color: var(--brand-2); }
.confirm-text { font-size: 1.2rem; font-weight: 650; }

.hint { color: var(--ink-3); font-size: .92rem; margin-top: .6rem; }
.empty { background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); padding: 2.5rem 1.5rem; text-align: center; color: var(--ink-2); font-size: 1.05rem; }
.search { display: flex; gap: .6rem; margin-bottom: 1.25rem; max-width: 720px; }
.search input { flex: 1; }
.search select { width: auto; }

/* ---------- Formulários ---------- */
.field { display: block; margin: 0; padding: 0; border: 0; min-width: 0; }
.field > label, .phase-pick legend { display: block; font-weight: 650; font-size: 1.05rem; margin-bottom: .35rem; padding: 0; }
.help { font-size: .9rem; color: var(--ink-3); margin: -.2rem 0 .4rem; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; min-height: 52px; padding: .65rem .85rem;
  font: 400 1.08rem/1.4 var(--font); color: var(--ink);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 20px) 52%, calc(100% - 14px) 52%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 2.5rem;
}
input.num { max-width: 140px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--action); outline: 3px solid rgba(29,106,100,.25); outline-offset: 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); background: #FFFBFA; }
.error { color: var(--red); font-size: .95rem; font-weight: 600; margin: .35rem 0 0; }
.check { display: flex; align-items: center; gap: .65rem; cursor: pointer; font-weight: 500; min-height: 34px; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--action); flex: none; }
fieldset.field .check { margin: .3rem 0; font-weight: 400; }
input.date { max-width: 240px; }

.phase-pick { border: 0; margin: 0; padding: 0; min-width: 0; }
.phase-opts { display: flex; gap: .6rem; flex-wrap: wrap; }
.phase-opt { position: relative; cursor: pointer; }
.phase-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.phase-opt span {
  display: flex; align-items: center; min-height: 54px; padding: .6rem 1.25rem; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--surface); font-weight: 650; font-size: 1.05rem; color: var(--ink-2);
}
.phase-opt span::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; margin-right: .6rem; flex: none; }
.phase-opt:hover span { border-color: var(--ink-3); }
.phase-opt input:focus-visible + span { outline: 3px solid #2B7FD9; outline-offset: 2px; }
.phase-opt.ph-0 span { color: var(--st-blue); }
.phase-opt.ph-1 span { color: var(--st-orange); }
.phase-opt.ph-final span { color: var(--st-green); }
.phase-opt.ph-0 input:checked + span { background: var(--st-blue); border-color: var(--st-blue); color: #fff; }
.phase-opt.ph-1 input:checked + span { background: var(--st-orange); border-color: var(--st-orange); color: #fff; }
.phase-opt.ph-final input:checked + span { background: var(--st-green); border-color: var(--st-green); color: #fff; }
.phase-opt input:checked + span::before { background: #fff; box-shadow: inset 0 0 0 4px currentColor; border-color: #fff; }

.formpage { max-width: 820px; }
.formpage h1 .muted { font-size: 1.3rem; margin-left: .4rem; }
.narrow { max-width: 640px; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.6rem; }
.formgrid > .field:first-of-type, .formgrid > .field:has(.phase-pick), .formgrid > .actions, .formgrid > [data-key=cor_contentores], .formgrid > [data-key^=local], .formgrid textarea { grid-column: 1 / -1; }
.formgrid .field:has(textarea) { grid-column: 1 / -1; }
.formgrid .actions { border-top: 1.5px solid var(--line-2); padding-top: 1.25rem; margin-top: .25rem; }
.editform > * + * { margin-top: 1.1rem; }
.edit-ctx { font-weight: 600; color: var(--ink-2); }

/* ---------- Janela de edição ---------- */
.edit-dialog {
  width: min(680px, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: 12px;
  box-shadow: 0 20px 60px rgba(10,30,30,.35); color: var(--ink); background: var(--surface);
}
.edit-dialog::backdrop { background: rgba(15,35,35,.55); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.4rem; border-bottom: 1.5px solid var(--line-2); }
.dlg-head h2 { margin: 0; font-size: 1.35rem; }
.dlg-x { font-size: 2rem; line-height: 1; width: 48px; height: 48px; border: 0; background: none; cursor: pointer; color: var(--ink-2); border-radius: 6px; }
.dlg-x:hover { background: var(--line-2); }
.dlg-body { padding: 1.2rem 1.4rem 1.4rem; }

/* ---------- Ficha ---------- */
.back { margin-bottom: .8rem; }
.back a::before { content: "‹ "; }
.rechead { margin-bottom: 1.25rem; }
.state { display: inline-block; font-weight: 700; padding: .2rem .8rem; border-radius: 999px; margin-bottom: .5rem; }
.state-pendente, .state-pos, .state-finalizado, .state-enviado { background: #E4EBEA; color: var(--ink); }
.kvtable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.kvtable th { text-align: left; font-weight: 600; color: var(--ink-2); width: 32%; padding: .75rem 1.1rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.kvtable td { padding: .75rem .5rem; border-bottom: 1px solid var(--line-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.kvtable td.c-act { text-align: right; width: 1%; white-space: nowrap; padding-right: 1rem; }
.history { margin-top: 2rem; }
.history ol { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.history ol > li { padding: .8rem 1.1rem; border-bottom: 1px solid var(--line-2); }
.history ol > li:last-child { border-bottom: 0; }
.history p { margin: 0; }
.history ul { margin: .25rem 0 0; padding-left: 1.2rem; color: var(--ink-2); }
del { color: var(--ink-3); }
ins { text-decoration: none; font-weight: 650; }
.danger { margin-top: 1.5rem; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: .3rem 1.1rem; }
.danger summary { cursor: pointer; font-weight: 650; padding: .6rem 0; color: var(--red); }
.danger form { padding-bottom: 1rem; }
.danger form > * + * { margin-top: .8rem; }

/* ---------- Entrar ---------- */
.stack > * + * { margin-top: 1.1rem; }

/* ---------- Administração ---------- */
.admin { display: grid; gap: 1.25rem; }
.subnav { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 2px solid var(--line); }
.subnav a { padding: .7rem .9rem; white-space: nowrap; color: var(--ink-2); text-decoration: none; font-weight: 650; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--action); }
.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin-bottom: 1rem; }
.grid2 { display: grid; gap: 1rem 1.25rem; grid-template-columns: 1fr 1fr; }
.span2 { grid-column: 1 / -1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.stats div { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stats strong { display: block; font-size: 2rem; line-height: 1.1; }
.stats span { color: var(--ink-2); font-size: .95rem; }
.pill { display: inline-block; font-size: .78rem; font-weight: 650; padding: .1rem .55rem; border-radius: 999px; background: #DDEDEA; color: var(--brand-2); vertical-align: middle; }
.pill-off { background: var(--line-2); color: var(--ink-3); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .97rem; }
.table th { text-align: left; font-size: .88rem; color: var(--ink-3); font-weight: 650; padding: .65rem .8rem; border-bottom: 1.5px solid var(--line); }
.table td { padding: .65rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr.inactive td { color: var(--ink-3); }
.table .detail { max-width: 380px; overflow-wrap: anywhere; color: var(--ink-2); }
.rows { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.row { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.row.inactive { opacity: .7; }
.rowform { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.rowform input[name=nome], .rowform input[name=label] { flex: 1 1 240px; width: auto; }
.rowform > label:first-of-type:not(.check):not(.sr) { font-weight: 650; width: 100%; }
.rowform select { width: auto; flex: 1 1 240px; }
.fieldlist { list-style: none; margin: 0 0 1rem; padding: 0; }
.fieldlist li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .7rem 0; border-top: 1px solid var(--line-2); }
.fieldlist li:first-child { border-top: 0; }
.fieldlist li.inactive .fl-label { color: var(--ink-3); text-decoration: line-through; }
.fieldlist li.dep { padding-left: 1.6rem; }
.fieldlist li.dep .fl-label::before { content: "↳ "; color: var(--ink-3); }
.fl-main { min-width: 0; }
.fl-label { font-weight: 650; text-decoration: none; font-size: 1.05rem; }
.fl-meta { display: flex; flex-wrap: wrap; gap: .1rem .9rem; font-size: .88rem; color: var(--ink-3); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

@media (max-width: 760px) {
  .grid2, .formgrid { grid-template-columns: 1fr; }
  main, .top-in, .flash-wrap, .foot { padding-left: 1rem; padding-right: 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .top, .btn, .danger, .foot, .subnav, .hint, .search { display: none !important; }
  body { background: #fff; font-size: 12px; }
  main { max-width: none; padding: 0; }
}

/* ---------- A minha conta ---------- */
.kv { margin: 0 0 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem 1.5rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.3rem; }
.kv div { min-width: 0; }
.kv dt { font-size: .9rem; color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 650; font-size: 1.05rem; }
.narrow > form.stack { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.3rem; }
.narrow > h2 { margin-top: .5rem; }
fieldset.field > legend { font-weight: 650; font-size: 1.05rem; margin-bottom: .35rem; }


/* ---------- Logotipo ---------- */
.wm { display: inline-flex; flex-direction: column; gap: .14em; font-family: var(--font-display); line-height: 1; }
.wm-word { white-space: nowrap; letter-spacing: -0.035em; }
.wm-b { font-weight: 800; color: var(--brand-2); }
.wm-t { font-weight: 300; color: var(--action); margin-left: .1em; }
.wm-bar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .08em; height: .12em; }
.wm-bar i { display: block; border-radius: 99px; }
.wm-bar i:nth-child(1) { background: var(--st-blue); }
.wm-bar i:nth-child(2) { background: #E07A10; }
.wm-bar i:nth-child(3) { background: var(--st-green); }
.wm-top { font-size: 1.75rem; }
.wm-top .wm-b { color: #fff; }
.wm-top .wm-t { color: #A8D8D1; }
.wm-top .wm-bar i:nth-child(1) { background: #5B95DA; }
.wm-top .wm-bar i:nth-child(2) { background: #F29A3A; }
.wm-top .wm-bar i:nth-child(3) { background: #4FB37A; }

/* ---------- Página de entrada ---------- */
body.bare { background: var(--bg); }
body.bare main { max-width: none; padding: 0; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; box-sizing: border-box; }
.login { width: 100%; max-width: 460px; margin: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 2.5rem 2.25rem 2rem; box-shadow: 0 1px 2px rgba(15,59,55,.06); }
.login-head { display: flex; flex-direction: column; align-items: center; gap: .9rem; margin-bottom: 2rem; text-align: center; }
.wm-login { font-size: 3.6rem; }
.login-sub { margin: 0; color: var(--ink-2); font-size: 1.05rem; font-weight: 600; letter-spacing: .01em; }
.login .flash { margin: 0 0 1rem; }
.login-help { margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line-2); color: var(--ink-3); font-size: .92rem; }
.login-help p { margin: 0 0 .4rem; }

/* ---------- Primeiro acesso e A minha conta ---------- */
.wm-small { font-size: 2.4rem; }
.login-head:has(.wm-small) { margin-bottom: 1.5rem; }
.fa-title { font-size: 1.7rem; margin: 0 0 .4rem; text-align: center; }
.fa-lead { color: var(--ink-2); text-align: center; margin: 0 0 1.5rem; }
.pw-wrap { display: flex; gap: .5rem; align-items: stretch; }
.pw-wrap input { flex: 1; min-width: 0; }
.pw-toggle { min-width: 112px; }
.stack > input + div, .stack > input + .field { margin-top: 0; }
.pw-rules { list-style: none; margin: -.2rem 0 0; padding: .7rem .9rem; background: var(--bg); border-radius: var(--radius); display: grid; gap: .3rem; font-size: .95rem; color: var(--ink-2); }
.pw-rules li { display: flex; align-items: center; gap: .55rem; }
.pw-rules li::before { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; box-sizing: border-box; }
.pw-rules li.ok { color: var(--st-green); font-weight: 600; }
.pw-rules li.ok::before { border-color: var(--st-green); background: var(--st-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat; }
.pw-match { margin: .4rem 0 0; font-size: .95rem; font-weight: 600; }
.pw-match.ok { color: var(--st-green); }
.pw-match.no { color: var(--pend); }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--action); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.account { max-width: 640px; }
.account h2 { margin-top: 2rem; margin-bottom: .25rem; }
.account-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; }
.account-card > .muted { margin: .8rem 0 0; }
.account-id { display: flex; align-items: center; gap: 1rem; }
.account-id p { margin: 0; }
.account-name { font-size: 1.25rem; font-weight: 700; }
.avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--brand-2); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; flex: none; }
.account-form { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 1.4rem 1.3rem; margin-top: .75rem; }

@media (min-width: 640px) { .usergrid { grid-template-columns: 1fr 160px 1.6fr; } .usergrid .span2 { grid-column: 1 / -1; } }

/* Iniciais do utilizador no canto superior direito */
.mainnav a.me { display: flex; align-items: center; padding: 0; margin-left: .75rem; border-radius: 50%; background: none; }
.mainnav a.me:focus-visible { outline-color: #fff; }
.mainnav a.me:hover .avatar { box-shadow: 0 0 0 3px rgba(255,255,255,.35); }
.avatar-sm { width: 40px; height: 40px; font-size: 1rem; background: #A8D8D1; color: var(--brand-2); }
.me-name { font-weight: 600; white-space: nowrap; }

/* Especialidades */
.esp-list { display: grid; gap: .75rem; }
.esp-card { margin: 0; }
.esp-card.inactive { background: #F7F9F8; }
.esp-card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.esp-card-head h2 { margin: 0 0 .2rem; display: flex; align-items: center; gap: .6rem; }
.esp-card-head p { margin: 0; }
.esp-more { margin-top: .8rem; border-top: 1px solid var(--line-2); padding-top: .6rem; }
.esp-more summary { cursor: pointer; color: var(--action); font-weight: 600; padding: .2rem 0; }
.esp-more > * + * { margin-top: .8rem; }
.esp-remove { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; align-items: center; }

/* ---------- Ficha: responsáveis e percurso ---------- */
.rec-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.rec-top .back { margin: 0; }
.sec-title { margin: 2rem 0 .6rem; }
.resp { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.resp.resp4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.resp > div { padding: 1rem 1.2rem; }
.resp > div + div { border-left: 1px solid var(--line-2); }
.resp p { margin: 0; }
.resp-k { font-size: .9rem; color: var(--ink-3); font-weight: 600; }
.resp-v { font-size: 1.1rem; font-weight: 700; margin-top: .15rem !important; }
.resp-t { font-size: .92rem; color: var(--ink-2); }
@media (max-width: 760px) { .resp { grid-template-columns: 1fr; } .resp > div + div { border-left: 0; border-top: 1px solid var(--line-2); } }
.trail { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); }
.trail > li { display: grid; grid-template-columns: 150px 1fr; gap: 1.2rem; padding: .9rem 1.2rem .9rem 1.2rem; position: relative; }
.trail > li + li { border-top: 1px solid var(--line-2); }
.trail-when { font-size: .92rem; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: .1rem; }
.trail-body { position: relative; padding-left: 1.4rem; }
.trail-body::before { content: ""; position: absolute; left: 0; top: .35rem; width: 12px; height: 12px; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 3px var(--surface); }
.trail-entrada .trail-body::before { background: var(--brand-2); }
.trail-cirurgia .trail-body::before { background: var(--st-blue); }
.trail-nova .trail-body::before { background: var(--brand-2); box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand-2); }
.trail-pronto .trail-body::before { background: var(--st-green); }
.trail-enviado .trail-body::before { background: var(--brand-2); }
.trail-enviado .trail-title { color: var(--brand-2); }
.trail-estado .trail-body::before { background: #E07A10; }
.trail-anulado .trail-body::before, .trail-alteracao .trail-body::before { background: var(--ink-3); }
.trail p { margin: 0; }
.trail-title { font-weight: 700; }
.trail-pronto .trail-title { color: var(--st-green); }
.trail-who { font-weight: 600; color: var(--ink); }
.trail-detail { margin-top: .3rem !important; color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; }
.trail-local { color: var(--ink); }
.trail-list { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--ink-2); }
@media (max-width: 760px) { .trail > li { grid-template-columns: 1fr; gap: .3rem; } }

/* ---------- Arquivo ---------- */
.archive td .v .chip { font-size: .85rem; }
.archive td .sub strong { color: var(--ink); font-weight: 600; }

@media print {
  .no-print, dialog, .flash-wrap { display: none !important; }
  .resp, .trail, .kvtable { border-color: #999; }
  .trail > li { break-inside: avoid; }
  .recordpage { max-width: none; }
  .chip { box-shadow: inset 0 0 0 1px #666 !important; }
}

.resp + .notice { margin-top: 1rem; }

/* Nova entrada: arrumação por linhas
   Material | Tipo de origem + Origem | Sala + Data | Cirurgião | Caixas + Contentores | Cor | Estado | Local */
.formgrid > [data-key=cirurgiao] { grid-column: 1 / -1; }
.formgrid > [data-key=n_caixas] { grid-column: 1; }
.formgrid > [data-key=n_contentores] { grid-column: 2; }
.formgrid input.num { max-width: 160px; }
@media (min-width: 760px) {
  .formgrid .phase-opts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; }
  .formgrid .phase-opt span { justify-content: flex-start; padding: .6rem .8rem; font-size: 1rem; height: 100%; box-sizing: border-box; white-space: nowrap; }
  .formpage:has(.formgrid) { max-width: 900px; }
}
.editform .phase-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.formgrid > [data-key=origem_tipo] { grid-column: 1; }
.formgrid > [data-key=empresa] { grid-column: 2; }
.formgrid > [data-key=sala] { grid-column: 1; }
.formgrid > [data-key=data_cirurgia] { grid-column: 2; }
@media (max-width: 760px) { .formgrid > [data-key] { grid-column: 1 / -1 !important; } }

/* Nova entrada em 4 colunas: os campos normais ocupam 2, Caixas e Contentores ficam lado a lado com 1 cada */
@media (min-width: 761px) {
  .formgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .formgrid > .field, .formgrid > [data-key] { grid-column: span 2; }
  .formgrid > .field:first-of-type, .formgrid > [data-key=cirurgiao], .formgrid > [data-key=cor_contentores],
  .formgrid > .field:has(.phase-pick), .formgrid > [data-key^=local], .formgrid > .actions, .formgrid > .field:has(textarea) { grid-column: 1 / -1; }
  .formgrid > [data-key=origem_tipo], .formgrid > [data-key=sala] { grid-column: 1 / 3; }
  .formgrid > [data-key=empresa], .formgrid > [data-key=data_cirurgia] { grid-column: 3 / 5; }
  .formgrid > [data-key=n_caixas] { grid-column: 1 / 2; }
  .formgrid > [data-key=n_contentores] { grid-column: 2 / 3; }
  .formgrid > [data-key=n_caixas] input.num, .formgrid > [data-key=n_contentores] input.num { max-width: none; }
}

/* Escolha com botões grandes (sem cores de estado) */
.phase-opt.ch-opt span { color: var(--ink); }
.phase-opt.ch-opt input:checked + span { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.acond-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 260px; font-size: .95rem; }
@media (min-width: 761px) {
  .formgrid .choice-opts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .formgrid > .field[data-key=acondicionamento] { grid-column: 2 / 5; }
  .formgrid > [data-key=n_contentores] { grid-column: 1 / 2; }
  .formgrid > [data-key=cor_contentores] { grid-column: 2 / 5; }
  .formgrid > [data-key=desc_acondicionamento] { grid-column: 1 / -1; }
}

/* Acondicionamento primeiro; com contentores: caixas e contentores lado a lado, descrição por baixo */
@media (min-width: 761px) {
  .formgrid > .field[data-key=acondicionamento] { grid-column: 1 / -1; }
  .formgrid > [data-key=n_caixas] { grid-column: 1 / 2; }
  .formgrid > [data-key=n_contentores] { grid-column: 2 / 3; }
  .formgrid > [data-key=cor_contentores] { grid-column: 1 / -1; }
  .formgrid .choice-opts { max-width: 560px; }
}

/* Administração: registos */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: .8rem 1rem; align-items: end; }
.filters-actions { grid-column: 1 / -1; display: flex; gap: .6rem; }
@media (max-width: 900px) { .filters { grid-template-columns: 1fr 1fr; } }
.rec-admin .c-chk { width: 44px; }
.rec-admin .check { min-height: 0; }
.danger-zone { border-color: #E8B4AE; background: #FFF8F7; display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.4rem; }
section.danger-zone { display: block; }
section.danger-zone h2 { color: var(--red); }
.danger-zone .rowform label { font-weight: 600; width: auto !important; }
.conf-input { max-width: 240px; flex: 0 1 240px !important; }

/* ---------- Dois níveis de destaque na lista ----------
   Essencial: material, sala, data, cirurgião. Secundário: origem, acondicionamento, última alteração.
   Estado e botões mais discretos. */
.board td.c-pri .cell .v { font-size: 1.05rem; color: var(--ink); }
.board td.c-first .cell .v { font-size: 1.12rem; font-weight: 750; }
.board td.c-first { min-width: 200px; }
.board td.c-sec .cell, .board td.c-sec .cell .v { font-size: .9rem; color: var(--ink-2); }
.board td.c-sec .cell .sub { font-size: .84rem; }
.cell-who .v { font-weight: 400; }
.acond-line { display: block; line-height: 1.4; }
.acond-line + .acond-line { margin-top: .15rem; }
.acond-line strong { color: var(--ink); font-weight: 700; }
.acond-cor { color: var(--ink-3); font-weight: 400; }
/* Etiquetas de estado e botões mais discretos */
.board .chip { font-size: .82rem; padding: .12rem .55rem; font-weight: 650; }
.board .chip.ph-final { background: #E3F1E7; color: #1C5B33; box-shadow: inset 0 0 0 1.5px #9CCBAA; }
.cell-act .btn-act { font-size: .82rem; padding: .12rem .55rem; font-weight: 650; color: var(--ink-2); }
.cell-act .btn-act:hover { color: var(--action-hover); }

/* Em ecrãs mais estreitos, os títulos das colunas podem ocupar duas linhas */
.board thead th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.board td.c-sec { min-width: 0; }
td.c-last { min-width: 130px; }
td.c-last .cell .v, td.c-last .cell .sub, td.c-surg .sub { white-space: nowrap; }
/* Caixas e contentores alinhados em baixo, mesmo quando um tem texto de ajuda */
.formgrid > [data-key=n_caixas], .formgrid > [data-key=n_contentores] { align-self: end; }

/* ---------- Telemóvel: cada material é um cartão (a tabela só no computador) ---------- */
@media (max-width: 760px) {
  .board, .board tbody, .board tr, .board td { display: block; width: auto; }
  .board thead { display: none; }
  .tablewrap { overflow: visible; background: transparent; border: 0; }
  .board tr.grp th { display: block; border-radius: 10px; margin-top: 1.2rem; font-size: 1.15rem; padding: .7rem 1rem; }
  .board tbody:first-of-type tr.grp th { margin-top: 0; }
  .board tbody + tbody tr.grp th { border-top: 0; }
  .board tr.none td { background: var(--surface); border-radius: 10px; margin-top: .5rem; border: 1.5px solid var(--line); }
  .board tbody > tr:not(.grp):not(.none) {
    display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem;
    grid-template-areas: "mat mat" "sala data" "cir org" "acond acond" "est est" "act act" "last last";
    background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; margin-top: .6rem; padding: .35rem .5rem .5rem 1rem;
  }
  .grp-pendente > tr:not(.grp):not(.none) { box-shadow: inset 6px 0 0 #3A5F8C; }
  .grp-pos > tr:not(.grp):not(.none) { box-shadow: inset 6px 0 0 #D9731A; }
  .grp-finalizado > tr:not(.grp):not(.none) { box-shadow: inset 6px 0 0 var(--st-green); }
  .board td { border: 0; padding: 0; min-width: 0 !important; text-align: left !important; }
  .board td.c-first { box-shadow: none !important; }
  .board td.k-material { grid-area: mat; }
  .board td.k-sala { grid-area: sala; }
  .board td.k-data_cirurgia { grid-area: data; }
  .board td.k-cirurgiao { grid-area: cir; }
  .board td.k-empresa { grid-area: org; }
  .board td.k-acondicionamento { grid-area: acond; }
  .board td.k-estado { grid-area: est; align-self: center; }
  .board td.c-surg { grid-area: act; }
  .board td.c-surg .cell { padding-top: .5rem; }
  .board td.c-last { grid-area: last; border-top: 1px solid var(--line-2); margin-top: .35rem; }
  .board td .cell { min-height: 0; padding: .4rem .25rem; }
  td.c-first .cell { padding-left: .25rem; }
  .board td.c-first .cell .v { font-size: 1.2rem; }
  /* Pequeno título por cima de cada dado (Sala, Data, Cirurgião…) */
  .board td.k-sala::before, .board td.k-data_cirurgia::before, .board td.k-cirurgiao::before,
  .board td.k-empresa::before, .board td.k-acondicionamento::before {
    content: attr(data-l); display: block; padding: .45rem .25rem 0; font-size: .72rem; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; margin-bottom: .05rem;
  }
  .board td.k-sala .cell .v, .board td.k-data_cirurgia .cell .v { font-size: 1.05rem; font-weight: 700; }
  .board td.k-estado .cell { padding-top: .5rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
  .board td.k-estado .cell .v, .board td.k-estado .cell .sub { display: inline; margin: 0; }
  .board td.k-estado .chip { font-size: .9rem; padding: .25rem .7rem; }
  /* Botão de confirmação grande, para o dedo */
  .cell-act { align-items: stretch !important; }
  .cell-act .btn-act { min-height: 44px; font-size: .95rem; padding: .5rem .8rem; justify-content: center; }
  .cell-act .btn-again { text-align: center; padding: .35rem 0; }
  td.c-surg .sub, td.c-last .cell .v, td.c-last .cell .sub { white-space: normal; text-align: left; }
  .board td.c-last .cell { display: flex; gap: .4rem; flex-wrap: wrap; align-items: baseline; padding-top: .45rem; }
  .board td.c-last .cell .v, .board td.c-last .cell .sub { font-size: .82rem; margin: 0; }
  /* Janelas: opções de estado uma por linha */
  .phase-opts { grid-template-columns: 1fr !important; }
  .esp-head h1 { font-size: 1.6rem; }
}
