/* ==========================================================================
   Haver — Design system da aplicação
   ========================================================================== */
:root {
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    /* Logótipo e títulos do site comercial. */
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;

    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-2: #cbd5e1;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;

    --brand: #0f766e;
    --brand-2: #0d9488;
    --brand-soft: #ccfbf1;
    /* A marca em tons (2026-10-05): a escura para texto sobre fundo claro, a clarinha para fundos, a da linha para contornos e os
       componentes RGB para as transparências (as folhas de estilo usam-nos em vez de verde-água escrito à mão). */
    --brand-ink: #115e59;
    --brand-tint: #f0fdfa;
    --brand-line: #5eead4;
    --brand-rgb: 15, 118, 110;
    --accent: #2dd4bf;
    --accent-rgb: 45, 212, 191;
    --navy: #0f172a;
    --navy-2: #1e293b;

    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --warn: #d97706;
    --warn-soft: #fef3c7;
    /* Fundo das etiquetas laranja (propostos, por aprovar): o laranja da supervisão aclarado, não o amarelo dos avisos (2026-10-05). */
    --warn-tint: color-mix(in srgb, var(--warn) 18%, #fff);
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --info: #2563eb;
    --info-soft: #dbeafe;
    /* Quadros de valores (2026-10-13, nota do dono: «andamos sempre nos cinzas e verdes… deveríamos ter os quadros com alguma cor
       mais evidente, talvez com tons de azul»): as linhas dos lançamentos, o IVA de um documento em papel e o cálculo dos inventários. */
    --grid-rgb: 37, 99, 235;
    --grid-tint: #f4f8ff;
    --grid-ink: #1e3a8a;
    /* Separadores de pasta (2026-10-13). */
    --tab-line: #cbd5e1;
    --tab-edge: #d6dee9;
    --tab-bg: #e8eef7;
    --tab-bg-hover: #dde6f2;
    --tab-ink: #1e3a8a;
    --tab-icon: #1d4ed8;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 10px 40px rgba(15, 23, 42, .12);
    --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font-sans); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .35rem; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--font-mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.text-right { text-align: right; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Layout ------------------------------------------------------------------ */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #cbd5e1; display: flex; flex-direction: column; padding: 1rem .85rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1.15rem; padding: .35rem .5rem 1rem; letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-dark { color: var(--ink); }

/* Logótipo (Components/Shared/BrandLogo.razor): «H» de duas colunas (Deve | Haver) unidas pela barra âmbar do equilíbrio,
   e o nome em minúsculas. */
.hv-logo { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); line-height: 1; }
.hv-logo__mark { width: 30px; height: 30px; flex: none; display: block; }
.hv-logo__tile { fill: var(--navy); }
.hv-logo__col { fill: #f6f2e9; }
.hv-logo__bar { fill: #f59e0b; }
.hv-logo__word { font-family: var(--font-display); font-weight: 600; font-size: 1.42rem; letter-spacing: -.02em; }
.hv-logo--dark { color: #fff; }
.hv-logo--dark .hv-logo__tile { fill: #1e293b; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .35rem; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: .6rem; padding: .5rem .75rem; border-radius: var(--radius-sm); color: #cbd5e1; font-weight: 500; font-size: .93rem; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(var(--accent-rgb), .16); color: #fff; }
/* Ícones do menu (NavIcon.razor, 2026-10-13): desenhos de traço em SVG, da cor de destaque, em vez dos carateres Unicode. */
.nav-icon { width: 18px; height: 18px; flex: none; color: var(--accent); }
/* Os mesmos desenhos fora do menu (AppIcon.razor): cartões de Relatórios e Declarações, módulos, páginas vazias, ligações. */
.app-icon { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.22em; }
.report-icon .app-icon, .module-icon .app-icon { width: 22px; height: 22px; }
.empty-glyph .app-icon { width: 2.6rem; height: 2.6rem; color: var(--muted); }
.doc-fallback-icon .app-icon { width: 2.5rem; height: 2.5rem; }
.link-icon .app-icon { width: 15px; height: 15px; vertical-align: -2px; }
/* Barra de deslocamento do menu (com «Mostrar mais» aberto num ecrã baixo): fina e escura, como o menu. */
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, .35) transparent; }
.nav-badge { margin-left: auto; background: var(--warn); color: #fff; border-radius: 999px; font-size: .7rem; padding: .05rem .45rem; font-weight: 700; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--navy-2); color: #fff; font-weight: 700; font-size: .8rem; flex: none; }
.logout-form { margin: 0; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
/* Barra de cima, gaveta e barra inferior dos ecrãs estreitos (escondidas em ecrãs largos; ver @media (max-width: 860px)). */
.mobile-bar { display: none; position: sticky; top: 0; z-index: 30; align-items: center; gap: .6rem; padding: .5rem .75rem; padding-top: calc(.5rem + env(safe-area-inset-top)); background: var(--navy); color: #fff; }
.mobile-bar__btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; flex: none; }
.mobile-bar__burger { display: flex; flex-direction: column; gap: 4px; }
.mobile-bar__burger i { display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.mobile-bar__brand { display: inline-flex; align-items: center; margin-right: auto; color: #fff; text-decoration: none; min-width: 0; }
.mobile-bar__brand:hover { text-decoration: none; }
.mobile-bar__brand .hv-logo__mark { width: 28px; height: 28px; }
.mobile-bar__brand .hv-logo__word { font-size: 1.3rem; }
.mobile-bar__new { flex: none; }
.app-nav-backdrop { display: none; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sidebar-close { display: none; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: rgba(255,255,255,.08); color: #fff; font-size: 1rem; cursor: pointer; flex: none; }
.tabbar { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .15rem; padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 20px rgba(15,23,42,.06); }
.tabbar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-width: 0; min-height: 50px; padding: .25rem .15rem; border: 0; border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: .66rem; font-weight: 600; text-decoration: none; cursor: pointer; }
.tabbar__item:hover { text-decoration: none; color: var(--ink); }
.tabbar__item.active { color: var(--brand); background: var(--brand-soft); }
.tabbar__icon { width: 22px; height: 22px; flex: none; }
.tabbar__label { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabbar .nav-badge { position: absolute; top: .15rem; right: calc(50% - 1.55rem); margin: 0; font-size: .62rem; padding: .02rem .35rem; line-height: 1.4; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; }
/* Cabeçalho das páginas (2026-10-13, como no TOConline 3.0): as ações ficam sempre no canto superior direito; um subtítulo comprido
   quebra em várias linhas em vez de empurrar os botões para baixo do título (Documentos, Lançamentos). */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header > :first-child { flex: 1 1 24rem; min-width: 0; }
.page-header .actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.company-switcher { display: flex; align-items: center; gap: .6rem; }
.loading-screen { padding: 4rem; text-align: center; color: var(--muted); }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state h2 { color: var(--ink); }

/* Cards & grids ----------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .85rem; }
.card-header h2, .card-header h3 { margin: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-header { padding: 1rem 1.25rem 0; }
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: var(--shadow); }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .82rem; color: var(--muted); }
.kpi.ok .kpi-value { color: var(--ok); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.danger .kpi-value { color: var(--danger); }
.kpi.brand .kpi-value { color: var(--brand); }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }

/* Tables ------------------------------------------------------------------ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
/* Quadro de valores (2026-10-13): caixa com o contorno azul, fundo azul-claro e os títulos das colunas a azul; os campos continuam
   brancos. Os quadros das linhas dos lançamentos (.lines-box, .movement-entry) usam as mesmas cores. */
.table-wrap.value-grid { padding: .2rem .75rem .35rem; border: 1px solid rgba(var(--grid-rgb), .35); border-radius: 12px; background: var(--grid-tint); box-shadow: 0 1px 3px rgba(var(--grid-rgb), .08); }
.value-grid .table th { background: none; color: var(--grid-ink); }
.value-grid .table th, .value-grid .table td { border-bottom-color: rgba(var(--grid-rgb), .14); }
.value-grid .table tbody tr:hover { background: none; }
.value-grid .table tfoot td { background: none; border-bottom: 0; border-top: 1px solid rgba(var(--grid-rgb), .25); }
.table tbody tr:hover { background: #f8fafc; }
.table tr.clickable { cursor: pointer; }
.table tfoot td { font-weight: 700; background: var(--surface-2); }
.table .num { text-align: right; }
.table.compact th, .table.compact td { padding: .4rem .55rem; }
.table tr.level-1 td { font-weight: 700; background: #f1f5f9; }
.table tr.level-2 td { font-weight: 600; }
.table tr.total td { font-weight: 700; border-top: 2px solid var(--line-2); }

/* Listas numa só linha (2026-10-02: Lançamentos, Vendas, os movimentos de cada conta bancária, estes como no extrato do banco,
   e Clientes, fornecedores e produtos). Um registo por linha: as colunas ficam com a largura do conteúdo e a do texto
   (.cell-fill) com o resto, cortada com reticências (o texto inteiro fica na dica). Na .cell-line o texto (.cell-text) encolhe
   e a etiqueta ao lado (ex.: «Inativo») fica sempre à vista; .cell-cap corta um texto secundário (ex.: o nome de uma conta) e
   .wide-only só aparece acima de 1280 px (o que esconde fica na dica). Nos ecrãs estreitos a tabela guarda uma largura mínima e
   desliza na horizontal. */
.table.one-line th, .table.one-line td { white-space: nowrap; }
.table.one-line td.cell-fill { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.table.one-line .badge-pair { flex-wrap: nowrap; }
.table.one-line .cell-extra { color: var(--muted); }
.table.one-line .cell-line { display: flex; align-items: center; gap: .4rem; min-width: 0; }
.table.one-line .cell-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.table.one-line .cell-line .badge { flex: none; }
.table.one-line .cell-cap { display: inline-block; max-width: 13rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.table.one-line tbody tr.clickable:hover { background: var(--brand-tint); }
.table.one-line tbody tr.clickable:hover td:first-child { box-shadow: inset 3px 0 0 var(--brand); }
@media (max-width: 1280px) {
    .table.one-line .wide-only { display: none; }
}
@media (max-width: 860px) {
    .table.one-line { min-width: 760px; }
    .table.one-line td.cell-fill { min-width: 10rem; }
}

/* Buttons ----------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; background: var(--surface); color: var(--ink); transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-outline { border-color: var(--line-2); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: inherit; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }
.btn-ghost.text-danger { color: var(--danger); }
.btn-success { background: var(--ok); color: #fff; }
/* Contornos coloridos: verde = contabilizado, laranja = aguarda supervisão (a cor da supervisão em todo o lado). */
.btn-outline-ok { border-color: var(--ok); background: var(--ok-soft); color: #166534; }
.btn-outline-ok:hover { background: #bbf7d0; }
.btn-outline-warn { border-color: var(--warn); background: var(--warn-soft); color: #92400e; }
.btn-outline-warn:hover { background: #fde68a; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover { background: #b45309; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }

/* Forms ------------------------------------------------------------------- */
.form-field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; }
.form-field label { font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.form-inline label { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input, .select, .textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
    font: inherit; padding: .5rem .7rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); width: 100%; min-height: 38px;
}
.input:focus, .select:focus, .textarea:focus, input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13, 148, 136, .35); border-color: var(--brand); }
.input.invalid, .select.invalid, .modified.invalid { border-color: var(--danger); }
.validation-message { color: var(--danger); font-size: .8rem; }
.input-sm { padding: .3rem .5rem; min-height: 32px; font-size: .88rem; }
.select { appearance: auto; }
.help { font-size: .8rem; color: var(--muted); }
/* Ajuda que avisa (ex.: a periodicidade do IVA escolhida não é a deduzida do ficheiro): a cor de aviso ganha à da ajuda. */
.help.text-warn { color: var(--warn); }
.help.text-danger { color: var(--danger); }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.dropzone { border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); background: var(--surface-2); }
.dropzone.active { border-color: var(--brand); background: var(--brand-soft); }
.file-input { display: block; margin: .5rem auto 0; }
/* Arrastar e largar: o campo de ficheiros ocupa todo o quadro (invisível) — largar ou clicar em qualquer ponto funciona. */
.dropzone { position: relative; transition: background .12s, border-color .12s; }
.dropzone > .file-input, .dropzone .dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.dropzone > .file-input:disabled { cursor: progress; }
.dropzone.drag-over { border-color: var(--brand); background: var(--brand-soft); }
.dropzone .drop-hint { margin: .35rem 0 0; font-size: .8rem; color: var(--brand); }
.dropzone-compact { padding: .9rem 1rem; }
.input.num { text-align: right; }
.spinner-xs { width: 12px; height: 12px; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
/* Ficha de funcionário em separadores (sinal = dados em falta: laranja aviso, vermelho impede gravar). */
.employee-form { display: grid; grid-template-columns: 13.5rem minmax(0, 1fr); gap: 1.25rem; align-items: start; margin-top: .25rem; }
.employee-tabs { display: flex; flex-direction: column; gap: .15rem; padding: .4rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); position: sticky; top: 0; z-index: 1; }
.employee-tabs button { display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%; text-align: left; background: none; border: 0; border-left: 3px solid transparent; border-radius: var(--radius-sm); padding: .55rem .7rem; font: inherit; font-size: .9rem; font-weight: 600; color: var(--ink-2); cursor: pointer; transition: background .12s, color .12s; }
.employee-tabs button:hover { background: var(--surface); color: var(--ink); }
.employee-tabs button.active { background: var(--surface); color: var(--brand); border-left-color: var(--brand); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.employee-tabs button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.employee-panel { min-width: 0; }
/* Ficha de funcionário na janela: altura fixa (não muda de tamanho nem de posição ao trocar de separador); só o painel rola. */
.modal.modal-employee { height: min(92vh, 58rem); display: flex; flex-direction: column; overflow: hidden; }
.modal.modal-employee .employee-form { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
.modal.modal-employee .employee-panel { min-height: 0; overflow-y: auto; padding-right: .25rem; }
.modal.modal-employee .employee-tabs { align-self: start; }
.employee-panel-title { margin: 0 0 .85rem; padding-bottom: .45rem; border-bottom: 1px solid var(--line); font-size: 1.05rem; color: var(--ink); }
@media (max-width: 900px) {
    .employee-form { grid-template-columns: 1fr; gap: .75rem; }
    .employee-tabs { flex-direction: row; overflow-x: auto; position: static; }
    .employee-tabs button { width: auto; white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
    .employee-tabs button.active { border-bottom-color: var(--brand); }
}
.tab-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--warn); }
.tab-dot.blocking { background: var(--danger); }
.issue-list { list-style: none; margin: .75rem 0 0; padding: .55rem .8rem; background: var(--warn-soft); border-radius: var(--radius-sm); font-size: .85rem; color: #78350f; }
.issue-list li { margin: .15rem 0; }
.issue-list li.blocking { color: #991b1b; font-weight: 600; }
.issue-list .link-button { font-weight: 600; margin-right: .3rem; color: inherit; }
.issue-list .link-button::after { content: ":"; }
.complete-zone { margin-bottom: 1rem; text-align: left; }

/* Badges & alerts --------------------------------------------------------- */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: var(--line); color: var(--ink-2); }
.badge-ok { background: var(--ok-soft); color: #166534; }
.badge-warn { background: var(--warn-tint); color: #92400e; }
.badge-danger { background: var(--danger-soft); color: #991b1b; }
.badge-info { background: var(--info-soft); color: #1e3a8a; }
.badge-brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge-muted { background: #f1f5f9; color: var(--muted); }
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent; margin-bottom: 1rem; font-size: .92rem; }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: #7f1d1d; }
.alert-ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.alert-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e3a8a; }
/* Confiança: a bolinha do semáforo com a percentagem ao lado (2026-10-16; até então uma barra). */
.confidence { display: inline-flex; align-items: center; gap: .35rem; font-variant-numeric: tabular-nums; font-weight: 600; font-size: .85rem; white-space: nowrap; }
/* Semáforo da confiança (ConfidenceBadge, 2026-10-05): verde a partir de 95 %, vermelho só a 0 % (bloqueado), laranja no resto. */
.confidence-dot { display: inline-block; flex: none; width: .62rem; height: .62rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px rgba(255, 255, 255, .9); }
.confidence-dot.mid { background: var(--warn); }
.confidence-dot.low { background: var(--danger); }
.check-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.check-list li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.check-list li.fail::before { content: "✗ "; color: var(--danger); }
/* Separadores (2026-10-13, proposta A escolhida pelo dono depois de «muito cinzentos e verdes… quem não souber nem repara que são
   submenus»; antes, 2026-10-04, um interruptor segmentado cinzento): separadores de pasta assentes numa linha, o ativo branco com
   uma barra azul-escura em cima, a fazer corpo com a linha e com o que está por baixo; os outros em azul acinzentado. A linha é uma
   sombra interior do contentor, que o separador ativo tapa (assim também desliza nos ecrãs estreitos). Os de navegação levam o
   ícone da secção (AppIcon). O segundo nível (.sub-tabs) é sublinhado; as escolhas de um formulário (como repartir, o resultado de
   um reembolso) continuam um interruptor segmentado. */
.pill-tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .25rem; padding: 0 0 0 .75rem; margin-bottom: 1rem; box-shadow: inset 0 -1px 0 var(--tab-line); }
.pill-tabs button, .pill-tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem .8rem; border: 1px solid var(--tab-edge); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--tab-bg); font: inherit; font-size: .95rem; font-weight: 600; color: var(--ink-2); cursor: pointer; text-decoration: none; transition: background .12s, color .12s; }
.pill-tabs button:hover, .pill-tabs a:hover { background: var(--tab-bg-hover); color: var(--ink); text-decoration: none; }
.pill-tabs .active, .pill-tabs .active:hover { background: var(--surface); color: var(--ink); font-weight: 700; border-color: var(--tab-line); border-top: 3px solid var(--tab-ink); padding-top: calc(.6rem - 2px); }
.pill-tabs .app-icon { width: 17px; height: 17px; vertical-align: 0; color: var(--muted); }
.pill-tabs .active .app-icon { color: var(--tab-icon); }
.pill-tabs button:focus-visible, .pill-tabs a:focus-visible { outline: 2px solid var(--tab-ink); outline-offset: 1px; }
.pill-tabs button:disabled { opacity: .55; cursor: not-allowed; }
/* Segundo nível (ex.: Funcionários › Declarações; Centros de custo › Atribuir por): sublinhado, por baixo do primeiro. */
.pill-tabs:is(.sub-tabs, .cc-subtabs) { gap: 1.25rem; padding: 0; margin-top: -.25rem; box-shadow: inset 0 -1px 0 var(--line); }
.pill-tabs:is(.sub-tabs, .cc-subtabs) button, .pill-tabs:is(.sub-tabs, .cc-subtabs) a { padding: .45rem .1rem; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; font-size: .9rem; font-weight: 500; }
.pill-tabs:is(.sub-tabs, .cc-subtabs) button:hover, .pill-tabs:is(.sub-tabs, .cc-subtabs) a:hover { background: none; color: var(--tab-ink); }
.pill-tabs:is(.sub-tabs, .cc-subtabs) .active, .pill-tabs:is(.sub-tabs, .cc-subtabs) .active:hover { border: 0; border-bottom: 2px solid var(--tab-ink); padding-top: .45rem; background: none; color: var(--tab-ink); font-weight: 700; }
/* Escolhas de um formulário: interruptor segmentado (também a finalidade da validação do SAF-T). */
.pill-tabs:is(.rf-kind, .cc-method, .cc-split__method, .saft-purpose) { width: fit-content; max-width: 100%; align-items: center; padding: .25rem; gap: .25rem; background: var(--filter-bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: none; }
.pill-tabs:is(.rf-kind, .cc-method, .cc-split__method, .saft-purpose) button { border: 0; border-radius: 9px; padding: .5rem .9rem; background: none; }
.pill-tabs:is(.rf-kind, .cc-method, .cc-split__method, .saft-purpose) button:hover { background: rgba(255, 255, 255, .75); }
.pill-tabs:is(.rf-kind, .cc-method, .cc-split__method, .saft-purpose) .active, .pill-tabs:is(.rf-kind, .cc-method, .cc-split__method, .saft-purpose) .active:hover { border: 0; padding-top: .5rem; background: var(--surface); color: var(--tab-ink); box-shadow: 0 1px 2px rgba(15, 23, 42, .1), 0 0 0 1px var(--line); }

/* Auth -------------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 20% -10%, #ccfbf1 0%, transparent 60%), radial-gradient(900px 500px at 110% 110%, #fef3c7 0%, transparent 55%), var(--bg); padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow-lg); }
.auth-card .brand { padding: 0 0 1rem; }
.auth-card h1 { font-size: 1.5rem; }
.auth-demo { margin-top: 1.25rem; padding: .75rem; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .85rem; display: flex; flex-direction: column; gap: .25rem; }

/* Modal ------------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 760px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); padding: 1.5rem; }
.modal.wide { max-width: 1100px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* Misc -------------------------------------------------------------------- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.split-3-2 { grid-template-columns: 3fr 2fr; }
.doc-preview { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f1f5f9; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .5rem 0 .5rem 1.25rem; border-left: 2px solid var(--line); position: relative; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .9rem; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.kbd { font-family: var(--font-mono); font-size: .78rem; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 .35rem; }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; }
.pagination { display: flex; gap: .35rem; justify-content: flex-end; padding: .75rem; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line-2); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Operação longa que não se pode interromper (BusyOverlay, 2026-10-02): um quadro no meio do ecrã, por cima da página e do menu,
   com o indicador, o que está a acontecer e o tempo decorrido. */
.busy-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1rem; background: rgba(15, 23, 42, .45); }
.busy-card { width: min(27rem, 100%); padding: 1.6rem 1.5rem 1.25rem; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; }
.busy-card .spinner { width: 38px; height: 38px; border-width: 3px; }
.busy-card h2 { margin: .95rem 0 .4rem; font-size: 1.08rem; }
.busy-card p { margin: 0; color: var(--ink-2); font-size: .9rem; }
.busy-card .busy-elapsed { margin-top: .8rem; color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums; }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* Ecrãs estreitos (telemóvel, tablet ao alto): barra de cima, menu em gaveta, barra inferior, uma coluna, campos e botões
   maiores para o dedo. */
@media (max-width: 860px) {
    :root { --sidebar-w: min(84vw, 320px); }
    .app-shell { grid-template-columns: 1fr; }
    .mobile-bar { display: flex; }
    .sidebar { position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); height: 100vh; height: 100dvh; z-index: 70; padding-bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-104%); transition: transform .26s cubic-bezier(.2, .7, .2, 1); }
    html.app-nav-open .sidebar { transform: none; box-shadow: 24px 0 60px rgba(15, 23, 42, .45); }
    html.app-nav-open { overflow: hidden; }
    .app-nav-backdrop { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15, 23, 42, .55); opacity: 0; pointer-events: none; transition: opacity .2s; }
    html.app-nav-open .app-nav-backdrop { opacity: 1; pointer-events: auto; }
    .sidebar-close { display: inline-grid; }
    .sidebar .brand { padding-bottom: .5rem; }
    .tabbar { display: grid; }
    /* A barra de empresa deixa de ser fixa (a de cima já o é) e o seletor ocupa a largura toda. */
    .topbar { position: static; padding: .55rem .9rem; }
    .company-switcher { width: 100%; gap: .45rem; }
    /* Mais específico do que «.company-switcher .select { min-width: 340px }», declarado mais abaixo. */
    .topbar .company-switcher .select { min-width: 0; flex: 1 1 0%; width: 0; }
    .content { padding: 1rem .9rem calc(4.8rem + env(safe-area-inset-bottom)); }
    h1 { font-size: 1.35rem; }
    .page-header { margin-bottom: 1rem; }
    .page-header .actions { width: 100%; }
    .page-header .actions .btn { flex: 1 1 auto; }
    .card { padding: 1rem; margin-bottom: 1rem; }
    .card.flush { padding: 0; overflow-x: auto; }
    .card-header { flex-wrap: wrap; }
    .grid-2, .grid-3, .grid-4, .split, .split-3-2, .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .table { font-size: .86rem; }
    .table th, .table td { padding: .5rem .5rem; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* Campos: 16px evita o zoom automático do iOS ao focar; alvos de toque com pelo menos 42px. */
    .input, .select, .textarea, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="search"], input[type="month"], select, textarea { font-size: 16px; min-height: 42px; }
    .input-sm { font-size: 16px; min-height: 38px; }
    .btn { min-height: 40px; }
    .btn-sm { min-height: 36px; padding: .4rem .8rem; }
    .btn-group .btn { flex: 1 1 auto; }
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { flex: 1 1 auto; }
    .pill-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .pill-tabs::-webkit-scrollbar { display: none; }
    .pill-tabs button, .pill-tabs a { white-space: nowrap; }
    .toolbar .input, .toolbar .select { flex: 1 1 140px; min-width: 0; }
    /* Campos com rótulo por cima (.form-field, em coluna) dos relatórios: ali a base de 140px seria a altura (as datas ficavam
       ovais com 140px de altura, 2026-10-02). */
    .toolbar .form-field > .input, .toolbar .form-field > .select, .toolbar .form-field > select, .toolbar .form-field > input { flex: none; }
    .toolbar .spacer { display: none; }
    /* Janelas: folha a partir do fundo, com a largura toda. */
    .modal-backdrop { padding: 0; align-items: end; }
    .modal, .modal.wide { max-width: none; max-height: 96vh; max-height: 96dvh; border-radius: 18px 18px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
    .modal.modal-employee { height: 96vh; height: 96dvh; }
    .kpi-value { font-size: 1.45rem; }
    .doc-preview { height: 55vh; }
    .dropzone { padding: 1.5rem 1rem; }
    .empty-state { padding: 2.5rem 1rem; }
}

/* Total de um documento em moeda estrangeira: o valor na moeda e, por baixo, o contravalor em euros lançado. */
.doc-total { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.doc-total-eur { font-size: .8rem; }
/* Câmbio indicado à mão no detalhe do documento. */
.rate-form { display: grid; gap: .5rem; margin-top: .5rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); max-width: 26rem; }
.rate-form .form-field { display: grid; gap: .2rem; margin: 0; }
.rate-form .form-field span { font-size: .8rem; color: var(--muted); }
.rate-form .input { max-width: 12rem; }
.rate-form p { margin: 0; }

/* Empresa de testes: distintivo bem visível (seletor de empresa, lista de empresas, ficha). */
.badge-test { background: #fde68a; color: #7c2d12; border: 1px solid #f59e0b; font-weight: 700; letter-spacing: .04em; }

/* ---- Cabeçalho das páginas de recursos humanos (RhHeader): uma só linha, ações sempre à direita do título ---- */
.rh-header { flex-wrap: nowrap; align-items: center; min-height: 3.5rem; }
.rh-header .rh-header-text { min-width: 0; }
.rh-header h1 { white-space: nowrap; margin-bottom: .15rem; }
.rh-header .subtitle { margin: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-header .actions { flex-wrap: nowrap; flex-shrink: 0; }
@media (max-width: 900px) { .rh-header { flex-wrap: wrap; } .rh-header .subtitle { white-space: normal; } }

/* ---- Valores dos cartões (KPI): nunca quebram a linha; num cartão estreito a letra encolhe ---- */
.grid .kpi { container-type: inline-size; }
.kpi-value { white-space: nowrap; }
@container (max-width: 240px) { .kpi-value { font-size: 1.4rem; } }
@container (max-width: 190px) { .kpi-value { font-size: 1.2rem; } }

/* ---- Seletor de empresa: a contabilidade selecionada em destaque ---- */
.company-switcher .select { font-weight: 700; color: var(--brand-ink); border: 2px solid var(--brand); background: var(--brand-tint); min-width: 340px; padding-left: .8rem; }

/* ---- Menu lateral: «Mostrar mais» (secção Contabilidade) ---- */
.nav-more { display: flex; flex-direction: column; gap: 2px; }
.nav-more:not(.open) > .nav-link { display: none; }
.nav-more-toggle { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .35rem .75rem; border: 0; border-radius: var(--radius-sm); background: none; color: #94a3b8; font: inherit; font-size: .82rem; font-weight: 500; text-align: left; cursor: pointer; }
.nav-more-toggle:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-more-toggle .nav-icon { color: #64748b; transition: transform .15s ease; }
.nav-more.open .nav-more-toggle .nav-icon { transform: rotate(180deg); }
.nav-more .nav-more-hide, .nav-more.open .nav-more-show { display: none; }
.nav-more.open .nav-more-hide { display: inline; }

/* ---- Vista de gabinete (Empresas, Painel do gabinete, Avenças, Definições): sem barra de empresa no topo ---- */
.app-main.firm-area .settings-tabs { top: 0; }

/* Botão «Supervisão» das páginas de origem (Documentos, Vendas, Bancos, Lançamentos): a contagem do que falta tratar nessa página
   (nome próprio: .btn-count já existe no site, para contagens dentro de botões coloridos). */
.btn-supervision-count { margin-left: .4rem; background: var(--warn); color: #fff; border-radius: 999px; font-size: .72rem; padding: .05rem .45rem; font-weight: 700; line-height: 1.3; }
/* No botão laranja da supervisão, o número em branco. */
.btn-supervision .btn-supervision-count { background: #fff; color: #b45309; }

/* Botão «Regressar» (BackButton): sempre à esquerda do título, nas páginas a que se chega a partir de outra. Pílula cheia com a
   seta e a palavra, para não passar despercebido (só a seta num círculo passava); nos ecrãs estreitos fica por cima do título. */
.back-btn { display: inline-flex; align-items: center; gap: .45rem; height: 2.4rem; padding: 0 1rem 0 .8rem; border-radius: 999px; border: 1px solid var(--brand); background: var(--brand); color: #fff; text-decoration: none; font-size: .95rem; font-weight: 700; line-height: 1; white-space: nowrap; flex: none; box-shadow: 0 2px 8px rgba(var(--brand-rgb), .28); transition: background .15s, transform .15s; }
.back-btn-arrow { font-size: 1.2rem; line-height: 1; transition: transform .15s; }
.back-btn:hover { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.back-btn:hover .back-btn-arrow { transform: translateX(-3px); }
.back-btn:focus-visible { outline: 3px solid var(--brand-soft); outline-offset: 2px; }
.page-header .has-back { display: grid; grid-template-columns: auto 1fr; column-gap: .9rem; align-items: start; }
.page-header .has-back > .back-btn { grid-row: 1 / span 3; margin-top: .1rem; }
.page-header .has-back > h1, .page-header .has-back > p { grid-column: 2; }
@media (max-width: 640px) {
    .page-header .has-back { grid-template-columns: 1fr; row-gap: .6rem; }
    .page-header .has-back > .back-btn { grid-row: auto; justify-self: start; margin-top: 0; }
    .page-header .has-back > h1, .page-header .has-back > p { grid-column: 1; }
}

/* Coluna de seleção das tabelas com ações em lote (Imobilizado, Recursos humanos, pré-visualizações das importações) e botão
   «×» de retirar uma linha de uma pré-visualização. */
.table .select-col { width: 2rem; text-align: center; padding-left: .35rem; padding-right: .35rem; }
.table .select-col input { width: 1rem; height: 1rem; cursor: pointer; vertical-align: middle; }
.table .select-col input:disabled { cursor: not-allowed; opacity: .35; }
.table tr.selected td { background: var(--brand-soft); }
.row-remove { font-size: 1.15rem; line-height: 1; padding: .2rem .5rem; color: var(--muted, #64748b); }
.row-remove:hover { color: var(--danger, #b91c1c); background: rgba(185, 28, 28, .08); }
.select-col .row-remove { display: block; margin: .3rem auto 0; padding: .1rem .4rem; }

/* Cartões de indicadores que filtram (ex.: Documentos › E-mails recebidos): mesmo aspeto dos .kpi, clicáveis. */
.kpi-btn { display: block; width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; text-decoration: none; }
.kpi-btn > span { display: block; }
.kpi-btn:hover { border-color: var(--brand); }
.kpi-btn.active { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* Módulos do gabinete: um cartão por módulo, com o estado e o botão de ligar/desligar. */
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; }
.module-card { display: flex; flex-direction: column; gap: .6rem; border-left: 4px solid var(--line-2); }
.module-card.on { border-left-color: var(--ok); }
.module-head { display: flex; gap: .75rem; align-items: center; }
.module-head h2 { margin: 0 0 .2rem; }
.module-icon { width: 2.4rem; height: 2.4rem; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; flex: none; }
.module-card p { margin: 0; }
.module-list { margin: 0; padding-left: 1.1rem; color: var(--ink-2); font-size: .9rem; }
.module-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-top: .5rem; border-top: 1px solid var(--line); }

/* ---- Filtros e botões (2026-10-01): os filtros deixaram de se confundir com os botões ----
   Filtros (.toolbar): barra branca própria, encostada à tabela que filtra; campos compactos em pílula, de fundo cinzento e sem
   sombra, com a largura do texto escolhido, numa só linha sempre que cabem. Um filtro com valor fica verde-água (lista com outra
   opção que não a vazia, pesquisa com texto, caixa marcada): vê-se logo o que está a filtrar.
   Botões: retângulos com sombra; o secundário (.btn-outline) com texto e contorno verde-água; o fantasma (.btn-ghost) com texto
   verde-água e fundo ao passar o rato. */
:root {
    --filter-bg: #f1f5f9;
    --filter-line: #e2e8f0;
    --filter-on-bg: var(--brand-tint);
    --filter-on-line: var(--brand-line);
    --filter-on-ink: var(--brand-ink);
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%2364748b' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
    --chevron-on: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%230f766e' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
}
.toolbar { gap: .4rem; }
.toolbar:where(:not(.card .toolbar, .modal .toolbar)) { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem .6rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); margin-bottom: .75rem; }
/* Seguida do cartão da tabela, forma com ele um só bloco (por cima da sombra do cartão). Com :where, os estilos próprios de
   uma página (ex.: .gab-bulk, .ss-month) continuam a prevalecer. */
.toolbar:where(:not(.card .toolbar, .modal .toolbar):has(+ .card)) { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; position: relative; z-index: 1; }
.toolbar:where(:not(.card .toolbar, .modal .toolbar)) + .card { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
/* Campos com rótulo por cima (relatórios): alinhados pela base, com as caixas de marcar ao nível dos campos. */
.toolbar:has(> .form-field) { align-items: flex-end; }
.toolbar .input, .toolbar .select, .toolbar select, .toolbar input[type="search"], .toolbar input[type="text"], .toolbar input[type="month"], .toolbar input[type="date"], .toolbar input[type="number"] {
    min-height: 34px; height: 34px; padding: .25rem .85rem; font-size: .86rem; color: var(--ink-2); background-color: var(--filter-bg); border: 1px solid var(--filter-line); border-radius: 999px; box-shadow: none;
}
.toolbar .select, .toolbar select {
    appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
    background-image: var(--chevron); background-repeat: no-repeat; background-position: right .75rem center; background-size: 12px 12px;
}
.toolbar .input:hover, .toolbar .select:hover, .toolbar select:hover, .toolbar input[type="search"]:hover, .toolbar input[type="text"]:hover, .toolbar input[type="month"]:hover, .toolbar input[type="date"]:hover, .toolbar input[type="number"]:hover { border-color: var(--line-2); }
.toolbar .input:focus, .toolbar .select:focus, .toolbar select:focus, .toolbar input[type="search"]:focus, .toolbar input[type="text"]:focus, .toolbar input[type="month"]:focus, .toolbar input[type="date"]:focus, .toolbar input[type="number"]:focus { background-color: var(--surface); border-color: var(--brand); outline: 2px solid rgba(13, 148, 136, .2); outline-offset: 0; }
.toolbar select:has(option[value=""]):not(:has(option[value=""]:checked)),
.toolbar input[placeholder]:not(:placeholder-shown) { background-color: var(--filter-on-bg); border-color: var(--filter-on-line); color: var(--filter-on-ink); font-weight: 600; }
.toolbar select:has(option[value=""]):not(:has(option[value=""]:checked)) { background-image: var(--chevron-on); }
/* Campo «Exercício» de um relatório ou declaração no exercício de trabalho, quando este não é o que está a decorrer (2026-10-14,
   WorkingYearState.Mark): laranja, para se ver que as outras páginas com ano também abrem nele. Depois das pílulas das barras de
   filtros e mais forte do que elas, que de outro modo o tapavam. */
.select.is-working-year, .toolbar .select.is-working-year { border-color: var(--warn); background-color: var(--warn-soft); color: #92400e; font-weight: 700; }
.toolbar > label:has(> input[type="checkbox"]) { display: inline-flex; align-items: center; gap: .4rem; height: 34px; padding: 0 .85rem 0 .7rem; border: 1px solid var(--filter-line); border-radius: 999px; background: var(--filter-bg); font-size: .86rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.toolbar > label:has(> input[type="checkbox"]):hover { border-color: var(--line-2); }
.toolbar > label:has(> input[type="checkbox"]:checked) { background: var(--filter-on-bg); border-color: var(--filter-on-line); color: var(--filter-on-ink); font-weight: 600; }
.toolbar > label > input[type="checkbox"] { width: auto; min-height: 0; margin: 0; accent-color: var(--brand); }
/* Botão de ordem (2026-10-12, «Confiança ↕» na supervisão): pílula como os filtros, verde-água com uma ordem escolhida (aria-pressed). */
.toolbar > .filter-toggle { display: inline-flex; align-items: center; flex: none; height: 34px; padding: 0 .85rem; border: 1px solid var(--filter-line); border-radius: 999px; background: var(--filter-bg); font: inherit; font-size: .86rem; font-weight: 500; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.toolbar > .filter-toggle:hover { border-color: var(--line-2); }
.toolbar > .filter-toggle:focus-visible { border-color: var(--brand); outline: 2px solid rgba(13, 148, 136, .2); outline-offset: 0; }
.toolbar > .filter-toggle[aria-pressed="true"] { background: var(--filter-on-bg); border-color: var(--filter-on-line); color: var(--filter-on-ink); font-weight: 600; }
/* Larguras (ecrãs largos): as listas ficam com a largura da opção escolhida; as pesquisas crescem até ao máximo quando sobra
   espaço; .filter-narrow para campos curtos (ex.: prefixo de conta). */
@media (min-width: 861px) {
    .toolbar > .select, .toolbar > select { flex: 0 1 auto; width: auto; min-width: 0; max-width: 13rem; field-sizing: content; }
    .toolbar > input[type="search"], .toolbar > .input:not([type]), .toolbar > input[type="text"] { flex: 1 1 10rem; width: auto; min-width: 8rem; max-width: 16rem; }
    .toolbar > .input.filter-narrow { flex: 1 1 7rem; min-width: 6rem; max-width: 9rem; }
    .toolbar > input[type="month"], .toolbar > input[type="date"] { flex: 0 0 auto; width: auto; min-width: 0; }
}
/* A contagem fica à direita; se não couber na linha dos filtros, desce sozinha, também à direita. */
.toolbar > .spacer ~ span.muted.small { white-space: nowrap; margin-left: auto; }
.toolbar .btn-sm { min-height: 34px; }

.btn-primary { box-shadow: 0 1px 2px rgba(var(--brand-rgb), .3), 0 3px 8px rgba(var(--brand-rgb), .18); }
.btn-outline { color: var(--brand); border-color: rgba(var(--brand-rgb), .4); box-shadow: 0 1px 2px rgba(15, 23, 42, .07); }
.btn-outline:hover { background: var(--filter-on-bg); border-color: var(--brand); color: var(--brand-ink); }
.btn-outline:disabled:hover { background: var(--surface); border-color: rgba(var(--brand-rgb), .4); color: var(--brand); }
.btn-outline.text-danger { color: var(--danger); border-color: #fca5a5; }
.btn-outline.text-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: #b91c1c; }
.btn-ghost { color: var(--brand); }
.btn-ghost:hover { background: rgba(var(--brand-rgb), .08); }
.btn-ghost.text-danger:hover { background: rgba(220, 38, 38, .08); }
.btn-ghost.text-ok { color: var(--ok); }
.sidebar .btn-ghost { color: inherit; }
.sidebar .btn-ghost:hover { background: rgba(255, 255, 255, .08); }
/* No site comercial, «.site a» pinta as ligações de verde-água: um botão principal que seja ligação ficava com o texto da cor do
   fundo (ex.: «Voltar ao início» da página não encontrada). */
.site a.btn-primary, .site a.btn-primary:hover { color: #fff; }
/* Entrar com Microsoft/Google: neutro, como nos outros sites. */
.sso-btn, .sso-btn:hover { color: var(--ink); border-color: var(--line-2); }
.sso-btn:hover { background: var(--surface-2); }

@media (max-width: 860px) {
    .toolbar:where(:not(.card .toolbar, .modal .toolbar)) { padding: .5rem; }
    .toolbar > .select, .toolbar > select, .toolbar > .input, .toolbar > input { flex: 1 1 140px; min-width: 0; max-width: none; }
    .toolbar .input, .toolbar .select, .toolbar select, .toolbar input[type="search"], .toolbar input[type="text"], .toolbar input[type="month"], .toolbar input[type="date"], .toolbar input[type="number"] { height: 40px; min-height: 40px; font-size: 16px; }
    .toolbar > label:has(> input[type="checkbox"]), .toolbar > .filter-toggle, .toolbar .btn-sm { min-height: 40px; height: auto; }
    .toolbar > .spacer ~ span.muted.small { white-space: normal; }
}

/* ---- Consulta de uma ficha num clique (2026-10-03, sugestão do contabilista): o código de uma conta, cliente, fornecedor ou
   produto (PeekLink) e o ⓘ dos campos editáveis e das opções das pesquisas (PeekButton) abrem a ficha na janela flutuante
   RecordPeekHost, por cima das janelas modais (mas abaixo do quadro de operação longa). ---- */
.peek-link { display: inline; padding: 0; margin: 0; border: 0; background: none; font: inherit; color: inherit; text-align: inherit; cursor: pointer; text-decoration: underline dotted; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.peek-link:hover, .peek-link:focus-visible { color: var(--brand); text-decoration-color: var(--brand); }
.peek-btn { display: inline-grid; place-items: center; flex: none; width: 1.3rem; height: 1.3rem; margin: 0 0 0 .2rem; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: .92rem; line-height: 1; vertical-align: middle; cursor: pointer; }
.peek-btn:hover, .peek-btn:focus-visible { color: var(--brand); background: var(--surface-2); }
.modal-backdrop.modal-floating:has(> .modal.record-peek) { z-index: 150; }
/* A janela de consulta de uma ficha distingue-se das outras janelas (2026-10-04, pedido do dono): cabeçalho escuro, o mesmo em todas
   as consultas (conta, cliente, fornecedor, produto), sem cores por tipo de ficha (2026-10-05). */
.modal.record-peek { --peek-head: #1e293b; }
.modal-floating .modal.record-peek .modal-header { background: var(--peek-head); border-bottom-color: transparent; color: #fff; }
.modal.record-peek .modal-header h2 { color: #fff; }
.modal.record-peek .modal-header .muted { color: rgba(255, 255, 255, .78); }
.modal.record-peek .modal-header .btn-outline { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); box-shadow: none; }
.modal.record-peek .modal-header .btn-outline:hover { background: rgba(255, 255, 255, .14); border-color: #fff; }
.modal.record-peek .modal-grip { background: rgba(255, 255, 255, .45); }
.record-peek__badges { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .65rem; }
.record-peek__section { margin: 0 0 .8rem; }
.record-peek__section h3 { margin: 0 0 .3rem; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.record-peek__section dl { display: grid; grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr); gap: .2rem .8rem; margin: 0; font-size: .87rem; }
.record-peek__section dt { color: var(--muted); }
.record-peek__section dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.record-peek__notes p { margin: 0; font-size: .87rem; white-space: pre-line; }
.record-peek__actions { flex-wrap: wrap; margin-top: .25rem; }
.record-peek__back { margin-right: auto; }
/* O ⓘ das opções das pesquisas de contas, clientes e produtos fica encostado à direita da opção, fora da grelha dela. */
.ap-item:has(> .peek-btn), .pp-item:has(> .peek-btn), .acct-dropdown li:has(> .peek-btn) { position: relative; padding-right: 2rem; }
.ap-item > .peek-btn, .pp-item > .peek-btn, .acct-dropdown li > .peek-btn { position: absolute; top: 50%; right: .35rem; margin: 0; transform: translateY(-50%); }

/* ---- Validação do SAF-T (2026-10-14, Declarações › SAF-T de contabilidade): cada inconformidade com a correção ao lado; os grupos
   com a lista por baixo e «Aplicar todas»; antes de aplicar em bloco, o que vai mudar. ---- */
.saft-toolbar { align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.saft-toolbar .pill-tabs { margin-bottom: 0; }
.saft-summary { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.saft-confirm { margin: 0 0 1rem; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.saft-confirm p { margin: 0 0 .5rem; }
.saft-confirm .msg-list { margin: 0 0 .5rem; }
.saft-result details { margin-top: .35rem; }
.saft-period { flex-wrap: wrap; }
.saft-period .input { min-width: 0; max-width: 100%; }
.saft-hint { margin: .25rem 0 0; }
.saft-resolved { margin-top: .3rem; color: var(--ink-2); }
.saft-entry { margin: .5rem 0 .25rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.saft-entry .table { margin: .4rem 0; background: var(--surface); }
.saft-entry .num { text-align: right; white-space: nowrap; }
.saft-entry .row { align-items: center; gap: .5rem; flex-wrap: wrap; }

/* Navegação entre páginas (2026-10-14, nota do dono: «faz scroll para o início da página e depois é que muda de página… é também o
   motivo de haver algum flickering»): enquanto a página nova não chega, uma barra fina no cimo mostra que está a carregar (app.js). */
html.nav-loading { cursor: progress; }
html.nav-loading::before {
    content: ""; position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 10000; pointer-events: none;
    background: linear-gradient(90deg, transparent 0%, var(--brand) 50%, transparent 100%) no-repeat;
    background-size: 40% 100%; animation: nav-loading 1.1s linear infinite;
}
@keyframes nav-loading { from { background-position: -40% 0; } to { background-position: 140% 0; } }
.conf-table td { vertical-align: top; }
.conf-fix { display: inline-flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.conf-fix .select { max-width: 240px; }
.conf-fix .input { width: 150px; }
.conf-items { list-style: none; margin: .45rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.conf-items li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
@media (min-width: 861px) { .conf-fix-col { width: 300px; } }
/* Telemóveis: cada inconformidade empilhada (gravidade, texto, correção) e o interruptor da finalidade à largura toda. */
@media (max-width: 600px) {
    .saft-toolbar .pill-tabs.saft-purpose { width: 100%; }
    .pill-tabs.saft-purpose button { flex: 1 1 0; justify-content: center; white-space: normal; text-align: center; }
    .conf-table thead { display: none; }
    .conf-table, .conf-table tbody, .conf-table tr, .conf-table td { display: block; width: auto; }
    .conf-table tr { padding: .55rem 0; border-bottom: 1px solid var(--line); }
    .conf-table td { border: 0; padding: .15rem 0; }
    .conf-fix .input { width: 100%; min-width: 0; flex: 1 1 140px; }
    .conf-fix .select { max-width: 100%; }
}

/* ---- Atualizações do Haver (2026-10-14): o aviso nas páginas antes da troca de versão (UpdateNoticeBanner) e a janela «Ligação
   ao Haver interrompida» enquanto o servidor está parado (ReconnectModal + js/reconnect.js; o Blazor muda as classes da janela). ---- */
.update-notice { border-left: 4px solid var(--warn); }
.reconnect-modal { width: min(26rem, calc(100vw - 2rem)); margin: 18vh auto auto; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); box-shadow: 0 18px 48px rgba(15, 23, 42, .28); }
.reconnect-modal::backdrop { background: rgba(15, 23, 42, .45); }
.reconnect-modal__body { padding: 1.5rem 1.5rem 1.25rem; text-align: center; }
.reconnect-modal__body h2 { margin: .25rem 0 .6rem; font-size: 1.1rem; }
.reconnect-modal__body p { margin: 0 0 .5rem; }
.reconnect-modal__hint { margin-top: .75rem !important; }
.reconnect-modal__actions { justify-content: center; margin-top: 1rem; }
.reconnect-modal .components-reconnect-first-attempt-visible,
.reconnect-modal .components-reconnect-repeated-attempt-visible,
.reconnect-modal .components-reconnect-failed-visible,
.reconnect-modal .components-pause-visible,
.reconnect-modal .components-resume-failed-visible,
.reconnect-modal .components-rejoining-animation { display: none; }
.reconnect-modal.components-reconnect-show .components-reconnect-first-attempt-visible,
.reconnect-modal.components-reconnect-show .components-rejoining-animation,
.reconnect-modal.components-reconnect-retrying .components-reconnect-repeated-attempt-visible,
.reconnect-modal.components-reconnect-retrying .components-rejoining-animation,
.reconnect-modal.components-reconnect-failed .components-reconnect-failed-visible,
.reconnect-modal.components-reconnect-paused .components-pause-visible,
.reconnect-modal.components-reconnect-resume-failed .components-resume-failed-visible { display: block; }
/* O Blazor junta «retrying» a «show»: fica só a contagem da tentativa seguinte. */
.reconnect-modal.components-reconnect-retrying .components-reconnect-first-attempt-visible { display: none; }
.reconnect-modal.components-reconnect-failed .reconnect-modal__actions .components-reconnect-failed-visible,
.reconnect-modal.components-reconnect-paused .reconnect-modal__actions .components-pause-visible,
.reconnect-modal.components-reconnect-resume-failed .reconnect-modal__actions .components-resume-failed-visible { display: inline-flex; }

/* ---- Janela flutuante (AdminModal com Floating; Plano de contas): a página por baixo continua visível e utilizável, porque o
   fundo não escurece nem apanha cliques (só a janela os apanha). Abre encostada à direita, com sombra, e arrasta-se pelo
   cabeçalho (iacc.floatingWindow guarda a posição num transform). Fica abaixo da gaveta do menu dos ecrãs estreitos. ---- */
.modal-backdrop.modal-floating { display: block; padding: 0; background: none; pointer-events: none; z-index: 60; }
.modal-floating > .modal { position: fixed; top: 4.75rem; right: 1rem; width: min(31rem, calc(100vw - 2rem)); max-width: none; max-height: calc(100vh - 5.75rem); max-height: calc(100dvh - 5.75rem); display: flex; flex-direction: column; overflow: hidden; padding: 0; pointer-events: auto; border: 1px solid var(--line-2); box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 4px 14px rgba(15, 23, 42, .12); }
.modal-floating > .modal.wide { width: min(46rem, calc(100vw - 2rem)); }
.modal-floating .modal-header { position: relative; flex: none; gap: .75rem; margin: 0; padding: 1.05rem 1.25rem .7rem; background: var(--surface-2); border-bottom: 1px solid var(--line); cursor: move; touch-action: none; -webkit-user-select: none; user-select: none; }
.modal-floating .modal-header h2 { font-size: 1.1rem; }
.modal-grip { position: absolute; top: .4rem; left: 50%; width: 2.5rem; height: .3rem; margin-left: -1.25rem; border-radius: 999px; background: var(--line-2); }
.modal-floating-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 1rem 1.25rem 1.25rem; }
.modal-floating .form-grid { grid-template-columns: 1fr; }
.modal-floating-hint { margin: 0 0 .85rem; font-size: .8rem; color: var(--muted); }
/* Ecrãs estreitos (onde as outras janelas passam a folha em baixo): em baixo, com a largura toda e pouco mais de meio ecrã de
   altura, para se ver o plano por cima; arrasta-se na vertical e o fim da página pode subir acima da janela. */
@media (max-width: 860px) {
    .modal-floating > .modal, .modal-floating > .modal.wide { top: auto; right: 0; bottom: 0; left: 0; width: auto; max-height: 55vh; max-height: 55dvh; padding: 0; border-width: 1px 0 0; border-radius: 18px 18px 0 0; }
    .modal-floating .modal-header { padding: 1.1rem 1rem .6rem; }
    .modal-floating-body { padding: .85rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
    .content:has(.modal-floating) { padding-bottom: calc(55vh + 1rem); }
}

/* Impressão (todas as páginas, 2026-10-02): no papel o browser aplica as regras dos ecrãs estreitos, por isso a barra de cima do
   telemóvel saía na primeira página e a barra de baixo, fixa, repetia-se no fundo de todas, por cima das últimas linhas. Essas
   barras e o botão «Regressar» não vão para o papel. */
@media print {
    .mobile-bar, .tabbar, .back-btn { display: none !important; }
    /* Páginas numeradas em todos os documentos impressos (nota da contabilista de 2026-10-05: «Nos documentos (ex: balancetes)
       numerar as páginas»), em baixo à direita, na margem da folha. */
    @page {
        @bottom-right { content: "Página " counter(page) " de " counter(pages); font-family: Inter, system-ui, "Segoe UI", sans-serif; font-size: 7.5pt; color: #555; }
    }
}

/* Campo ou cartão para onde uma ligação levou (iacc.focusField, app.js; regra do dono de 2026-10-11): um anel que se desvanece. */
.field-highlight { border-radius: 10px; animation: field-highlight 3s ease-out; }
@keyframes field-highlight {
    0%, 45% { box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .6), 0 0 0 10px rgba(var(--brand-rgb), .14); }
    100% { box-shadow: 0 0 0 0 rgba(var(--brand-rgb), 0), 0 0 0 0 rgba(var(--brand-rgb), 0); }
}
@media (prefers-reduced-motion: reduce) { .field-highlight { animation: none; outline: 3px solid rgba(var(--brand-rgb), .6); outline-offset: 3px; } }

/* Dado do perfil fiscal em falta indicado no próprio aviso da declaração (ProfileFieldFix; testes das declarações, 2026-10-13). */
.profile-fix { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .1rem .4rem; vertical-align: middle; }
.profile-fix .input { width: 9.5rem; }
.profile-fix-all { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: inherit; white-space: nowrap; }
.profile-fix-error { flex-basis: 100%; font-size: .85rem; color: var(--danger, #b42318); }
