:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1d2330; --muted: #6b7280;
  --line: #e3e6eb; --accent: #2b6cb0; --accent-ink: #fff;
}
/* Titillium Web — tipografia da marca Certigera, auto-alojada (sem depender de
   internet do cliente). Pesos: Regular 400, SemiBold 600, Bold 700 (subset latin,
   cobre os acentos PT). */
@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/titillium-web-400.woff2") format("woff2");
}
@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/titillium-web-600.woff2") format("woff2");
}
@font-face {
  font-family: "Titillium Web"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/titillium-web-700.woff2") format("woff2");
}
/* Flag emoji as a web font so they render on Windows too (which has no native
   flag glyphs). Scoped to the regional-indicator range, so only flags use it. */
@font-face {
  font-family: "Twemoji Country Flags";
  unicode-range: U+1F1E6-1F1FF, U+1F3F4, U+E0062-E0063, U+E0065, U+E0067,
                 U+E006C, U+E006E, U+E0073-E0074, U+E0077, U+E007F;
  src: url("/static/TwemojiCountryFlags.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }
body {
  margin: 0; font: 15px/1.5 "Titillium Web", -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
/* prepend the flag font everywhere (incl. native select options) */
body, button, input, select, optgroup, option {
  font-family: "Twemoji Country Flags", "Titillium Web", -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  display: flex; align-items: center; gap: 1.5rem;
  padding: .6rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); }
.mainnav { display: flex; gap: 1rem; flex: 1; align-items: center; }
.mainnav a.on { font-weight: 600; color: var(--ink); }
.navtoggle { display: none; background: none; border: 0; font-size: 1.4rem; line-height: 1;
  cursor: pointer; color: var(--ink); padding: .1rem .4rem; }
/* grouped dropdown menus — click to toggle (works on desktop + touch + keyboard) */
.navgroup { position: relative; }
.navgroup-label { background: none; border: 0; cursor: pointer; font: inherit; color: var(--accent); padding: 0; }
.navgroup.active > .navgroup-label, .navgroup.open > .navgroup-label { color: var(--ink); font-weight: 600; }
.navgroup-menu { position: absolute; top: 100%; left: 0; display: none; flex-direction: column;
  min-width: 12rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,.12); padding: .35rem; z-index: 30; }
.navgroup.open > .navgroup-menu { display: flex; }
.navgroup-menu a { padding: .4rem .6rem; border-radius: 6px; color: var(--ink); white-space: nowrap; }
.navgroup-menu a:hover { background: #eef2f7; text-decoration: none; }
.navgroup-menu a.on { font-weight: 600; background: #eef2f7; }
/* Resolver dropdown on the Incongruentes worklist (native <details>, no JS) */
.rowmenu { display: inline-block; }
.rowmenu > summary { list-style: none; cursor: pointer; }
.rowmenu > summary::-webkit-details-marker { display: none; }
/* in-flow (not absolute) so the menu can't be clipped by a table/overflow wrapper —
   opening it just grows the row. */
.rowmenu-actions { display: flex; flex-direction: column; gap: .3rem; margin-top: .3rem;
  min-width: 11rem; padding: .35rem; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.rowmenu-actions .btn { width: 100%; text-align: left; }
/* module switcher (Certificação · Certidão · …) — sits on the right, by the user name */
.modswitcher { display: inline-flex; gap: .3rem; padding-right: .9rem; border-right: 1px solid var(--line); }
.modtab { padding: .25rem .65rem; border-radius: 999px; color: var(--accent); font-weight: 600; }
.modtab:hover { background: #eef2f7; text-decoration: none; }
.modtab.on, .modtab.on:hover { background: var(--accent); color: var(--accent-ink); }
.modchk { display: inline-flex; align-items: center; gap: .2rem; margin-right: .5rem; font-size: .82rem; white-space: nowrap; }
td.num, th.num { text-align: right; white-space: nowrap; }
td.dt { white-space: nowrap; }   /* keep dates on one line so the column isn't squeezed */
.neg { color: #c0392b; }
.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 1.1rem; text-align: center;
  color: var(--muted); margin: .6rem 0; }
.dropzone.drag { border-color: var(--accent); background: #eef4fb; color: var(--ink); }
/* wide tables scroll horizontally instead of breaking the layout. `scrollbar-width`
   tira a barra «overlay» do GNOME: em Ubuntu ela só aparecia ao passar o rato por
   cima, logo uma tabela cortada parecia não ter forma nenhuma de rolar (2026-09-22). */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

/* --- responsive: collapse the nav into a hamburger drawer on narrow screens --- */
@media (max-width: 800px) {
  header { flex-wrap: wrap; gap: .75rem 1rem; }
  .navtoggle { display: inline-block; order: 3; margin-left: auto; }
  .account { order: 2; }
  .mainnav { display: none; order: 4; flex-basis: 100%; flex-direction: column;
    align-items: stretch; gap: 0; }
  header.navopen .mainnav { display: flex; }
  .mainnav > a { padding: .55rem .25rem; border-top: 1px solid var(--line); }
  .navgroup { width: 100%; border-top: 1px solid var(--line); }
  .navgroup-label { width: 100%; text-align: left; padding: .55rem .25rem; }
  .navgroup-menu { position: static; display: none; min-width: 0; border: 0;
    box-shadow: none; padding: 0 0 .3rem 1rem; }
}
@media (max-width: 480px) { .account .user { display: none; } }
.account { display: flex; gap: .75rem; align-items: center; color: var(--muted); }
.account .logout { font-size: .9rem; }

main { max-width: 1100px; margin: 1.5rem auto; padding: 0 1.25rem; }
main.wide { max-width: 1500px; }   /* wide tables (Peritos, etc.) */
/* Peritos: compact + wrap so all 9 columns fit without horizontal clipping */
#peritos table th, #peritos table td { padding: .4rem .55rem; font-size: .85rem; }
#peritos table td { overflow-wrap: anywhere; }
#peritos table select.sexo { font-size: .85rem; }
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }

.cards { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.25rem; min-width: 150px;
}
.card .big { font-size: 2rem; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
/* module chooser (the «gertrudes» home) — big tiles, one per accessible module */
.modcards { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.25rem; }
.modcard { display: flex; align-items: center; justify-content: center; min-width: 13rem;
  min-height: 6.5rem; padding: 1.5rem 2rem; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 1.3rem; font-weight: 700; color: var(--ink); text-align: center; }
.modcard:hover { border-color: var(--accent); background: #eef4fb; text-decoration: none; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
th { background: #fafbfc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f0f4f9; }
/* IDs com taxa de urgência — linha levemente tingida (laranja quente) + barra à esquerda,
   para os peritos os reconhecerem de relance na Agenda e nas Prioridades */
tbody tr.row-urgente { background: #fff3e8; }
tbody tr.row-urgente:hover { background: #ffe6d1; }
tbody tr.row-urgente td:first-child { box-shadow: inset 3px 0 0 #ea7a17; }
/* Verificar FT: nota de crédito = linha inteira verde-água (pedido Raúl 2026-08-24) */
tbody tr.row-nc { background: #d8f3ec; }
tbody tr.row-nc:hover { background: #c6ebe1; }
tbody tr.row-nc td:first-child { box-shadow: inset 3px 0 0 #2aa58c; }
.nc-legend { background: #d8f3ec; padding: 0 .35em; border-radius: 4px; }

dl { display: grid; grid-template-columns: 220px 1fr; gap: .15rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; }
dt { color: var(--muted); }
dd { margin: 0; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; background: #eef2f7; font-size: .85rem; }
.b-certificado-emitido, .b-certificado-pago, .b-certificado-concluido { background: #def7ec; color: #03543f; }
.b-cancelado, .b-lixo, .b-calote { background: #fde8e8; color: #9b1c1c; }
.b-agendado, .b-visita-efetuada, .b-visita-efectuada { background: #e1effe; color: #1e429f; }
.b-prioridades { background: #def7ec; color: #03543f; }   /* pronto a calcular */
.b-parado { background: #fde2dc; color: #b42318; }         /* à espera de pagamento/docs — vermelho p/ incentivar acção */
.b-push, .b-aguarda-orcamento, .b-aguarda-pagamento { background: #fdf6b2; color: #723b13; }
.b-aguarda-cliente { background: #fde4cf; color: #8a3f08; }   /* adjudicado, a aguardar o cliente */
.b-worten { background: #fde2e2; color: #cc0000; }   /* tag de canal de venda Worten (vermelho da marca) */
.b-quente { background: #fde2d6; color: #9c2a10; }
.b-para-estornar { background: #fde2d6; color: #9c2a10; }   /* Certidão: marcado para estorno (fila Estornar) */
.b-morno  { background: #fdf6b2; color: #723b13; }
.b-frio   { background: #e1effe; color: #1e429f; }
/* módulo Certidão — bolhas de tipo, cores subtis/esbatidas (não berrantes):
   CRP castanho · CPC azul · CNA rosa · CCA verde · COB preto */
.b-crp { background: #efe7df; color: #6f4d31; }
.b-cpc { background: #e8eef7; color: #3a5680; }
.b-cna { background: #f7e9f1; color: #8a4a66; }
.b-cca { background: #e8f1ea; color: #3f6b4a; }
.b-cob { background: #e9e9ec; color: #38383d; }
.filterchips { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-size: .9rem; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { background: #eef2f7; color: var(--muted); border-radius: 999px; padding: 0 .45rem; font-size: .8rem; }
.chip.on .n { background: rgba(255,255,255,.25); color: var(--accent-ink); }

/* Estatísticas › Peritos: expandable perito rows + nested IDs subtable */
tr.exp-row { cursor: pointer; }
tr.exp-row:hover td { background: #fafbfc; }
tr.exp-row .exp-caret { display: inline-block; color: var(--muted); font-size: .75rem; transition: transform .15s; }
tr.exp-row[aria-expanded="true"] .exp-caret { transform: rotate(90deg); }
tr.exp-detail > td { padding: 0; background: #fafbfc; }
table.subtable { border: 0; border-radius: 0; background: transparent; }
table.subtable th { background: transparent; }
table.subtable th, table.subtable td { padding: .4rem .7rem; font-size: .9rem; }

.docs-upload { margin: .3rem 0 .2rem; }
.docs-upload input[type=file] { padding: .35rem 0; font: inherit; }
.docs-upload .muted { margin: .25rem 0 0; }
.dropzone { display: inline-flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  border: 1.5px dashed var(--line); border-radius: 8px; padding: .5rem .7rem; background: var(--bg); }
.dropzone.dz-over { border-color: var(--accent); background: #eef4fb; }
.dropzone .dz-hint { color: var(--muted); font-size: .85rem; }
.dropzone .dz-hint.dz-err { color: #c0392b; }
.dropzone.dz-busy { opacity: .75; }
/* temperatura buttons: greyed out by default, lit in their colour when active */
.btn.temp { background: #eef2f7; color: var(--muted); opacity: .7; }
.btn.temp.on { opacity: 1; font-weight: 600; }
.btn.temp.on.temp-quente { background: #fde2d6; color: #9c2a10; }
.btn.temp.on.temp-morno  { background: #fdf6b2; color: #723b13; }
.btn.temp.on.temp-frio   { background: #e1effe; color: #1e429f; }

form.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
form.filters input, form.filters select { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
form.filters input.searchbox { flex: 1 1 20rem; min-width: 14rem; }
form.filters label.togglefilter { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
button { padding: .45rem .9rem; border: 0; border-radius: 7px; background: var(--accent); color: var(--accent-ink); font: inherit; cursor: pointer; }
button:hover { filter: brightness(1.05); }

form.actionform { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; }
form.actionform label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
form.actionform input, form.actionform select { padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.flash { padding: .6rem .9rem; border-radius: 8px; margin: 0 0 1rem; }
.flash.ok { background: #def7ec; color: #03543f; }
.flash.error { background: #fde8e8; color: #9b1c1c; }
.flash.premium { background: #fef9c3; color: #854d0e; }
/* client tiers (bronze < prata < ouro < premium) — banner on the ficha/consulta */
.flash.nivel-bronze  { background: #f1e2d2; color: #7c4a1e; }
.flash.nivel-prata   { background: #e8edf0; color: #455862; }
.flash.nivel-ouro    { background: #fdf1c4; color: #876409; }
.flash.nivel-premium { background: #fef9c3; color: #854d0e; }
/* «Ausentes hoje» heads-up on the Hoje dashboard (calm blue, not a warning) */
.flash.aviso { background: #e1effe; color: #1e429f; }
.flash.aviso strong { display: block; margin-bottom: .15rem; }
ul.ausentes-hoje { margin: 0; padding-left: 1.2rem; }
ul.ausentes-hoje li { line-height: 1.5; }
.resumo-box { border: 1px solid var(--line); border-left: 3px solid var(--accent, #2563eb); border-radius: 8px; padding: .6rem .9rem; margin: .25rem 0 1rem; max-width: 760px; background: var(--card, #fff); }
.resumo-box .resumo-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .35rem; }
.resumo-box .resumo-text { line-height: 1.5; }
.resumo-box .resumo-head { gap: .4rem; }
.relatorio-panel { margin-top: .7rem; border-top: 1px dashed var(--line); padding-top: .6rem; }
.relatorio-text { white-space: pre-wrap; line-height: 1.5; font-size: .93rem; }
/* Reclamações worklist (cards) + the consulta-detail complaint box */
.reclamacao-list { display: flex; flex-direction: column; gap: .8rem; }
.reclamacao-card, .reclamacao-box { border: 1px solid var(--line); border-left: 3px solid #cc0000; border-radius: 8px; padding: .7rem .9rem; background: var(--card, #fff); max-width: 820px; }
.reclamacao-box { margin: .25rem 0 1rem; }
.recl-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .2rem; }
.recl-meta { color: var(--muted); font-size: .9rem; margin-bottom: .4rem; }
.recl-nota { margin: .1rem 0 .4rem; font-size: .9rem; }
.recl-analise { line-height: 1.5; margin: .3rem 0 .5rem; }
.recl-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.recl-mark { display: flex; flex-direction: column; gap: .4rem; margin-top: .4rem; max-width: 480px; }
.recl-mark textarea { font: inherit; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; }
.b-recl { background: #fde2e2; color: #cc0000; }
th[title] { cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
.traduzir-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .1rem 0 .6rem; }
.traduzir-bar .btn { padding: .15rem .55rem; }
/* animated "a escrever"/loading indicator (3 bouncing dots) — chat + email translator */
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: typing 1s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.followup-form textarea { width: 100%; max-width: 640px; display: block; padding: .5rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; margin-bottom: .5rem; }
ul.followups { list-style: none; padding: 0; margin: .75rem 0; max-width: 760px; }
ul.followups li { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .5rem; background: var(--card); }
.fu-head { font-size: .8rem; color: var(--muted); margin-bottom: .25rem; }
.fu-text { white-space: pre-wrap; }
ul.doclist { list-style: none; padding: 0; margin: .4rem 0; }
ul.doclist li { padding: .15rem 0; }
ul.doclist label { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
ul.doclist input[type=checkbox] { width: 1.05rem; height: 1.05rem; cursor: pointer; }
.prazo { font-weight: 600; }
.prazo.atraso { color: #9b1c1c; }
.prazo.hoje { color: #b25e09; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal[hidden] { display: none; }
.modal-box { background: var(--card); border-radius: 12px; padding: 1.25rem 1.5rem; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-actions { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0 .5rem; }
.perito-agenda:not(:empty) { margin-top: .6rem; }
.agendaday { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .9rem; max-width: 900px; }
ul.agendaslots { list-style: none; padding: 0; margin: .4rem 0 0; }
ul.agendaslots li { padding: .2rem 0; border-top: 1px solid var(--line); }
ul.agendaslots li:first-child { border-top: 0; }
ul.agendaslots .slot { display: inline-block; min-width: 3.2rem; font-weight: 600; color: var(--accent); }
ul.agendaslots li.new { background: #e1effe; border-radius: 6px; }            /* slot being entered */
ul.agendaslots li.conflict { background: #fde8e8; }                           /* time clash */
ul.agendaslots li.conflict .slot { color: #9b1c1c; }
/* valor de produção do dia (peritos internos) — indicativo, meta ~1000€/dia */
.prod-dia { margin: .5rem 0 .25rem; padding: .35rem .6rem; border-radius: 8px; font-size: .9rem; }
.prod-dia.ok  { background: #def7ec; color: #03543f; }                         /* meta atingida */
.prod-dia.low { background: #fef9c3; color: #854d0e; }                         /* abaixo — pouco rentável */
.prod-dia .big { font-weight: 700; font-size: 1.05rem; }
.prod-dia .meta { opacity: .75; }
.prod-bar { height: 6px; margin-top: .35rem; border-radius: 999px; background: rgba(0,0,0,.08); overflow: hidden; }
.prod-bar > i { display: block; height: 100%; background: currentColor; opacity: .4; }

/* scheduling calendar */
.sched-cal { max-width: 360px; margin-top: .6rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.cal-nav { background: #eef2f7; color: var(--accent); border: 0; border-radius: 6px; padding: .1rem .6rem; cursor: pointer; font-size: 1.1rem; line-height: 1.2; }
.cal-earliest { margin: .2rem 0 .5rem; font-size: .9rem; }
.linklike { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-wd { text-align: center; font-size: .7rem; color: var(--muted); padding: .15rem 0; }
.cal-day { position: relative; aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 7px; background: var(--card); cursor: pointer; font: inherit; font-size: .85rem; color: var(--ink); }
.cal-day:hover { border-color: var(--accent); }
.cal-day.wknd { background: #f1f3f6; color: var(--muted); }
.cal-day.holi { background: #fdf6b2; color: #723b13; }
.cal-day.today { font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.earliest { box-shadow: inset 0 0 0 2px #1e8e3e; }
/* past days: dimmed — opacity keeps the weekend/holiday tint visible, just faded */
.cal-day.past { opacity: .4; }
.cal-day.past.sel { opacity: 1; }   /* a chosen past day (back-dating) stays fully visible */
.cal-day.sel { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 6px; height: 6px; border-radius: 50%; background: #1e8e3e; }
.cal-day.sel .cal-dot { background: #fff; }
.cal-legend { margin-top: .5rem; font-size: .75rem; color: var(--muted); display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.cal-legend .lg-wknd, .cal-legend .lg-holi { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; }
.cal-legend .lg-wknd { background: #f1f3f6; border: 1px solid var(--line); }
.cal-legend .lg-holi { background: #fdf6b2; }
.cal-legend .cal-dot { position: static; transform: none; display: inline-block; }
.duplist { margin: .4rem 0 0; padding-left: 1.2rem; }
.confirmrow { flex-direction: row !important; align-items: center; gap: .4rem; color: var(--ink) !important; }

.stateblock { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; }
.staterow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.staterow .lbl { min-width: 96px; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.staterow .actions { display: flex; gap: .4rem; flex-wrap: wrap; }
form.inline-action { display: inline; margin: 0; }
fieldset.anexos-existentes { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin: .25rem 0; }
fieldset.anexos-existentes legend { color: var(--muted); font-size: .85rem; padding: 0 .4rem; }
fieldset.anexos-existentes .confirmrow { display: flex; gap: .5rem; align-items: center; }
form.inline-edit { display: flex; gap: .4rem; align-items: center; margin: 0; flex-wrap: wrap; }
form.inline-edit input { flex: 1 1 16rem; min-width: 0; }
.btn { padding: .35rem .7rem; border: 0; border-radius: 7px; font: inherit; cursor: pointer; color: #fff; background: var(--accent); }
.btn.danger { background: #e02424; }
.danger-zone { margin-top: 1.5rem; padding: .9rem 1.1rem; border: 1px solid #e0242440; border-left: 3px solid #e02424; border-radius: 8px; background: #e024240a; max-width: 560px; }
.danger-zone h2 { margin: 0 0 .3rem; font-size: 1rem; }
.btn:hover { filter: brightness(1.06); }
a.btn { display: inline-block; text-decoration: none; }
.newbtn { margin-left: auto; }
form.actionform label > input, form.actionform label > select { display: block; margin-top: .15rem; }
form.actionform label.grow { flex: 1 1 24rem; }
form.actionform label.grow > input { width: 100%; }
/* consulta geo block: map on the left, distrito/concelho/morada fields on the right */
.geo-row { flex: 1 0 100%; display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.geo-fields { flex: 1 1 220px; display: flex; flex-direction: column; gap: .7rem; min-width: 200px; }
.mapwrap { flex: 0 0 auto; width: 280px; min-height: 370px; background: #eef2f7; border: 1px solid var(--line); border-radius: 8px; }
.mapwrap svg { width: 100%; height: 370px; display: block; }
@media (max-width: 560px) { .mapwrap { width: 100%; } }
/* price heatmap on the Preços page */
.preco-mapa, .consultas-mapa, .certidao-mapa { width: 100%; max-width: 640px; background: #fff; border: 1px solid var(--line); border-radius: 8px; margin: .25rem 0 1.25rem; }
.preco-mapa svg, .consultas-mapa svg, .certidao-mapa svg { width: 100%; height: auto; display: block; }
.preco-mapa svg path, .consultas-mapa svg path, .certidao-mapa svg path { stroke: #fff; stroke-width: .3; }
.mapa-metrica { font: inherit; color: inherit; padding: .05rem .35rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.mapa-toggle { display: inline-flex; gap: .4rem; margin: .1rem 0 .6rem; flex-wrap: wrap; }
.mapa-toggle + .mapa-toggle { margin-left: 1rem; }
.mapa-legend { display: flex; gap: .75rem; align-items: center; font-size: .85rem; color: var(--muted); margin: .25rem 0 .4rem; flex-wrap: wrap; }
.mapa-legend .swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; border: 1px solid var(--line); vertical-align: middle; margin-right: .2rem; }
#pt-concelhos path { fill: #b5bfca; stroke: #fff; stroke-width: .6; vector-effect: non-scaling-stroke; transition: fill .12s; cursor: pointer; }
#pt-concelhos path.hov { fill: #6f93b8; }
#pt-concelhos path.sel { fill: var(--accent); }
#pt-concelhos path.on { fill: var(--accent); }

/* Perito operating-constraints form (map + capability matrix) */
.adminform.restricoes { max-width: 860px; }
.restricoes-distritos { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.mapwrap.perito-map { width: 420px; min-height: 460px; }
.mapwrap.perito-map svg { height: 460px; }
/* single column: an expandable district must never split, so no CSS multicol here */
.restricoes-distritos .distrito-checks { flex: 1 1 220px; margin-top: 0; }
.cap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.cap-grid fieldset.cap-group { border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem .6rem; }
.cap-grid fieldset.cap-group legend { color: var(--muted); font-size: .85rem; padding: 0 .4rem; }
.adminform.restricoes .ro-note { font-style: italic; margin: .1rem 0 .4rem; }
.conc-group { margin: .05rem 0 .3rem 1.5rem; }
.conc-group > summary { color: var(--muted); font-size: .82rem; cursor: pointer; }
/* show ALL concelhos (no scroll cap — a hidden overflow looked like missing concelhos);
   2 compact columns keep the expanded list short */
.conc-checks { list-style: none; margin: .15rem 0 0; padding: 0; font-size: .9rem; columns: 2; column-gap: 1rem; }
.conc-checks li { padding: .05rem 0; break-inside: avoid; -webkit-column-break-inside: avoid; }
.distrito-item.conc-locked .conc-group { opacity: .4; }
@media (max-width: 560px) { .mapwrap.perito-map { width: 100%; } .conc-checks { columns: 1; } }

.telrow { display: flex; gap: .35rem; margin-top: .15rem; }
.telrow .cc { flex: 0 0 auto; max-width: 11rem; }
.telrow .flagbadge { flex: 0 0 auto; font-size: 1.35rem; line-height: 1; display: flex; align-items: center; }
.telrow .flagbadge:empty { display: none; }
.telrow input { flex: 1 1 auto; }
.schedwrap { padding: .25rem 0 .25rem 96px; }
.stateblock .flash { margin: .2rem 0 0; }
@media (max-width: 600px) { .schedwrap { padding-left: 0; } }

.typeahead { position: relative; flex: 1 1 24rem; min-width: 16rem; max-width: 32rem; }
.typeahead input { width: 100%; }
.ta-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 20; background: var(--card); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; box-shadow: 0 10px 24px rgba(0,0,0,.08); max-height: 320px; overflow-y: auto; }
.ta-item { display: block; padding: .5rem .7rem; border-bottom: 1px solid var(--line); color: var(--ink); }
.ta-item:last-child { border-bottom: 0; }
.ta-item:hover { background: #f0f4f9; text-decoration: none; }
.ta-sub { color: var(--muted); font-size: .85rem; }
.ta-empty { padding: .6rem .7rem; color: var(--muted); }

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.pginfo { color: var(--muted); }
.empty, .muted { color: var(--muted); }
.crumb { color: var(--muted); margin-bottom: .5rem; }
.h2row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

.items-section { flex: 1 0 100%; margin-top: .4rem; }
.items-lbl { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.item-row { display: flex; gap: .5rem; margin-bottom: .4rem; align-items: center; max-width: 460px; }
.item-row input, .item-row select { padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.item-row select[name=tipologia] { flex: 1 1 auto; }
.item-row .tipo { flex: 0 0 auto; min-width: 8rem; }
.item-row .qty { width: 4.5rem; }
.item-row { max-width: 620px; }
.item-del { background: #e02424; padding: .35rem .65rem; line-height: 1; }
.btn.ghost { background: #eef2f7; color: var(--accent); }
/* greyed-out, non-clickable, but still hoverable so its title tooltip shows */
.btn.disabled { opacity: .5; cursor: not-allowed; }
.tipchip { display: inline-block; background: #eef2f7; border-radius: 6px; padding: .1rem .5rem; margin: 0 .3rem .2rem 0; }

.adminform { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem 1.25rem; max-width: 560px; }
.adminform h2 { margin: 1.5rem 0 .5rem; }
.adminform h2:first-of-type { margin-top: 0; }
.adminform input, .adminform select { padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.adminform input.wide { display: block; width: 100%; margin-top: .2rem; }
.pricetable { width: 100%; margin-bottom: .5rem; }
.pricetable th { background: transparent; }
.pricetable td:first-child { font-weight: 500; }
.pricetable td input { width: 7rem; }
.pricetable td select { width: 100%; max-width: 16rem; }
/* Preço deste perito com preços por concelho: uma coluna por concelho, scroll horizontal
   dentro do bloco (nunca a página), a coluna da tipologia fica presa à esquerda */
.adminform.pc-form { max-width: 100%; }
.pc-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pricetable.pc-matriz { width: auto; }
.pricetable.pc-matriz td:first-child, .pricetable.pc-matriz th:first-child {
  position: sticky; left: 0; background: var(--card); z-index: 1; }
.pricetable.pc-matriz td input.pc-cell { width: 4.75rem; }
.pricetable.pc-matriz th.pc-concelho, .pricetable.pc-matriz th.pc-distrito {
  white-space: nowrap; font-size: .8rem; text-align: center; }
.pricetable.pc-matriz th.pc-distrito { border-bottom: 1px solid var(--line); text-align: left;
  border-left: 2px solid var(--line); }
/* Utilizadores: roomier form so Nome/Email get more width */
.usersform { max-width: 100%; }
.usertable th:nth-child(2), .usertable td:nth-child(2) { min-width: 10rem; }  /* Nome */
.usertable th:nth-child(3), .usertable td:nth-child(3) { width: 100%; }       /* Email grabs the slack */
.usertable td input.wide { width: 100%; min-width: 10rem; }   /* fill the cell, don't overflow */
/* Cada utilizador são DUAS linhas: a ficha e, por baixo, a matriz de módulos. Com
   tudo na mesma linha a tabela passava do ecrã e o `overflow:hidden` de `table`
   (o que lhe dá os cantos redondos) cortava as colunas da direita sem sequer deixar
   aparecer barra para rolar — a coluna Estado desapareceu assim (2026-09-22). */
.usertable tr.urow td { border-bottom: 0; padding-bottom: .35rem; }
.usertable tr.umods td { padding-top: 0; padding-bottom: .8rem; }
.usertable tr.umods .umodlbl { display: inline-block; margin-right: .35rem; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.usertable tr.umods .umodlbl:not(:first-child) { margin-left: .9rem; }
.usertable tr.urow td:first-child { font-weight: 500; }
/* live price preview on the consulta form */
.preco-preview { border: 1px solid var(--line); border-radius: 8px; padding: .25rem .85rem .6rem; background: var(--card); margin: .25rem 0 1rem; }
.preco-preview .empty { margin: .6rem 0; }
.cfgrow { display: flex; gap: 1.25rem; margin-bottom: .5rem; }
.cfgrow label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); gap: .2rem; }
.cfgrow input { max-width: 8rem; }
#lo-id-field[hidden], #worten-ref-field[hidden] { display: none; }   /* author display:flex above beats the UA [hidden] rule */
.emailpreview { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.25rem; margin: .25rem 0 1rem; max-width: 640px; }
.emailpreview.editable { border-style: dashed; cursor: text; }
.emailpreview.editable:focus { outline: 2px solid var(--accent, #2563eb); outline-offset: 2px; border-style: solid; }
.sigbox { width: 100%; max-width: 640px; font-family: monospace; font-size: .85rem; padding: .5rem; border: 1px solid var(--line); border-radius: 7px; }
.pricetotal { font-size: 1.15rem; margin-top: .75rem; }
.pricetotal strong { color: var(--accent); }
dl dd { white-space: nowrap; }

/* login */
.loginpage { display: grid; place-items: center; min-height: 100vh; }
.loginbox { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; width: 320px; display: flex; flex-direction: column; gap: .75rem; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.loginbox h1 { text-align: center; margin: 0 0 .5rem; }
.loginbox input { padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.loginbox button { padding: .65rem; }
.error { color: #9b1c1c; background: #fde8e8; padding: .5rem .7rem; border-radius: 7px; margin: 0; font-size: .9rem; }
.info { color: #166534; background: #e7f6ec; padding: .5rem .7rem; border-radius: 7px; margin: 0; font-size: .9rem; }
/* 2FA code page */
.twofa-sent { margin: 0; font-size: .92rem; color: var(--muted); text-align: center; }
.loginbox input[name=code] { text-align: center; font-size: 1.5rem; letter-spacing: .4rem; }
/* the typed digits stay big/spaced; the placeholder hint shrinks so it fits the box */
.loginbox input[name=code]::placeholder { font-size: .9rem; letter-spacing: normal; }
.twofa-timer { margin: 0; text-align: center; font-size: .9rem; color: var(--muted); }
.twofa-timer.expired { color: #9b1c1c; }
.loginbox.resend { width: 320px; padding: .6rem 2rem 1rem; flex-direction: row; justify-content: space-between; background: transparent; border: 0; box-shadow: none; margin-top: -.4rem; }
.linklike { background: none; border: 0; color: var(--accent, #2563eb); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
/* click-to-call: the phone number itself is a link that rings the agent + toast */
.callbtn { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: none; }
.callbtn:hover { text-decoration: underline; }
.callbtn:disabled { opacity: .5; cursor: progress; text-decoration: none; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%) translateY(1rem); opacity: 0; transition: opacity .25s, transform .25s; background: #222; color: #fff; padding: .6rem 1rem; border-radius: 8px; font-size: .9rem; box-shadow: 0 4px 14px rgba(0,0,0,.25); z-index: 1000; max-width: 90vw; }
.toast.toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-ok { background: #15803d; }
.toast.toast-err { background: #b91c1c; }
/* Enviar Declarações (DPD…): form mais largo, campos da declaração agrupados */
.adminform.declaracao { max-width: 760px; }
.adminform.declaracao fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem .8rem; margin: 0 0 1rem; }
.adminform.declaracao legend { color: var(--muted); font-size: .85rem; padding: 0 .4rem; }
.adminform.declaracao .formrow { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-end; }
.adminform.declaracao .formrow label { display: flex; flex-direction: column; gap: .2rem; }

/* Verificar FT › Aceitar documento — escolha dos IDs de certificação por perito
   (pedido Raúl 2026-09-03). Uma coluna: cada linha leva data + concelho + cliente. */
ul.ft-ids { font-size: .92rem; max-height: 26rem; overflow-y: auto; }
ul.ft-ids li { padding: .2rem 0; }
ul.ft-ids label { align-items: baseline; }
.ft-id-meta { color: var(--muted); font-size: .85rem; }
ul.ft-ids .fora { color: #9c2a10; font-weight: 600; font-size: .85rem; }
details.ft-mes > summary { cursor: pointer; color: var(--muted); font-size: .88rem; margin: .5rem 0 .1rem; }
.ft-mes-acoes { margin: .2rem 0 .1rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.ft-mes-acoes .btn { padding: .2rem .6rem; font-size: .82rem; }
/* Definições › Fornecedores ↔ peritos — uma linha do mapa por form */
.ft-mapa-linha { border: 1px solid var(--line); border-radius: 9px; padding: .6rem .75rem; margin: .5rem 0; }
.ft-mapa-linha code { font-size: .95rem; }

/* Impostos › SS › TSU — um bloco («slot») por mês fechado, do mais recente ao mais antigo */
.tsu-slot { border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px;
            background: var(--card); padding: .7rem 1rem; margin-bottom: .7rem; }
.tsu-slot.tsu-pago { border-left-color: #0e9f6e; }
.tsu-slot.tsu-por_pagar { border-left-color: #c27803; }
.tsu-slot.tsu-sem_guia { border-left-color: var(--line); }
/* IVA (mesma forma de slot): estados que a TSU não tem */
.tsu-slot.tsu-credito, .tsu-slot.tsu-nada { border-left-color: #0e9f6e; }
.tsu-slot.tsu-prestacoes, .tsu-slot.tsu-parcial { border-left-color: #c27803; }
.tsu-slot.tsu-sem_declaracao, .tsu-slot.tsu-explicado { border-left-color: var(--line); }
.iva-prest { list-style: none; margin: .45rem 0 .2rem; padding: 0; display: flex;
  flex-wrap: wrap; gap: .3rem 1.1rem; font-size: .88rem; }
.tsu-aviso-inline { color: #b42318; font-size: .85rem; }
.tsu-head { display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; }
.tsu-head h2 { margin: 0; font-size: 1.05rem; }
.tsu-valor { margin-left: auto; font-weight: 700; white-space: nowrap; }
.tsu-aviso { margin: .3rem 0 0; }
.tsu-docs { list-style: none; margin: .5rem 0; padding: 0; }
.tsu-docs li { margin: .2rem 0; }
.tsu-drops { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-top: .4rem; }
.tsu-drop { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; }
.tsu-droplbl { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem;
               color: var(--muted); }
.tsu-rodape { margin-top: 1.2rem; font-size: .85rem; }
.b-guia { background: #e1effe; color: #1e429f; }
.b-comprovativo { background: #def7ec; color: #03543f; }
.b-resolver { background: #fed7aa; color: #9a3412; }   /* IVA: prestação paga pela referência errada — não voltar a pagar */
.tsu-soltos { margin: 1rem 0; }
.tsu-soltos > summary { cursor: pointer; color: var(--accent); }
.tsu-aviso { margin: .3rem 0 0; color: #b42318; font-size: .88rem; }
.tsu-valor .muted { font-weight: 400; font-size: .8rem; }
.tsu-nota { margin: .25rem 0 0; font-size: .82rem; }
.tsu-valor.tsu-estimado { font-weight: 600; color: var(--muted); font-style: italic; }

/* Impostos › TSU: a certidão de não dívida em vigor (fundo da página) */
.tsu-certidao { border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px;
                background: var(--card); padding: .6rem 1rem; margin: 1.2rem 0; }
.tsu-certidao h2 { margin: 0 0 .2rem; font-size: 1rem; }
.tsu-certidao p { margin: 0; }
.tsu-cert-ok { border-left-color: #0e9f6e; }
.tsu-cert-falta { border-left-color: #c27803; }
.tsu-cert-divida { border-left-color: #c0392b; }
/* parte fixa de um email (salvaguarda / livre resolução / fecho): visível, não editável */
.emailpreview.fixo { background: #f6f7f5; color: #333; }
.emailpreview.fixo.texto { white-space: pre-wrap; font-family: inherit; }
/* imóvel novo (construção nova) — distingue-se à vista do existente, que é o caso comum */
.tipchip.edif-novo { background: #fff3cd; color: #6b4e00; }

/* Folha de despesas: um talão por linha, bem separado do seguinte (Raúl 2026-11-09) */
.adminform.folha-form { max-width: none; }
tr.talao-row > td { border-bottom: 3px solid #8a96a8; padding-top: .9rem; padding-bottom: .9rem;
                    vertical-align: top; }
tr.talao-row.alt > td { background: #f3f5f8; }
tr.talao-row:last-child > td { border-bottom: 0; }
