/* ============================================================
   Laser Build — Orçamentos
   Sistema visual estilo Apple (muito branco, sombras suaves,
   amarelo de marca #FECE00 com parcimónia, mono nos números).
   Adaptado do design Laser Build (Claude Design).
   Sem framework. Variáveis CSS para afinação fácil.
   ============================================================ */

:root {
    /* ---- Marca / tinta ---- */
    --brand: #FECE00;
    --brand-deep: #E7B900;
    --brand-soft: #FFF6D6;
    --ink: #1A1A17;
    --ink-soft: #6C6C64;
    --ink-faint: #A0A096;
    --bg: #F3F3F0;
    --surface: #FFFFFF;
    --surface-2: #FAFAF8;
    --line: #E9E9E3;
    --line-soft: #F1F1EC;

    /* ---- Tons (estados / badges) ---- */
    --tone-neutro-bg: #EFEFEA;   --tone-neutro-fg: #74746B;
    --tone-azul-bg: #E9F0F6;     --tone-azul-fg: #3672A0;
    --tone-amarelo-bg: #FBF0D2;  --tone-amarelo-fg: #997400;
    --tone-verde-bg: #E6F1E9;    --tone-verde-fg: #2E7D52;
    --tone-vermelho-bg: #F8E9E7; --tone-vermelho-fg: #BF453C;

    /* ---- Sombras / raios / tipografia ---- */
    --sh-card: 0 1px 2px rgba(26,26,23,.04), 0 5px 18px rgba(26,26,23,.045);
    --sh-hover: 0 2px 6px rgba(26,26,23,.06), 0 16px 38px rgba(26,26,23,.09);
    --sh-pop: 0 8px 30px rgba(26,26,23,.12);
    --r-lg: 20px; --r-md: 14px; --r-sm: 10px;
    --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Monaco, "Cascadia Code", monospace;
    --side-w: 248px;

    /* ---- Aliases de compatibilidade (nomes antigos) ---- */
    --cor-primaria: var(--brand-deep);
    --cor-primaria-escura: #C9A300;
    --cor-texto: var(--ink);
    --cor-suave: var(--ink-soft);
    --cor-borda: var(--line);
    --cor-fundo: var(--bg);
    --cor-branco: var(--surface);
    --cor-ok: var(--tone-verde-fg);
    --cor-ok-fundo: var(--tone-verde-bg);
    --cor-erro: var(--tone-vermelho-fg);
    --cor-erro-fundo: var(--tone-vermelho-bg);
    --cor-aviso: var(--tone-amarelo-fg);
    --cor-aviso-fundo: var(--tone-amarelo-bg);
    --raio: var(--r-sm);
    --sidebar-largura: var(--side-w);
    --sombra: var(--sh-card);
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[x-cloak] { display: none !important; }
svg { display: block; }
::selection { background: var(--brand); color: var(--ink); }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input { font: inherit; color: inherit; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 0.88em; font-family: var(--mono); }
h1, h2, h3 { letter-spacing: -0.02em; }

.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: -0.02em; }
.dim, .texto-suave { color: var(--ink-soft); }
.r { text-align: right; }

/* ============ ESTRUTURA GERAL ============ */
.app { display: flex; min-height: 100vh; }

/* ---- Barra de modo de desenvolvimento (só fora de produção) ---- */
.devbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 26px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--tone-amarelo-bg); color: var(--tone-amarelo-fg);
    border-bottom: 1px solid #EFDFB0; font-size: 11.5px; font-weight: 700;
    letter-spacing: .06em; text-transform: uppercase; user-select: none; }
.devbar__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-deep); flex: 0 0 auto; }
/* Empurra o conteúdo para baixo da barra e ajusta os elementos «sticky». */
body.tem-devbar { padding-top: 26px; }
body.tem-devbar .app { min-height: calc(100vh - 26px); }
body.tem-devbar .sidebar { top: 26px; height: calc(100vh - 26px); }
body.tem-devbar .topo { top: 26px; }
body.tem-devbar .impersonate-bar { top: 26px; }

/* ---- Barra lateral (clara, estilo Apple) ---- */
.sidebar {
    width: var(--side-w); flex-shrink: 0;
    background: var(--surface); color: var(--ink-soft);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: 22px 16px 18px;
    /* Fixa a barra lateral no ecrã (como a do topo). No mobile, o media query
       abaixo volta a position:fixed (drawer), por isso não é afetado. */
    position: sticky; top: 0; align-self: flex-start;
    height: 100vh; overflow-y: auto;
}
.sidebar__marca { display: flex; align-items: center; padding: 4px 10px 22px; overflow: hidden; }
.sidebar__marca a { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); font-weight: 800; font-size: 18px; letter-spacing: -0.04em; max-width: 100%; }
.sidebar__logo { height: 30px; max-height: 30px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.sidebar__sub { display: none; }

.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---- Topo ---- */
.topo {
    height: 64px; flex-shrink: 0;
    display: flex; align-items: center; gap: 14px;
    padding: 0 26px;
    background: rgba(255,255,255,.72);
    border-bottom: 1px solid var(--line);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    position: sticky; top: 0; z-index: 30;
}
.topo__menu {
    display: none; width: 38px; height: 38px; border-radius: var(--r-sm);
    place-items: center; color: var(--ink); font-size: 20px;
}
.topo__menu:hover { background: var(--surface-2); }
.topo__pesquisa {
    flex: 1; max-width: 440px; display: flex; align-items: center; gap: 9px;
    padding: 9px 13px; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 11px; color: var(--ink-faint); transition: border-color .15s;
}
.topo__pesquisa:focus-within { border-color: var(--ink-faint); }
.topo__pesquisa input { flex: 1; font-size: 13.5px; color: var(--ink); border: 0; outline: none; background: none; }
.topo__pesquisa input::placeholder { color: var(--ink-faint); }
.topo__pesquisa svg { color: var(--ink-faint); flex-shrink: 0; }

/* Barra de personificação (Impersonate) — sempre visível no topo. */
.impersonate-bar { position: sticky; top: 0; z-index: 45; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 26px; background: #8A2E2E; color: #fff; font-size: 13.5px; }
.impersonate-bar__txt { display: inline-flex; align-items: center; gap: 8px; }
.impersonate-bar__txt svg { flex-shrink: 0; }
.impersonate-bar__sub { opacity: .8; }
.impersonate-bar__btn { border: 1px solid rgba(255,255,255,.55); background: rgba(255,255,255,.14); color: #fff; padding: 5px 13px; border-radius: 999px; font-weight: 600; font-size: 12.5px; cursor: pointer; }
.impersonate-bar__btn:hover { background: rgba(255,255,255,.26); }
/* Durante a personificação o topo deixa de ser fixo, para a barra ficar sempre à vista. */
.principal--impersonando .topo { position: static; }

/* Lupa (só telemóvel) e botão de fechar da pesquisa: escondidos no desktop. */
.topo__lupa { display: none; }
.topo__pesquisa-fechar { display: none; }
.topo__direita { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Chip de utilizador no topo */
.topo__user {
    display: inline-flex; align-items: center; gap: 9px;
    padding: 5px 12px 5px 6px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface);
    font-weight: 600; font-size: 13.5px; color: var(--ink);
}
.topo__user:hover { background: var(--surface-2); }
.topo__user { cursor: pointer; }
/* Menu da conta (avatar): Abrir perfil · Ajuda · Sair. */
.topo__perfil { position: relative; }
.topo__perfil-menu {
    position: absolute; top: calc(100% + 6px); right: 0; min-width: 220px; z-index: 50;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    box-shadow: var(--sh-pop); padding: 6px;
}
.topo__perfil-hd { display: flex; align-items: center; gap: 9px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.topo__perfil-id { display: flex; flex-direction: column; min-width: 0; }
.topo__perfil-id strong { font-size: 13.5px; }
.topo__perfil-id small { color: var(--ink-faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.topo__perfil-menu a { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; color: var(--ink); font-size: 14px; font-weight: 500; }
.topo__perfil-menu a:hover { background: var(--surface-2); }
.topo__user-av {
    width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--brand);
    display: grid; place-items: center; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.topo__sair, .topo__cal {
    width: 38px; height: 38px; border-radius: var(--r-sm); display: grid; place-items: center;
    color: var(--ink-soft);
}
.topo__sair:hover, .topo__cal:hover { background: var(--surface-2); color: var(--ink); }

.conteudo { flex: 1; padding: 34px 40px 80px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ============ MENU (navegação lateral) ============ */
.menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.menu__li { position: relative; }
.menu__item {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink-soft);
    font-size: 14.5px; font-weight: 500; letter-spacing: -0.01em; transition: all .16s ease;
}
.menu__item:hover { background: var(--surface-2); color: var(--ink); }
.menu__item--ativo { background: var(--ink); color: #fff; }
.menu__item--ativo:hover { background: var(--ink); color: #fff; }
/* Ícone sempre em amarelo (marca). Sobre fundo claro usa-se o tom mais
   carregado (legível); sobre a barra preta do item ativo, o amarelo vivo. */
.menu__icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 20px; height: 20px; color: var(--brand-deep); }
.menu__item--ativo .menu__icon { color: var(--brand); }
.menu__label { white-space: nowrap; }
.menu__badge {
    flex-shrink: 0; margin-left: auto;
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    background: var(--tone-vermelho-bg, #F6D9D6); color: var(--tone-vermelho-fg, #BF453C);
    font-size: 11px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.menu__item--ativo .menu__badge { background: #fff; color: var(--ink); }
/* Badge clicável (link próprio) sobreposto ao item — ex.: Obras Em Análise. */
a.menu__badge {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    margin: 0; text-decoration: none; cursor: pointer; transition: filter .16s ease;
}
a.menu__badge:hover { filter: brightness(.95); }
.menu__badge--analise { background: #99740022; color: #997400; }
/* Quando o item Obras está ativo (barra preta), o badge passa a branco para
   se ler bem por cima do fundo escuro. */
.menu__li:has(.menu__item--ativo) a.menu__badge--analise { background: #fff; color: var(--ink); }
.acoes-validar { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.contador-fila {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 28px; height: 28px; padding: 0 9px; border-radius: 999px;
    background: var(--tone-vermelho-bg, #F6D9D6); color: var(--tone-vermelho-fg, #BF453C);
    font-size: 15px; font-weight: 700; vertical-align: middle; margin-left: 8px;
}
.menu__vazio { padding: 12px; color: var(--ink-faint); font-size: 13px; }

/* ============ SINO (notificações) ============ */
.sino { position: relative; }
.sino__btn {
    height: 38px; padding: 0 10px; border-radius: var(--r-sm);
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--ink-soft); transition: all .15s;
}
.sino__btn:hover { background: var(--surface-2); color: var(--ink); }
.sino__contador {
    min-width: 18px; height: 18px;
    background: var(--brand); color: var(--ink);
    font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 0 5px;
    display: inline-grid; place-items: center;
}
.sino__lista {
    position: absolute; right: 0; top: 120%;
    background: #fff; border: 1px solid var(--line);
    border-radius: var(--r-md); box-shadow: var(--sh-pop);
    width: 300px; padding: 12px; z-index: 40;
}
.sino__vazio { color: var(--ink-soft); margin: 0; font-size: 14px; }

/* ============ CABEÇALHO DE PÁGINA ============ */
.cabecalho-pagina { margin-bottom: 26px; }
.cabecalho-pagina h1 { font-size: 30px; font-weight: 700; line-height: 1.05; margin: 0 0 9px; }
.cabecalho-pagina .texto-suave { font-size: 14.5px; color: var(--ink-soft); margin: 0; max-width: 70ch; line-height: 1.45; }
/* Nome da obra em destaque, por baixo do título do orçamento. */
.orc-obra-nome { display: block; font-size: 18px; font-weight: 700; color: var(--ink); text-decoration: none; margin: 0 0 8px; line-height: 1.25; }
.orc-obra-nome:hover { color: var(--brand-deep); }

/* Ficha da obra: "Obra 32860" mais discreto e o NOME da obra em destaque. */
.cabecalho-pagina h1.obra-titulo-num { font-size: 19px; font-weight: 700; color: var(--ink-soft); margin: 0 0 3px; letter-spacing: .01em; }
.obra-titulo-nome {
    font-size: 23px; font-weight: 700; color: var(--ink); line-height: 1.2; margin: 0; max-width: 40ch;
    /* Limite confortável: no máximo 2 linhas, com reticências (nome completo no title). */
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Cabeçalho com ações (obra/orçamento/…): em desktop os botões ficam sempre no
   canto superior direito e o título ocupa o resto (encolhe/quebra sem os empurrar). */
@media (min-width: 821px) {
    .cabecalho-pagina--acoes { align-items: flex-start; }
    .cabecalho-pagina--acoes > :first-child { flex: 1 1 auto; min-width: 0; }
    .cabecalho-pagina--acoes > .form__botoes { flex: 0 0 auto; }
}
.cabecalho-pagina--acoes {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 24px; flex-wrap: wrap;
}

/* ============ CARTÕES ============ */
.cartao {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 22px 24px; margin-bottom: 20px;
    box-shadow: var(--sh-card);
}
.cartao h2 { font-size: 16px; font-weight: 650; margin: 0 0 16px; }
.cartao--info { background: var(--brand-soft); border-color: #F4E2A4; }

/* ============ TABELAS ============ */
.tabela { width: 100%; border-collapse: collapse; margin-top: 12px; }
.tabela th, .tabela td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); }
.tabela th {
    font-size: 11.5px; text-transform: uppercase; color: var(--ink-faint);
    letter-spacing: 0.04em; font-weight: 600; border-bottom-color: var(--line);
}
.tabela tbody tr { transition: background .14s; }
.tabela tbody tr:hover { background: var(--surface-2); }
/* Linha inteira clicável (tr[data-href]) — ver app.js. */
.tabela tbody tr[data-href] { cursor: pointer; }
.tabela .num, th.num { text-align: right; font-family: var(--mono); font-feature-settings: "tnum" 1; }

/* ============ BOTÕES ============ */
.btn {
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    background: var(--brand); color: var(--ink);
    padding: 9px 16px; border: 0; border-radius: var(--r-sm);
    cursor: pointer; font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em;
    box-shadow: 0 1px 2px rgba(231,185,0,.4); transition: all .15s ease; white-space: nowrap;
}
.btn:hover { background: var(--brand-deep); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(231,185,0,.4); text-decoration: none; }
.btn svg { flex-shrink: 0; }
.btn--bloco { width: 100%; }
.btn--secundario {
    background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: none; font-weight: 550;
}
.btn--secundario:hover { background: var(--surface-2); border-color: var(--ink-faint); transform: none; box-shadow: none; }
.btn--pequeno { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; box-shadow: none; }

/* Impressão do preview de preços: a área .orc-print é CLONADA (via JS) para
   #orc-print-root ao nível do <body>; aqui esconde-se tudo o resto com
   display:none (não deixa espaço → sem páginas repetidas/misturadas). Ativa-se
   só ao clicar em "Imprimir preços" (classe imprimir-precos no <html>). */
#orc-print-root { display: none; }
@media print {
    html.imprimir-precos body > *:not(#orc-print-root) { display: none !important; }
    html.imprimir-precos #orc-print-root { display: block !important; }
    html.imprimir-precos #orc-print-root .orc-print { position: static !important; max-width: none !important;
                 margin: 0 !important; padding: 0 !important; box-shadow: none !important;
                 border: 0 !important; background: #fff !important; }
    html.imprimir-precos #orc-print-root .tabela-scroll { overflow: visible !important; }
    /* O viewport de zoom tem altura fixa + scroll no ecrã: na impressão solta-se
       para não cortar linhas. O transform já é reposto a 100% em JS antes do clone. */
    html.imprimir-precos #orc-print-root .orc-zoom-viewport { overflow: visible !important; height: auto !important; max-height: none !important; }
    /* Totais só na ÚLTIMA página: por omissão o <tfoot> repete-se no fundo de
       cada página impressa. Como grupo de linhas normal, aparece uma só vez, a
       seguir à última linha (o <thead> continua a repetir os cabeçalhos). */
    html.imprimir-precos #orc-print-root tfoot { display: table-row-group !important; }
    /* O zoom do preview é sempre 100% na impressão. */
    html.imprimir-precos #orc-print-root .orc-print-zoom { zoom: 1 !important; }
    html.imprimir-precos .no-print { display: none !important; }
}

/* ============ MENSAGENS FLASH ============ */
.flashes { padding: 16px 40px 0; max-width: 1180px; width: 100%; margin: 0 auto; }
.flash {
    display: flex; justify-content: space-between; align-items: center;
    padding: 11px 16px; border-radius: var(--r-md); margin-bottom: 8px;
    border: 1px solid transparent; font-weight: 500; font-size: 14px;
}
.flash button { background: none; border: 0; font-size: 18px; cursor: pointer; line-height: 1; color: inherit; }
.flash--ok    { background: var(--tone-verde-bg);    color: var(--tone-verde-fg);    border-color: #C6E2CF; }
.flash--erro  { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); border-color: #ECCFCB; }
.flash--aviso { background: var(--tone-amarelo-bg);  color: var(--tone-amarelo-fg);  border-color: #EFDFB0; }

/* ============ PÁGINAS DE ERRO ============ */
.erro-pagina { text-align: center; padding: 80px 20px; }
.erro-pagina h1 { font-size: 72px; margin: 0; color: var(--brand-deep); font-family: var(--mono); }

/* ============ FORMULÁRIOS ============ */
.form { margin: 0; }
.form--estreito { max-width: 440px; }
.campo { margin-bottom: 16px; }
.campo label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13.5px; }
.campo input[type="text"],
.campo input[type="email"],
.campo input[type="password"],
.campo input[type="number"],
.campo input[type="date"],
.campo input[type="search"],
.campo select,
.campo textarea {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    font-size: 14.5px; font-family: inherit; background: #fff; color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
    outline: none; border-color: var(--brand-deep);
    box-shadow: 0 0 0 3px rgba(254,206,0,.25);
}
.campo--check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.campo--check input { width: auto; }
.ajuda { color: var(--ink-soft); font-weight: 400; }
small.ajuda { display: inline-block; margin-top: 4px; font-size: 12.5px; }
.form__botoes { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.form__linha { display: flex; gap: 12px; flex-wrap: wrap; }
.form__linha .campo { flex: 1; min-width: 120px; }

/* ============ LOGIN ============ */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: var(--ink); padding: 20px;
    background-image: radial-gradient(circle at 50% 0%, rgba(254,206,0,.10), transparent 60%);
}
.auth-cartao {
    background: #fff; border-radius: var(--r-lg); padding: 34px;
    width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.auth-marca { text-align: center; margin-bottom: 24px; }
.auth-marca__logo { height: 52px; max-height: 52px; width: auto; max-width: 80%; object-fit: contain; }
.auth-marca__nome { display: block; font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: -0.04em; }
.auth-marca__sub { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
/* Aviso de ambiente de desenvolvimento/testes (nunca aparece em produção). */
.auth-marca__sub--dev { display: inline-block; margin-top: 10px; padding: 4px 14px; background: #FDECEA; color: #B42318; border: 1px solid #F0B4AC; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.auth-titulo { font-size: 18px; margin: 0 0 20px; font-weight: 650; }
.auth-body .flashes { padding: 0; margin: 0 0 16px; max-width: none; }

/* ============ TABELAS: AÇÕES / ESTADOS / LINKS ============ */
.tabela__acoes { white-space: nowrap; }
.tabela__acoes a { margin-right: 12px; }
.inline { display: inline; }
.link {
    background: none; border: 0; color: var(--brand-deep); cursor: pointer; padding: 0;
    font-size: inherit; font-weight: 600; text-decoration: none;
}
.link:hover { text-decoration: underline; }
.link-perigo { background: none; border: 0; color: var(--tone-vermelho-fg); cursor: pointer; font-size: inherit; padding: 0; font-weight: 600; }
.link-perigo:hover { text-decoration: underline; }

.estado { font-size: 13px; font-weight: 600; }
.estado--ok { color: var(--tone-verde-fg); }
.estado--off { color: var(--ink-faint); }

/* ============ ETIQUETAS / BADGES ============ */
.etiqueta {
    display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 600; text-transform: capitalize; letter-spacing: -0.005em;
}
.etiqueta--admin     { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); }
.etiqueta--gestor    { background: var(--tone-amarelo-bg);  color: var(--tone-amarelo-fg); }
.etiqueta--comercial { background: var(--tone-azul-bg);     color: var(--tone-azul-fg); }
.etiqueta--contabilista { background: var(--tone-verde-bg, #E3F0E4); color: var(--tone-verde-fg, #2E7D32); }
.etiqueta--convidado    { background: #ECECE8; color: #6B6B63; }

/* Badges de estado de orçamento */
.estado-badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
    border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: -0.005em;
}

/* "Clientes nesta obra": lista compacta em chips (nº + nome + nº de orçamentos).
   Evita uma tabela alta quando a obra tem muitos clientes. Dois alvos de clique:
   o nº abre a ficha do cliente; o corpo abre o último orçamento nesta obra. */
/* Campo só de leitura (ex.: margem calculada no formulário de produto). */
.campo-estatico {
    display: block; padding: 9px 12px; border: 1px dashed var(--line); border-radius: 10px;
    background: var(--surface-2); color: var(--ink); font-variant-numeric: tabular-nums;
}

.cliente-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cliente-chip {
    display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
    padding: 3px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); font-size: 13px; line-height: 1.2;
}
.cliente-chip:hover { border-color: var(--ink-soft); }
.cliente-chip__num {
    flex: 0 0 auto; font-family: var(--mono, monospace); font-size: 11.5px; color: var(--ink-soft);
    padding: 3px 8px; border-radius: 999px;
}
.cliente-chip__num:hover { background: var(--surface-2); color: var(--ink); }
.cliente-chip__corpo {
    display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink);
    padding: 3px 5px 3px 3px; border-radius: 999px;
}
.cliente-chip__corpo:hover { background: var(--surface-2); }
.cliente-chip__nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 30ch; }
.cliente-chip__n {
    flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--ink-soft); font-size: 11.5px; font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.cliente-chip__corpo:hover .cliente-chip__n { background: var(--surface); }
.cliente-chip form.inline { display: inline-flex; }
.cliente-chip__x {
    flex: 0 0 auto; width: 22px; height: 22px; border: 0; border-radius: 999px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; margin-right: 2px;
    background: none; color: var(--ink-faint); font-size: 17px; line-height: 1;
}
.cliente-chip__x:hover { background: var(--tone-vermelho-bg, #f6e2e0); color: var(--tone-vermelho-fg, #bf453c); }
.estado-badge--pendente     { background: var(--tone-azul-bg);     color: var(--tone-azul-fg); }
.estado-badge--em_progresso { background: var(--tone-amarelo-bg);  color: var(--tone-amarelo-fg); }
.estado-badge--ganho        { background: var(--tone-verde-bg);    color: var(--tone-verde-fg); }
.estado-badge--validado     { background: #E8F5E9;                 color: #2E7D32; }
.estado-badge--perdido      { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); }
.estado-badge--anulado      { background: var(--tone-neutro-bg);   color: var(--tone-neutro-fg); }

/* ============ LISTA DE DADOS (dl) ============ */
.dados { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; margin: 0; }
.dados dt { font-weight: 600; color: var(--ink-soft); }
.dados dd { margin: 0; }

/* Ficha "Dados" da obra: cada campo é um bloco (rótulo | valor no PC). No
   telemóvel passa a grelha de 2 campos por linha — ver media query. */
.dados-obra { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.dados-obra .campo-dado { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: baseline; }
.dados-obra dt { font-weight: 600; color: var(--ink-soft); }
.dados-obra dd { margin: 0; }

/* ============ BARRA DE PESQUISA ============ */
.barra-pesquisa { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.barra-pesquisa input[type="search"] {
    flex: 1; max-width: 360px; padding: 9px 13px;
    border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 14.5px; background: #fff;
}
.barra-pesquisa input[type="search"]:focus { outline: none; border-color: var(--brand-deep); box-shadow: 0 0 0 3px rgba(254,206,0,.25); }

/* ============ AUTOCOMPLETE ============ */
.auto-resultados {
    position: relative; border: 1px solid var(--line); border-radius: var(--r-sm);
    margin-top: 4px; background: #fff; max-height: 240px; overflow-y: auto; box-shadow: var(--sh-card);
}
.auto-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border: 0; background: none; cursor: pointer; font-size: 14px; }
.auto-item:hover { background: var(--surface-2); }
.auto-vazio { padding: 10px 12px; color: var(--ink-soft); font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.auto-aviso { padding: 8px 11px; font-size: 12.5px; line-height: 1.4; color: #8A6D00; background: #FFF8E1; border-bottom: 1px solid #FFE082; }
.auto-item--obra { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-decoration: none; color: var(--ink); }
.auto-item--obra:hover { text-decoration: none; }
.auto-item__meta { font-size: 12px; color: var(--ink-soft); }
.aviso-rascunho { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: #8A6D00; background: #FFF8E1; border: 1px solid #FFE082; border-radius: var(--r-sm); padding: 6px 10px; margin-bottom: 10px; }
.aviso-rascunho .link { color: #8A6D00; text-decoration: underline; }

/* ============ CHIPS ============ */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--tone-azul-bg); color: var(--tone-azul-fg);
    padding: 4px 8px 4px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.chip button { background: none; border: 0; cursor: pointer; font-size: 15px; line-height: 1; color: inherit; }

/* Caixa inline */
.caixa-inline { border: 1px dashed var(--line); border-radius: var(--r-sm); padding: 12px; margin-top: 8px; background: var(--surface-2); }
.caixa-inline input { width: 100%; margin-bottom: 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.erro-inline { color: var(--tone-vermelho-fg); font-size: 13px; margin: 6px 0 0; }
.select-curto { padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }

/* Seletor de estado da obra em estilo botão + dropdown (uniforme com Editar/Histórico). */
.estado-drop { position: relative; display: inline-block; }
.estado-drop__btn { display: inline-flex; align-items: center; gap: 8px; }
.estado-drop__dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.estado-drop__menu { position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--sh-pop, 0 12px 32px rgba(0,0,0,.12)); padding: 5px; z-index: 50; }
.estado-drop__item { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 8px 11px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; font-size: 14px; color: var(--ink); }
.estado-drop__item > span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.estado-drop__item:hover { background: var(--surface-2); }
.estado-drop__item.is-atual { font-weight: 700; }
.estado-drop__check { color: #2E7D52; flex-shrink: 0; }

/* ============ ATALHOS (início) ============ */
.atalhos { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.atalho {
    display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 22px; box-shadow: var(--sh-card);
    color: var(--ink); font-weight: 600;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
}
.atalho:hover { transform: translateY(-2px); box-shadow: var(--sh-hover); border-color: #E0E0D8; text-decoration: none; }
.atalho__icon { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink); }

/* ============ ORÇAMENTOS ============ */
.barra-estados { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn--estado-em_progresso { background: var(--tone-azul-fg); color: #fff; box-shadow: none; }
.btn--estado-ganho        { background: var(--tone-verde-fg); color: #fff; box-shadow: none; }
.btn--estado-perdido      { background: var(--tone-vermelho-fg); color: #fff; box-shadow: none; }
.btn--estado-anulado      { background: var(--tone-neutro-fg); color: #fff; box-shadow: none; }
.btn--estado-em_progresso:hover,
.btn--estado-ganho:hover,
.btn--estado-perdido:hover,
.btn--estado-anulado:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: none; }

.grelha-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* Histórico de revisões */
.lista-revisoes { list-style: none; margin: 0; padding: 0; }
.lista-revisoes li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.lista-revisoes li:last-child { border-bottom: 0; }
.lista-revisoes .num { margin-left: auto; font-family: var(--mono); }
.lista-revisoes a { display: inline-flex; align-items: center; gap: 6px; }
.lista-revisoes a.atual { font-weight: 700; }
.rev-val { display: inline-flex; flex-shrink: 0; }
.rev-val--ok { color: #2E7D52; }   /* validado */
.rev-val--pend { color: #997400; } /* por validar */
.rev-val--elim { font-size: 12px; }
.lista-revisoes li.rev-eliminada a { color: var(--ink-soft); text-decoration: line-through; }

/* Totais nas tabelas de linhas */
.tabela--linhas tfoot td, .tabela--editor tfoot td { border-bottom: 0; padding-top: 5px; padding-bottom: 5px; }
/* Total com IVA: mantém o separador mas sem negrito — a ênfase fica no valor
   s/ IVA (Incidência), evitando confusão entre valores com e sem IVA. */
.total-final td { border-top: 2px solid var(--line); font-size: 15px; font-weight: 400; }

/* -- Linhas do orçamento em TELEMÓVEL: cada artigo vira um cartão e os totais
   (tfoot) ficam sempre visíveis como um bloco resumo (o modo cartão genérico
   esconderia o tfoot, mas aqui os totais são essenciais). Evita o scroll
   horizontal da tabela larga. -- */
@media (max-width: 820px) {
    .tabela--linhas { display: block; min-width: 0; width: 100%; }
    .tabela--linhas thead { display: none; }
    .tabela--linhas tbody { display: block; }
    .tabela--linhas tbody tr {
        display: flex; flex-direction: column;
        border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px;
        padding: 11px 13px; background: var(--surface); box-shadow: var(--sh-card);
    }
    .tabela--linhas tbody td {
        display: flex; align-items: baseline; gap: 10px;
        border: 0 !important; padding: 4px 0; text-align: right; font-size: 13.5px;
    }
    /* Rótulo à esquerda (empurra o valor — e uma eventual etiqueta líq. — para a direita, agrupados). */
    .tabela--linhas tbody td::before {
        content: attr(data-label); flex: 0 0 auto; margin-right: auto; text-align: left;
        font-size: 11px; font-weight: 700; color: var(--ink-soft);
        text-transform: uppercase; letter-spacing: .03em;
    }
    /* Descrição = título do cartão (topo, sem rótulo); Ref. logo abaixo. */
    .tabela--linhas tbody td.cel-desc {
        order: -2; display: block; text-align: left; font-weight: 600; font-size: 14.5px;
        padding-bottom: 2px;
    }
    .tabela--linhas tbody td.cel-desc::before { content: none; }
    .tabela--linhas tbody td.cel-ref { order: -1; }
    /* Rodapé de totais como bloco resumo. */
    .tabela--linhas tfoot { display: block; margin-top: 2px; }
    .tabela--linhas tfoot tr { display: flex; justify-content: space-between; gap: 12px; }
    .tabela--linhas tfoot td {
        display: block; border: 0 !important; padding: 4px 0; text-align: right;
    }
    .tabela--linhas tfoot td:first-child { text-align: left; color: var(--ink-soft); }
    .tabela--linhas tfoot tr.total-final { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
    .tabela--linhas tfoot tr.total-final td { font-size: 15px; border-top: 0; }
}

/* Editor de linhas */
.tabela-scroll { overflow-x: auto; }
.in-tabela { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.in-tabela:focus { outline: none; border-color: var(--brand-deep); box-shadow: 0 0 0 3px rgba(254,206,0,.2); }
.in-num { text-align: right; font-family: var(--mono); }
.tabela--editor td { padding: 4px 6px; vertical-align: middle; }
.tabela--editor th { padding: 8px 6px; }

/* Adicionar produtos / linha livre — fica sempre abaixo da última linha. */
.linha-add td { padding: 10px 6px !important; background: var(--surface-2); }
.add-linhas { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.add-busca { margin-top: 10px; max-width: 460px; }
.add-busca input[type="text"] { width: 100%; }
.add-busca__res {
    border: 1px solid var(--line); border-radius: var(--r-sm); margin-top: 4px;
    background: #fff; max-height: 260px; overflow-y: auto; box-shadow: var(--sh-card);
}

/* ============ DEFINIÇÕES: SUB-NAVEGAÇÃO ============ */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.subnav__item { padding: 9px 14px; color: var(--ink-soft); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 14px; font-weight: 500; }
.subnav__item:hover { color: var(--ink); }
.subnav__item--ativo { color: var(--ink); border-bottom-color: var(--brand); font-weight: 650; }

.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check-inline input { width: auto; }

/* Campo de imagem */
.campo-imagem { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.campo-imagem:last-child { border-bottom: 0; }
.campo-imagem > div { flex: 1; }
.preview-img { max-width: 120px; max-height: 160px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

/* Condições: lista de escolha */
.lista-condicoes { display: flex; flex-direction: column; gap: 8px; }
.cond-item { display: flex; gap: 11px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); cursor: pointer; transition: all .14s; }
.cond-item:hover { background: var(--surface-2); border-color: #DEDED6; }
.cond-item input { width: auto; margin-top: 3px; }
.cond-item span { display: flex; flex-direction: column; gap: 2px; }

/* ============ PUBLICIDADES: GRELHA (mosaico) ============ */
.grelha-pub { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.pub-card {
    border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
    display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--sh-card);
    transition: transform .18s ease, box-shadow .18s ease;
}
.pub-card:hover { transform: translateY(-2px); box-shadow: var(--sh-hover); }
.pub-thumb { width: 100%; height: 160px; object-fit: contain; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.pub-info { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.pub-acoes { display: flex; gap: 12px; align-items: center; margin-top: 8px; }

/* ============ HISTÓRICO (percurso + fita) ============ */
.cartao--percurso { padding-top: 16px; padding-bottom: 8px; }
.pc-info { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-bottom: 6px; }
.pc-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.pc-chip svg { color: var(--ink-faint); flex: 0 0 auto; }
.diag-scroll { overflow-x: auto; }
/* Largura limitada: o SVG mantém o rácio, por isso capar a largura cap também
   a altura (senão em ecrãs largos fica desproporcionalmente alto). Alinhado à
   esquerda. */
svg.percurso { display: block; width: 100%; max-width: 720px; min-width: 560px; height: auto; }
/* Stepper vertical (só telemóvel). */
.pc-vert { display: none; list-style: none; margin: 4px 0 0; padding: 0; }
.pc-v { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 5px 0 16px; }
.pc-v:last-child { padding-bottom: 2px; }
.pc-v::before { content: ""; position: absolute; left: 13px; top: 28px; bottom: -2px; width: 2px; background: var(--line); }
.pc-v:last-child::before { display: none; }
.pc-v-node { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line);
    background: var(--surface); color: var(--ink-faint); display: grid; place-items: center; z-index: 1; }
.pc-v.done .pc-v-node, .pc-v.win.on .pc-v-node { border-color: var(--tone-verde-fg); background: var(--tone-verde-fg); color: #fff; }
.pc-v.now .pc-v-node { border-color: var(--brand-deep); background: var(--brand-soft); }
.pc-v.gate .pc-v-node { border-style: dashed; border-color: var(--tone-amarelo-fg); background: var(--tone-amarelo-bg); color: var(--tone-amarelo-fg); }
.pc-v.gate.idle .pc-v-node { border-color: var(--line); background: var(--surface-2); color: var(--ink-faint); }
.pc-v.win .pc-v-node { border-color: var(--tone-verde-fg); background: var(--tone-verde-bg); color: var(--tone-verde-fg); }
.pc-v.lose .pc-v-node { border-color: var(--tone-vermelho-fg); background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); }
.pc-v.lose.on .pc-v-node { background: var(--tone-vermelho-fg); color: #fff; }
.pc-v.excl .pc-v-node { border-color: var(--ink-faint); background: var(--surface-2); color: var(--ink-soft); }
.pc-v-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-deep); }
.pc-v-txt b { font-size: 14px; display: block; line-height: 1.3; }
.pc-v.todo .pc-v-txt b, .pc-v.win .pc-v-txt b, .pc-v.lose .pc-v-txt b, .pc-v.gate.idle .pc-v-txt b { color: var(--ink-faint); }
.pc-v-txt small { font-size: 12px; color: var(--ink-faint); }
.percurso .seg { fill: none; stroke: var(--line); stroke-width: 2.5; }
.percurso .seg.done { stroke: var(--tone-verde-fg); }
.percurso .seg.active { stroke: var(--brand-deep); }
.percurso .seg.gate { stroke: var(--tone-amarelo-fg); }
.percurso .seg.gate.idle { stroke: var(--line); }
.percurso .seg.excl { stroke: var(--ink-faint); }
.percurso .nd.excl { stroke: var(--ink-faint); fill: var(--surface-2); }
.percurso .seg.win { stroke: var(--tone-verde-fg); opacity: .4; }
.percurso .seg.win.on { opacity: 1; }
.percurso .seg.lose { stroke: var(--tone-vermelho-fg); opacity: .4; }
.percurso .seg.lose.on { opacity: 1; }
.percurso .detour { fill: none; stroke: var(--tone-amarelo-fg); stroke-width: 2; stroke-dasharray: 5 4; }
.percurso .nd { fill: var(--surface); stroke: var(--line); stroke-width: 2.5; }
.percurso .nd.done { fill: var(--tone-verde-fg); stroke: var(--tone-verde-fg); }
.percurso .nd.now { stroke: var(--brand-deep); fill: var(--brand-soft); }
.percurso .nd.win { stroke: var(--tone-verde-fg); fill: var(--tone-verde-bg); opacity: .7; }
.percurso .nd.lose { stroke: var(--tone-vermelho-fg); fill: var(--tone-vermelho-bg); opacity: .55; }
.percurso .nd.lose.on { opacity: 1; }
.percurso .nd.gate { stroke: var(--tone-amarelo-fg); fill: var(--tone-amarelo-bg); }
.percurso .nd.gate.idle { stroke: var(--line); fill: var(--surface-2); }
.percurso .glyph { stroke: #fff; stroke-width: 2.6; fill: none; }
.percurso .glyph.dk { stroke: var(--tone-amarelo-fg); }
.percurso .glyph.faintg { stroke: var(--ink-faint); }
.percurso .pulse { fill: var(--brand-deep); }
/* Estado atual «Pendente» adota a cor do estado (azul), não o âmbar do «agora». */
.percurso .nd.now.az { stroke: var(--tone-azul-fg); fill: var(--tone-azul-bg); }
.percurso .seg.active.az { stroke: var(--tone-azul-fg); }
.percurso .pulse.az { fill: var(--tone-azul-fg); }
.percurso .sub.az { fill: var(--tone-azul-fg); }
.pc-v.now.az .pc-v-node { border-color: var(--tone-azul-fg); background: var(--tone-azul-bg); }
.pc-v.now.az .pc-v-pulse { background: var(--tone-azul-fg); }
.percurso .lbl { font-family: var(--font); font-size: 13px; font-weight: 600; fill: var(--ink); }
.percurso .lbl.faint { fill: var(--ink-faint) !important; }
.percurso .sub { font-family: var(--font); font-size: 11px; fill: var(--ink-faint); }
.percurso .gatetxt { font-family: var(--font); font-size: 11.5px; font-weight: 700; fill: var(--tone-amarelo-fg); }
.percurso .gatetxt.idle { fill: var(--ink-faint); }
#ah path { fill: var(--tone-amarelo-fg); }
.percurso-cap { display: flex; align-items: flex-start; gap: 8px; margin: 14px 0 2px; padding: 10px 14px;
    background: var(--tone-amarelo-bg); border: 1px solid #F4E2A4; border-radius: 12px; font-size: 12.5px; color: var(--ink); }
.percurso-cap svg { flex: 0 0 auto; margin-top: 1px; color: var(--tone-amarelo-fg); }

/* ============ PERCURSO DA OBRA (cartão de fases, novo) ============ */
.fases { overflow: hidden; }
.fases__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px 6px; }
.fases__head h3 { font-size: 15px; font-weight: 750; letter-spacing: -.01em; margin: 0; }
.fases__head p { font-size: 12.5px; color: var(--ink-faint); margin: 2px 0 0; }
.estado-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
    font-size: 13px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.estado-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.estado-pill--azul { background: var(--tone-azul-bg); color: var(--tone-azul-fg); border-color: #CFE0EE; }
.estado-pill--verde { background: var(--tone-verde-bg); color: var(--tone-verde-fg); border-color: #C6E2CF; }
.estado-pill--verm { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); border-color: #ECCFCB; }
.estado-pill--amar { background: var(--tone-amarelo-bg); color: var(--tone-amarelo-fg); border-color: #F4E2A4; }
.estado-pill--neu { background: var(--surface-2); color: var(--ink-soft); border-color: var(--line); }
.fases__svg { padding: 2px 16px 4px; }
.fases__svg svg { width: 100%; height: auto; display: block; }
.fases svg text { font-family: var(--font); }
.t-lbl { font-size: 15px; font-weight: 700; fill: var(--ink); }
.t-sub { font-size: 12px; font-weight: 600; fill: var(--ink-faint); }
.t-sub--cur { font-size: 12px; font-weight: 700; }
.t-lbl--fut { font-size: 14.5px; font-weight: 700; fill: #8E8E84; }
.t-lbl--gan { font-size: 14.5px; font-weight: 700; fill: var(--tone-verde-fg); }
.t-lbl--per { font-size: 14.5px; font-weight: 700; fill: var(--tone-vermelho-fg); }
.t-det { font-size: 13px; font-weight: 700; fill: #7C9C89; }
.t-det-sub { font-size: 11.5px; font-weight: 600; fill: #A9C2B4; }
.t-det--fut { font-size: 12px; font-weight: 700; fill: #B0B0A6; }
.t-exc { font-size: 12.5px; font-weight: 700; fill: #9A9A90; }
.t-exc-sub { font-size: 11px; font-weight: 600; fill: #B4B4AA; }
.t-sig { font-size: 11px; font-weight: 800; font-family: var(--mono); fill: var(--ink-soft); }
.fases__legenda { display: flex; align-items: center; gap: 20px; padding: 12px 22px 16px; flex-wrap: wrap; border-top: 1px solid var(--line-soft); }
.leg { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.leg i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.leg--done i { background: var(--tone-verde-fg); }
.leg--cur i { background: var(--tone-azul-fg); }
.leg--fut i { background: #D3D3CC; }
.fases__nota { margin-left: auto; font-size: 12px; color: var(--ink-faint); }
.fases__nota b { color: var(--ink-soft); font-weight: 700; }
@media (max-width: 768px) {
    .fases__head { padding: 16px 16px 6px; flex-wrap: wrap; }
    .fases__svg { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 2px 12px; }
    .fases__svg svg { min-width: 900px; }
    .fases__legenda { padding: 12px 16px 16px; gap: 14px; }
    .fases__nota { margin-left: 0; }
}

.hist-tl { position: relative; }
.hist-dia { display: flex; align-items: center; gap: 10px; margin: 18px 0 12px; }
.hist-dia:first-child { margin-top: 2px; }
.hist-dia b { font-size: 12.5px; font-weight: 700; }
.hist-dia .rule { flex: 1; height: 1px; background: var(--line-soft); }
.hist-ev { position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 14px; align-items: start;
    padding: 9px 8px 9px 0; border-radius: 12px; text-decoration: none; color: inherit; }
.hist-link:hover { background: var(--surface-2); }
.hist-ev::before { content: ""; position: absolute; left: 16px; top: -14px; bottom: -14px; width: 2px; background: var(--line); z-index: 0; }
.hist-ev:first-of-type::before { top: 16px; }
.hist-node { position: relative; z-index: 1; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
    background: var(--surface); border: 2px solid var(--line); color: var(--ink-faint); }
.hist-node.azul { border-color: var(--tone-azul-fg); color: var(--tone-azul-fg); background: var(--tone-azul-bg); }
.hist-node.verde { border-color: var(--tone-verde-fg); color: var(--tone-verde-fg); background: var(--tone-verde-bg); }
.hist-node.amar { border-color: var(--tone-amarelo-fg); color: var(--tone-amarelo-fg); background: var(--tone-amarelo-bg); }
.hist-node.verm { border-color: var(--tone-vermelho-fg); color: var(--tone-vermelho-fg); background: var(--tone-vermelho-bg); }
.hist-node.neu { border-color: var(--line); color: var(--ink-faint); background: var(--surface-2); }
.hist-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2px; }
.hist-tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--tone-neutro-bg); color: var(--tone-neutro-fg); }
.hist-tag.azul { background: var(--tone-azul-bg); color: var(--tone-azul-fg); }
.hist-tag.verde { background: var(--tone-verde-bg); color: var(--tone-verde-fg); }
.hist-tag.amar { background: var(--tone-amarelo-bg); color: var(--tone-amarelo-fg); }
.hist-tag.verm { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); }
.hist-hora { font-size: 12px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.hist-quem { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-soft); }
.hist-txt { font-size: 14px; color: var(--ink); }
.hist-ir { align-self: center; color: var(--ink-faint); opacity: 0; transition: opacity .12s; }
.hist-link:hover .hist-ir { opacity: 1; }
.hist-ev--grupo { background: var(--surface-2); border: 1px dashed var(--line); }
.hist-expandir { margin-top: 6px; font-size: 12px; color: var(--brand-deep); font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }
.hist-sub { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.hist-subitem { font-size: 12px; color: var(--ink-soft); }
.hist-subitem .mono { color: var(--ink-faint); }
/* Referência da obra num evento do histórico do utilizador. */
.obra-ref { font-family: var(--mono); font-size: 11.5px; color: var(--ink-soft);
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
/* Resumo de contagens (histórico do utilizador). */
.uh-stats { display: flex; gap: 26px; flex-wrap: wrap; }
.uh-stat b { font-size: 22px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.uh-stat span { display: block; font-size: 12px; color: var(--ink-soft); margin-top: 1px; }

/* ============ HISTÓRICO GLOBAL POR DIA (seletor + timeline) ============ */
.sel-topo { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.sel { padding: 22px 26px 18px; margin-bottom: 20px; }
.sel__head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.sel__dia { display: flex; align-items: baseline; gap: 12px; }
.sel__num { font-size: 42px; font-weight: 800; letter-spacing: -0.04em; line-height: .9; font-variant-numeric: tabular-nums; }
.sel__dow { font-size: 17px; font-weight: 650; color: var(--ink-soft); }
.sel__count { font-size: 16px; color: var(--ink-soft); }
.sel__count b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
/* Ponteiro FIXO ao centro; arrasta-se o CONTEÚDO (a faixa de dias). */
.sel__chart { position: relative; height: 132px; background: var(--surface-2); border: 1px solid var(--line-soft);
    border-radius: 12px; overflow-x: clip; overflow-y: visible; user-select: none; touch-action: pan-y; cursor: grab; outline: none; }
.sel__chart:focus-visible { box-shadow: 0 0 0 2px var(--brand-deep) inset; }
.sel__chart.dragging { cursor: grabbing; }
.sel__track { position: absolute; top: 0; left: 0; height: 100%; will-change: transform; }
.sel__bars { position: absolute; left: 0; right: 0; top: 26px; bottom: 16px; display: flex; align-items: flex-end; z-index: 2; }
.bar-col { flex: 0 0 auto; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; height: 100%; }
/* Pontos por tipo (nome próprio «sd» para não colidir com o .seg genérico). */
.bar-col .sd { width: 6px; height: 6px; border-radius: 50%; }
.bar-col .sd.is-fut { opacity: .4; }
.sd--verde { background: var(--tone-verde-fg); }
.sd--azul { background: var(--tone-azul-fg); }
.sd--vermelho { background: var(--tone-vermelho-fg); }
.sd--amarelo { background: var(--brand-deep); }
.sd--cinza { background: var(--ink-faint); }
.bar-col.is-sel .sd { box-shadow: 0 0 0 1px rgba(0,0,0,.16); }
.futuro-hatch { position: absolute; top: 8px; bottom: 16px; z-index: 1; pointer-events: none;
    background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,.03) 6px 7px); }
.sel__today { position: absolute; top: 20px; bottom: 16px; width: 2px; background: var(--tone-verde-fg); transform: translateX(-1px); pointer-events: none; z-index: 3; opacity: .75; }
/* Etiqueta «hoje» DENTRO do gráfico (top positivo) — nunca fica cortada. */
.sel__today::after { content: 'hoje'; position: absolute; top: -15px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--tone-verde-fg); }
.sel__mes { position: absolute; top: 6px; font-size: 11px; font-weight: 800; letter-spacing: .08em; color: var(--ink-faint); pointer-events: none; z-index: 3; }
/* Ponteiro central fixo */
.sel__playhead { position: absolute; top: 20px; bottom: 16px; left: 50%; width: 2px; transform: translateX(-1px); background: var(--brand-deep); pointer-events: none; z-index: 5; }
.sel__playhead::before { content: ''; position: absolute; top: -3px; left: 50%; transform: translateX(-50%); width: 11px; height: 11px; border-radius: 50%; background: var(--brand-deep); }
.sel__playhead::after { content: attr(data-dia); position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; font-family: var(--mono); color: var(--brand-deep); }
.sel__foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 22px; font-size: 12.5px; color: var(--ink-faint); font-family: var(--mono); flex-wrap: wrap; }
.sel__hint { font-family: var(--font); font-size: 13px; }

/* Filtro por utilizador (chips) */
.filtro-user { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.filtro-user__lbl { font-size: 13.5px; font-weight: 650; color: var(--ink-soft); }
.chip-user { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all .15s; }
.chip-user:hover { background: var(--surface-2); }
.chip-user.ativo { border-color: var(--brand-deep); background: var(--brand-soft); color: var(--ink); }
.chip-user .sigla { width: 24px; height: 24px; min-width: 24px; border-radius: 7px; font-size: 9.5px; }
.chip-user__n { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.chip-todos { padding: 7px 14px; }

/* Timeline do dia (nós + linha vertical) */
.tl-cartao { padding: 8px 26px 20px; transition: opacity .12s; }
.tl-cartao.is-loading { opacity: .45; }
.tl-vazio { padding: 30px 4px; color: var(--ink-faint); font-size: 14.5px; }
.tl { position: relative; padding-left: 4px; }
.tl-item { position: relative; display: grid; grid-template-columns: 48px 1fr; gap: 16px; padding: 12px 0; text-decoration: none; color: inherit; }
.tl-item::before { content: ''; position: absolute; left: 23px; top: 46px; bottom: -12px; width: 2px; background: var(--line); }
.tl-item:last-child::before { display: none; }
.tl-item:hover .tl-texto { color: var(--brand-deep); }
.tl-node { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-faint); z-index: 1; }
.tl-node--azul { background: var(--tone-azul-bg); border-color: transparent; color: var(--tone-azul-fg); }
.tl-node--verde { background: var(--tone-verde-bg); border-color: transparent; color: var(--tone-verde-fg); }
.tl-node--amar { background: var(--tone-amarelo-bg); border-color: transparent; color: var(--tone-amarelo-fg); }
.tl-node--vermelho { background: var(--tone-vermelho-bg); border-color: transparent; color: var(--tone-vermelho-fg); }
.tl-corpo { padding-top: 2px; min-width: 0; }
.tl-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.tl-tag { font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 7px; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.tl-tag--azul { background: var(--tone-azul-bg); color: var(--tone-azul-fg); border-color: transparent; }
.tl-tag--verde { background: var(--tone-verde-bg); color: var(--tone-verde-fg); border-color: transparent; }
.tl-tag--amar { background: var(--tone-amarelo-bg); color: var(--tone-amarelo-fg); border-color: transparent; }
.tl-tag--vermelho { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); border-color: transparent; }
.tl-hora { font-size: 13px; font-family: var(--mono); color: var(--ink-faint); font-weight: 600; }
.tl-user { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.tl-obra { font-size: 12.5px; font-family: var(--mono); color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line);
    padding: 2px 9px; border-radius: 7px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46%; }
.tl-texto { font-size: 14.5px; color: var(--ink); line-height: 1.45; transition: color .12s; }
.tl-nota { margin-top: 7px; padding: 8px 12px; border-left: 2px solid var(--line-strong); background: var(--surface-2);
    border-radius: 0 8px 8px 0; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; white-space: pre-line; }
.tl-nota--resp { border-left-color: var(--tone-verde-fg); }
.tl-nota--resp strong { color: var(--tone-verde-fg); font-weight: 700; }

/* ============ ÚLTIMA IMPORTAÇÃO ============ */
.imp-ult__cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.imp-det { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.imp-det > summary { cursor: pointer; font-size: 14px; font-weight: 650; padding: 4px 0; }
.imp-lista { max-height: 340px; overflow: auto; margin-top: 8px; }

/* ============ FICHA (produto) ============ */
.ficha-dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 26px; margin: 0; }
.ficha-dl > div { padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ficha-dl dt { font-size: 12px; color: var(--ink-faint); font-weight: 600; margin-bottom: 3px; }
.ficha-dl dd { margin: 0; font-size: 15px; font-weight: 600; }
.ficha-desc { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.prod-link { color: inherit; text-decoration: none; }
.prod-link:hover { color: var(--brand-deep); }
.prod-link:hover code { color: var(--brand-deep); }

/* ============ FILTROS DE PRODUTOS ============ */
.prod-filtros__linha { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.prod-filtros__lbl { font-size: 12.5px; font-weight: 700; color: var(--ink-faint); letter-spacing: .02em; }
.seg-filtro { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-filtro__op { display: inline-flex; align-items: center; padding: 5px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft); cursor: pointer; transition: all .12s; }
.seg-filtro__op input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg-filtro__op.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-card); }
.prod-marcas { position: relative; }
.prod-marcas__pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; min-width: 240px; max-height: 340px; overflow: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--sh-pop); padding: 8px; }
.prod-marcas__lista { display: flex; flex-direction: column; gap: 1px; }
.prod-marcas__lista label { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; font-size: 13.5px; cursor: pointer; }
.prod-marcas__lista label:hover { background: var(--surface-2); }
.prod-marcas__acoes { display: flex; align-items: center; gap: 12px; padding: 8px 6px 2px; border-top: 1px solid var(--line); margin-top: 6px; }

/* ============ RESPONSIVO ============ */
@media (max-width: 900px) {
    .grelha-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
        transform: translateX(-100%); transition: transform .26s cubic-bezier(.3,.8,.3,1);
        box-shadow: var(--sh-pop);
    }
    .sidebar.aberto { transform: translateX(0); }
    .sidebar::after {
        content: ''; position: fixed; inset: 0; left: var(--side-w);
        background: rgba(20,20,18,.32); opacity: 0; pointer-events: none; transition: opacity .2s;
    }
    .sidebar.aberto::after { opacity: 1; }
    .topo__menu { display: grid; }
    /* Pesquisa em telemóvel: recolhida numa lupa (junto aos ícones da direita);
       abre em ecrã inteiro por cima da barra. */
    .topo__pesquisa { display: none; }
    .topo__pesquisa-wrap { flex: 0 0 auto; margin-left: auto; }
    .topo__lupa {
        display: grid; width: 38px; height: 38px; border-radius: var(--r-sm);
        place-items: center; color: var(--ink-soft); border: 0; background: none;
    }
    .topo__lupa:hover { background: var(--surface-2); }
    .topo__pesquisa-wrap.is-mobile-aberto {
        position: absolute; left: 14px; right: 14px; top: 50%; transform: translateY(-50%);
        z-index: 45; max-width: none;
    }
    .topo__pesquisa-wrap.is-mobile-aberto .topo__lupa { display: none; }
    .topo__pesquisa-wrap.is-mobile-aberto .topo__pesquisa { display: flex; width: 100%; max-width: none; background: var(--surface); box-shadow: var(--sh-card); }
    .topo__pesquisa-fechar {
        display: grid; place-items: center; width: 26px; height: 26px; flex-shrink: 0;
        border: 0; background: none; color: var(--ink-soft); font-size: 22px; line-height: 1; cursor: pointer;
    }
    /* Chip de utilizador: só a sigla (esconde o nome). */
    .topo__user { font-size: 0; gap: 0; padding: 3px; border: 0; background: none; }
    .topo__user-av { font-size: 12px; }
    /* Topo apertado para caberem todos os ícones (incl. sino e a calculadora de
       margens dos diretores) sem transbordar. */
    .topo { padding: 0 10px; gap: 2px; }
    .topo__direita { gap: 1px; }
    .topo__cal, .topo__sair, .topo__lupa { width: 32px; height: 32px; }
    .sino__btn { padding: 0 5px; }
    /* A ajuda está no menu lateral em telemóvel — liberta espaço no topo. */
    .topo__ajuda { display: none; }
    /* A janela do atalho de margens ocupa a largura toda no telemóvel. */
    .modal.atalho-mg { max-width: none; }
    .atalho-mg__corpo { max-height: 60vh; }
    /* Painel de notificações fixo ao ecrã — vê-se tudo, sem cortes. */
    .sino__lista { position: fixed; top: 66px; left: 10px; right: 10px; width: auto; max-width: none; }
    body.tem-devbar .sino__lista { top: 92px; }
    .conteudo { padding: 24px 18px 70px; }
    .cabecalho-pagina h1 { font-size: 25px; }
    .cabecalho-pagina--acoes { flex-direction: column; align-items: stretch; }
    .flashes { padding: 16px 18px 0; }
    /* Ficha "Dados" em modo minimalista: etiqueta-caption + valor destacado */
    .dados { grid-template-columns: 1fr; gap: 2px 0; }
    .dados dt { margin-top: 12px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
    .dados dd { font-size: 15px; }
    .dados dt:first-child { margin-top: 0; }
}

/* ============================================================
   OBRAS — resumo operacional, estados e interações
   ============================================================ */

/* Letra de estado (círculo colorido) */
.estado-letra {
    display: inline-grid; place-items: center; width: 24px; height: 24px;
    border-radius: 50%; border: 1px solid var(--line); font-weight: 700;
    font-size: 12px; line-height: 1; flex-shrink: 0; vertical-align: middle;
}

/* Sigla do comercial (iniciais) */
.sigla {
    display: inline-grid; place-items: center; min-width: 28px; height: 28px;
    padding: 0 6px; border-radius: 8px; background: var(--surface-2);
    border: 1px solid var(--line); color: var(--ink); font-weight: 700;
    font-size: 11.5px; letter-spacing: 0.02em; vertical-align: middle;
}
.sigla--sm { min-width: 22px; height: 22px; font-size: 10.5px; border-radius: 6px; }
/* Autor de uma versão que NÃO é o responsável da obra (rasto de colaboração). */
.sigla--autor { gap: 1px; background: #fbf3dd; border-color: #ecd9a4; color: #8a6d1a; font-weight: 700; }

/* Urgência do próximo contacto */
.urg-atraso { color: var(--tone-vermelho-fg); font-weight: 700; }
.urg-hoje   { color: var(--brand-deep); font-weight: 700; }
.urg-breve  { color: var(--tone-amarelo-fg); font-weight: 600; }
.urg-tag {
    display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    font-family: var(--font); vertical-align: middle;
}
.urg-tag--atraso { background: var(--tone-vermelho-bg); color: var(--tone-vermelho-fg); }
.urg-tag--hoje   { background: var(--brand-soft); color: var(--brand-deep); }

/* Resumo de obras: colunas */
.col-data { white-space: nowrap; }
/* Cor da data Contacto Cliente (Seguimento): atraso no mês corrente = amarelo;
   meses anteriores = vermelho. Aplica-se à própria letra da data. */
.data-cli--mes { color: #C9A227; font-weight: 600; }
.data-cli--old { color: #C62828; font-weight: 600; }
.tabela--obras .col-estado { text-align: center; width: 1%; }
.form-estado { display: inline-flex; margin: 0; }

/* Barra de datas (detalhe da obra) */
.datebar { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.datebar-item {
    display: flex; align-items: center; gap: 14px; padding: 15px 18px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
    box-shadow: var(--sh-card);
}
.datebar-item--next { background: var(--brand-soft); border-color: #F4E2A4; box-shadow: none; }
.datebar-item--next.is-atraso { background: var(--tone-vermelho-bg); border-color: #ECCFCB; }
.datebar-item--next.is-hoje { background: var(--brand-soft); border-color: #F4E2A4; }
.datebar-ico {
    width: 42px; height: 42px; border-radius: 11px; background: var(--surface-2);
    border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink); flex-shrink: 0;
}
.datebar-item--next .datebar-ico { background: #fff; border-color: #F4E2A4; color: var(--brand-deep); }
.datebar-item--next.is-atraso .datebar-ico { border-color: #ECCFCB; color: var(--tone-vermelho-fg); }
.datebar-lbl { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.datebar-val { font-size: 20px; font-weight: 700; margin-top: 3px; letter-spacing: -0.02em; }

/* Timeline de interações */
.timeline { display: flex; flex-direction: column; margin-top: 18px; }
/* Linha divisória entre o formulário de interação e a lista (como antes das Observações). */
.hr-secao { border: 0; border-top: 1px solid var(--line); margin: 18px 0 0; }
.hr-secao + .timeline { margin-top: 12px; }
.tl-item { display: flex; gap: 13px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before {
    content: ''; position: absolute; left: 4.5px; top: 16px; bottom: 0; width: 1.5px; background: var(--line);
}
.tl-dot {
    width: 11px; height: 11px; border-radius: 50%; background: var(--brand);
    border: 2px solid #fff; box-shadow: 0 0 0 1px var(--brand); flex-shrink: 0; margin-top: 3px; z-index: 1;
}
.tl-corpo { flex: 1; min-width: 0; }
.tl-topo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-quando { font-size: 13px; font-weight: 650; }
.tl-dot--val { background: #2e7d52; box-shadow: 0 0 0 1px #2e7d52; }
/* Aprovada: pequeno escudo verde à esquerda da bola (mantém a linha/bolas iguais). */
.tl-escudo { position: absolute; left: -13px; top: 2px; color: #2e7d52; line-height: 0; z-index: 2; }
.tl-acoes { display: inline-flex; align-items: center; gap: 2px; margin-left: auto; }
.tl-conjunto { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-size: 12.5px; margin: 8px 0 2px; color: var(--ink-soft); cursor: pointer; }
.tl-conjunto input { margin: 0; flex-shrink: 0; }
.tl-btn { background: none; border: 0; cursor: pointer; color: var(--ink-soft); padding: 3px; border-radius: 5px; display: inline-flex; line-height: 0; }
.tl-btn:hover { background: var(--surface-2); color: var(--ink); }
.tl-btn--val:hover { color: #2e7d52; }
/* Botão «Validar» por interação: pílula mais sugestiva que o antigo visto. */
.tl-btn--pill { gap: 6px; padding: 5px 12px; border: 1px solid #2e7d52; border-radius: 999px;
    color: #2e7d52; background: var(--tone-verde-bg, #E6F1E9); font-size: 12.5px; font-weight: 700; line-height: 1; }
.tl-btn--pill:hover { background: #2e7d52; color: #fff; }
/* Botão "Solicitar aprovação" (só escudo, pequeno e compacto) na interação. */
.btn--aprovar { background: var(--brand-soft); color: #8A6D00; border: 1px solid #F4E2A4; box-shadow: none; padding: 6px 7px; line-height: 0; }
.btn--aprovar:hover { background: #fff; border-color: #E6C86A; }
/* Pesquisa de texto nas interações da obra: a lupa mostra/esconde a caixa. */
.int-busca-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.int-busca-lupa.is-ativo { color: var(--ink); background: var(--surface-2); }
.int-busca { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); flex: 1 1 auto; min-width: 0; }
.int-busca input[type=search] { flex: 1 1 auto; min-width: 0; max-width: 340px; padding: 6px 11px; border: 1px solid var(--cor-borda); border-radius: 999px; font-size: 13px; background: var(--cor-branco); }
.int-busca__n { font-size: 11.5px; white-space: nowrap; }
.tl-editar { margin-top: 8px; }
.tl-editar textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; resize: vertical; }
.tl-editar__linha { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.tl-editar__linha input[type=date] { padding: 6px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); margin-left: 4px; }
.marca-rever { color: #C9A227; font-size: 10px; vertical-align: middle; margin-left: 2px; }
.chk-antecipar { display: inline-flex; align-items: center; gap: 5px; margin-top: 7px; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.tl-antecip { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: #8A6D00; background: var(--brand-soft); border: 1px solid #F4E2A4; border-radius: 999px; padding: 1px 8px; }
/* Nota de trabalho (sem pedido de validação): marcador neutro, não amarelo/verde. */
.tl-dot--nota { background: #cfcfc8; box-shadow: 0 0 0 1px #cfcfc8; }
.tl-tag-pend { font-size: 11.5px; font-weight: 700; color: #8A6D00; background: var(--brand-soft); border: 1px solid #F4E2A4; border-radius: 999px; padding: 1px 8px; }
/* Resposta do diretor: por baixo da interação, ligeiramente avançada. */
/* Resposta do diretor: discreta — sem fundo nem linha verde, só texto indentado. */
.tl-resposta { margin: 5px 0 0 16px; padding: 1px 0 1px 11px; border-left: 2px solid var(--line); font-size: 13px; color: var(--ink-soft); display: flex; gap: 7px; align-items: flex-start; }
/* Botão verde (interação = nota de trabalho, "Registar"); a amarela é «Submeter». */
.btn--verde { background: #2e7d52; border-color: #2e7d52; color: #fff; }
.btn--verde:hover { background: #276b47; border-color: #276b47; }
.btn--verde-out { background: var(--surface); border-color: #2e7d52; color: #2e7d52; }
.btn--verde-out:hover { background: var(--tone-verde-bg, #E6F1E9); }
/* Interações do diretor: registar-e-enviar + registar-só-nota lado a lado. */
.int-botoes-dir { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.int-botao-nota { display: flex; flex-direction: column; gap: 3px; }
.int-botao-nota small { font-size: 11px; color: var(--ink-faint); text-align: center; }
.preco-antigo { display: inline-block; margin-top: 2px; font-size: 10.5px; font-weight: 600; color: #8A6D00; background: var(--brand-soft); border: 1px solid #F4E2A4; border-radius: 5px; padding: 0 5px; }
.precos-msg { font-size: 12.5px; align-self: center; }
/* Aviso de preços desatualizados, ao lado do botão «Atualizar preços». */
.aviso-precos { display: inline-flex; align-items: center; gap: 7px; align-self: center; font-size: 12.5px;
    color: var(--tone-amarelo-fg); background: var(--tone-amarelo-bg);
    border: 1px solid #F4E2A4; border-radius: 999px; padding: 5px 12px; }
.aviso-precos svg { flex: 0 0 auto; }
/* Aviso de data bloqueada na aprovação de interação (limite de marcações/dia). */
.aviso-data { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin: 2px 0 8px; padding: 8px 12px;
    font-size: 12.5px; color: var(--tone-vermelho-fg); background: var(--tone-vermelho-bg);
    border: 1px solid #ECCFCB; border-radius: 10px; }
.aviso-data svg { flex: 0 0 auto; }
/* «usar DD/MM» — aplica o próximo dia livre sugerido. */
.aviso-sugestao { margin-left: auto; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--tone-vermelho-fg);
    background: var(--surface); color: var(--tone-vermelho-fg); font-size: 11.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.aviso-sugestao:hover { background: var(--tone-vermelho-fg); color: #fff; }
/* «+» que aparece ao passar o rato na Ref. — insere uma linha livre acima. */
.cel-ref-add { white-space: nowrap; }
/* Só o símbolo «+» em amarelo, sem círculo (aparece no hover da Ref.). */
.add-acima { opacity: 0; margin-right: 5px; padding: 0; border: 0; background: none;
    color: var(--brand-deep); font-size: 17px; font-weight: 700; line-height: 1; vertical-align: middle;
    cursor: pointer; transition: opacity .12s, color .12s; }
.cel-ref-add:hover .add-acima, .add-acima:focus-visible { opacity: 1; }
.add-acima:hover { color: var(--brand); }
.barra-datas input[type="search"] { padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--r-sm); min-width: 180px; font-size: 14px; }
.barra-icones { display: flex; align-items: center; gap: 6px; margin-top: 10px; width: 100%; }
.filtro-ic { position: relative; }
.ic-btn { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink-soft); cursor: pointer; }
.ic-btn:hover { background: var(--surface-2); color: var(--ink); }
.ic-btn.is-ativo { border-color: var(--brand-deep); color: var(--brand-deep); background: var(--brand-soft); }
/* Variante com texto (dropdowns dos filtros): largura automática, ícone + rótulo. */
.ic-btn--texto { width: auto; gap: 6px; padding: 0 12px; font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap; }
/* Chips dos filtros aplicados (clicar remove). */
.chips-ativos { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip-ativo { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--brand-deep); background: var(--brand-soft); border: 1px solid #F4E2A4; border-radius: 999px; padding: 3px 10px; text-decoration: none; }
.chip-ativo:hover { background: #fff; }
.chip-ativo__x { font-weight: 800; color: var(--ink-soft); }
/* Indicadores do Seguimento (por baixo do nº da obra): bola amarela = interações
   por aprovar; ícone âmbar = orçamentos por aprovar. Só aparecem se existirem. */
.seg-indic { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.seg-bola { width: 9px; height: 9px; border-radius: 50%; background: #E6B800; box-shadow: 0 0 0 1px #C9A227; }
.seg-orc { display: inline-flex; color: #8A6D00; }
.pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--sh-card); padding: 12px; min-width: 210px; }
.pop-lbl { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.pop-lbl input { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.pop-acoes { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
.pop--lista { padding: 6px; max-height: 340px; overflow-y: auto; }
.pop-item { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-size: 14px; white-space: nowrap; }
.pop-item:hover { background: var(--surface-2); text-decoration: none; }
.pop-item.is-sel { background: var(--brand-soft); font-weight: 600; }
.ord-th { color: inherit; text-decoration: none; cursor: pointer; white-space: nowrap; }
.ord-th:hover { text-decoration: underline; }
.ord-th.is-ord { color: var(--ink); font-weight: 700; }
.cond-editor { display: flex; flex-direction: column; gap: 10px; }
.cond-bloco { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; background: #fff; }
.cond-bloco.is-on { border-color: #F4E2A4; background: #FFFDF5; }
.cond-cab { display: flex; align-items: center; gap: 10px; font-size: 14.5px; cursor: pointer; }
.cond-texto { width: 100%; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); font: inherit; resize: vertical; }
.tl-prox { display: inline-flex; flex-direction: column; line-height: 1.25; font-size: 12px; color: var(--ink-soft); }
.tl-prox-ant { font-size: 10.5px; color: var(--ink-soft); text-decoration: line-through; opacity: .7; }
.tl-texto { font-size: 13.5px; margin-top: 4px; color: var(--ink); }

/* A metade do "próximo contacto" divide-se em dois: Contacto Cliente (editável)
   à esquerda e o Próximo contacto à direita. */
.datebar-next-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.datebar-abertura-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.datebar-input {
    font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px;
    border: 1px solid var(--linha); border-radius: 8px; padding: 3px 8px;
    background: #fff; color: var(--ink); font-family: inherit; max-width: 100%;
}
@media (max-width: 768px) {
    .datebar { grid-template-columns: 1fr; }
    .datebar-next-split { grid-template-columns: 1fr; }
    .datebar-abertura-split { grid-template-columns: 1fr; }
    .hist-ev { grid-template-columns: 30px 1fr; }
    .hist-ir { display: none; }
    /* Percurso: no telemóvel o diagrama passa a stepper vertical. */
    .cartao--percurso .diag-scroll { display: none; }
    .pc-vert { display: block; }
    /* Histórico global por dia */
    .sel { padding: 18px 16px 14px; }
    .sel__num { font-size: 34px; }
    .sel__hint { display: none; }
    .tl-cartao { padding: 6px 16px 18px; }
    .tl-item { grid-template-columns: 40px 1fr; gap: 12px; }
    .tl-item::before { left: 19px; }
    .tl-node { width: 38px; height: 38px; }
    .tl-obra { max-width: 100%; margin-left: 0; }
}

/* ============================================================
   DASHBOARDS por perfil (KPIs, barras, gráfico, finanças)
   ============================================================ */

.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 20px;
}
.kpi-grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpi {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
    padding: 16px 18px; box-shadow: var(--sh-card);
}
.kpi--destaque { background: var(--brand-soft); border-color: #F4E2A4; box-shadow: none; }
.kpi--alerta { background: var(--tone-vermelho-bg); border-color: #ECCFCB; box-shadow: none; }
.kpi__lbl { font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.kpi__val { font-size: 27px; font-weight: 750; letter-spacing: -0.02em; margin: 4px 0 2px; line-height: 1.1; }
.kpi__sub { font-size: 12px; color: var(--ink-soft); }

/* Variação percentual (delta) */
.delta { font-weight: 700; }
.delta--sobe { color: var(--tone-verde-fg); }
.delta--desce { color: var(--tone-vermelho-fg); }
.delta--neutro { color: var(--ink-soft); }

/* Barras horizontais (obras por estado) */
.barras { display: flex; flex-direction: column; gap: 11px; margin-top: 14px; }
.barra-linha { display: flex; align-items: center; gap: 10px; }
.barra-nome { font-size: 13px; min-width: 92px; flex-shrink: 0; }
.barra-trilho { flex: 1; height: 9px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.barra-fill { display: block; height: 100%; border-radius: 999px; min-width: 2px; }
.barra-num { font-size: 13px; font-weight: 700; min-width: 24px; text-align: right; }

/* Gráfico de barras (valor ganho por mês: ano atual vs anterior) */
.barchart {
    display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px;
    align-items: end; height: 180px; margin-top: 18px;
}
.bc-col { display: flex; flex-direction: column; align-items: center; height: 100%; }
.bc-bars { display: flex; align-items: flex-end; justify-content: center; gap: 3px; flex: 1; width: 100%; }
.bc-bar { width: 42%; max-width: 16px; border-radius: 4px 4px 0 0; min-height: 2px; transition: opacity .15s; }
.bc-bar--atual { background: var(--brand); }
.bc-bar--ant { background: #D8D6CC; }
.bc-bar:hover { opacity: 0.75; }
.bc-lbl { font-size: 11px; color: var(--ink-soft); margin-top: 6px; }
.bc-lbl--atual { color: var(--brand-deep); font-weight: 700; }

/* Legenda */
.legenda { display: flex; gap: 16px; flex-wrap: wrap; }
.legenda__item { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.legenda__cor { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* Cartões-atalho de administração */
.cartao--link { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.cartao--link:hover { border-color: var(--brand-deep); box-shadow: var(--sh-card); }
.cartao--desativado { opacity: 0.6; }
.ferr-ico { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; color: var(--brand-deep); flex-shrink: 0; }
.badge-soft { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); padding: 1px 7px; border-radius: 999px; }
.sep-titulo { margin: 26px 0 14px; font-size: 16px; }

/* ============================================================
   Estados/permissões: banners, pills, botão de perigo, matriz
   ============================================================ */

.banner-ok, .banner-aviso {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
}
.banner-ok    { background: var(--tone-verde-bg);    border-color: #BfE0CC; }
.banner-aviso { background: var(--tone-vermelho-bg); border-color: #ECCFCB; }
/* Orçamento eliminado (soft-delete): mantido no histórico, sem PDF. */
.banner-eliminado { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: #FDECEA; border-color: #F5C6C0; }
/* «Não aprovado»: banner minimalista (uma nota curta com o motivo). */
.banner-eliminado--compacto { padding: 12px 16px; font-size: 13.5px; line-height: 1.45; }

/* Diálogo de validação: escolha Aprovar / Não aprovar. */
.val-opcoes { display: flex; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.val-opcao { flex: 1 1 140px; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: var(--r-sm); cursor: pointer; font-weight: 600; font-size: 14px; }
.val-opcao input { width: auto; margin: 0; }
.val-opcao.is-sel { border-color: #2E7D52; background: var(--tone-verde-bg, #E8F5E9); color: #2E7D52; }
.val-opcao--neg.is-sel { border-color: #C62828; background: var(--tone-vermelho-bg, #FDECEA); color: #C62828; }

/* Seguimento: secção «Finalizadas a aguardar validação» (Ganho pendente). */
.painel--aguarda { border-color: #BfE0CC; box-shadow: inset 3px 0 0 #2E7D52; }

/* Nota provisória (ex.: valores em € ainda em afinação) — discreta, âmbar. */
.nota-provisoria { display: flex; align-items: center; gap: 8px; margin: -6px 0 18px; padding: 8px 12px; font-size: 12.5px; line-height: 1.4; color: #8A6D00; background: #FFF8E1; border: 1px solid #FFE082; border-radius: var(--r-sm); }
.nota-provisoria__pt { font-size: 14px; flex-shrink: 0; }

.pill-ganho {
    display: inline-block; font-size: 10.5px; font-weight: 700; vertical-align: middle;
    background: var(--tone-verde-bg); color: var(--tone-verde-fg);
    border: 1px solid #BfE0CC; padding: 1px 7px; border-radius: 999px; margin-left: 6px;
}

.btn--perigo { background: var(--tone-vermelho-fg); border-color: var(--tone-vermelho-fg); color: #fff; }
.btn--perigo:hover { filter: brightness(0.94); }

/* Agrupador de campos (ex.: faturação no formulário da obra) */
.campo-grupo { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px 4px; margin-bottom: 16px; }
.campo-grupo > legend { font-weight: 650; font-size: 13.5px; padding: 0 6px; }

/* Matriz de permissões (perfil × estado) */
.tabela--matriz td.num, .tabela--matriz th.num { text-align: center; }
.tabela--matriz input[type="checkbox"] { width: 18px; height: 18px; }

/* ============================================================
   DASHBOARDS (Comercial · Gestão: Visão Geral / Performance)
   ============================================================ */

/* -- Cabeçalho + toggles -------------------------------------- */
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--brand-deep); }
.dash-titulo { font-size: 30px; line-height: 1.1; margin: 2px 0 4px; letter-spacing: -.02em; }
.dash-sub { margin: 0; font-size: 14px; }
.dash-toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; box-shadow: var(--sh-card); }
.seg__item { display: inline-flex; align-items: center; gap: 6px; padding: 7px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 650; color: var(--ink-soft); white-space: nowrap; }
.seg__item.is-ativo { background: var(--ink); color: #fff; }
.seg__item:not(.is-ativo):hover { color: var(--ink); }

/* -- KPI cards ------------------------------------------------- */
.dash-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 18px; }
.dash-kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; box-shadow: var(--sh-card); }
.dash-kpi__ico { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); margin-bottom: 12px; }
.dash-kpi__topo { position: absolute; top: 18px; right: 18px; }
.dash-kpi__val { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.dash-kpi__lbl { margin-top: 4px; font-size: 14px; font-weight: 600; }
.dash-kpi__foot { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line-soft); font-size: 12px; color: var(--ink-faint); }
.dash-kpi--amarelo { background: var(--brand); border-color: var(--brand); }
.dash-kpi--amarelo .dash-kpi__ico { background: rgba(0,0,0,.08); border-color: transparent; color: var(--ink); }
.dash-kpi--amarelo .dash-kpi__foot { border-top-color: rgba(0,0,0,.12); color: rgba(26,26,23,.6); }
.dash-kpi--solo { margin: 0; }
.delta { font-size: 12.5px; font-weight: 800; }
.delta.is-pos { color: var(--tone-verde-fg); }
.delta.is-neg { color: var(--tone-vermelho-fg); }

/* -- Banner de faturação (em breve) --------------------------- */
.fatura-banner { margin-bottom: 18px; }
.fatura-banner--amarelo { background: var(--brand); border-color: var(--brand); }
.fatura-banner__top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.fatura-banner__titulo { font-size: 17px; margin: 0; }
.fatura-banner__sub { margin: 2px 0 0; font-size: 13px; }
.fatura-banner__ico { color: var(--ink-soft); }
.fatura-banner--amarelo .fatura-banner__ico { color: rgba(26,26,23,.6); }
.fatura-grid { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: flex-end; }
.fatura-bloco { min-width: 130px; }
.fatura-lbl { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; }
.fatura-banner--amarelo .fatura-lbl { color: rgba(26,26,23,.7); }
.fatura-val { font-size: 22px; font-weight: 800; }
.fatura-nota { margin: 14px 0 0; font-size: 12px; display: flex; align-items: center; gap: 5px; }

/* -- Painel genérico (cartão com topo) ------------------------ */
.painel__topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.painel__titulo { font-size: 16px; margin: 0; }
.painel__sub { margin: 2px 0 0; font-size: 12.5px; }
.contador { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 8px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 800; }
.dash-cols { gap: 16px; }

/* -- Avatar --------------------------------------------------- */
.av { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 12.5px; font-weight: 800; flex-shrink: 0; }

/* -- Agenda de contactos -------------------------------------- */
.agenda { display: flex; flex-direction: column; }
.agenda-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line-soft); color: inherit; }
.agenda-row:first-child { border-top: 0; }
.agenda-row:hover { background: var(--surface-2); border-radius: 10px; }
.agenda-data { width: 52px; text-align: center; flex-shrink: 0; border-left: 3px solid var(--line); padding-left: 8px; }
.agenda-data.is-atraso { border-left-color: var(--tone-vermelho-fg); }
.agenda-data.is-hoje { border-left-color: var(--brand-deep); }
.agenda-data__lbl { display: block; font-size: 10px; font-weight: 800; letter-spacing: .05em; color: var(--ink-faint); }
.agenda-data.is-atraso .agenda-data__lbl { color: var(--tone-vermelho-fg); }
.agenda-data__dia { display: block; font-size: 14px; font-weight: 700; }
.agenda-corpo { flex: 1; min-width: 0; }
.agenda-nome { font-weight: 650; font-size: 14.5px; }
.agenda-obra { font-size: 13px; }
.agenda-meta { font-size: 11.5px; color: var(--ink-faint); display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.agenda-dir { text-align: right; flex-shrink: 0; }
.agenda-valor { font-weight: 800; font-size: 14px; }
.badge-estado { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; color: var(--ink-soft); margin-top: 3px; }
.badge-estado::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--ink-faint)); }
.agenda-call { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--brand-soft); color: var(--brand-deep); flex-shrink: 0; }

/* -- Obras recém-abertas -------------------------------------- */
.obra-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line-soft); color: inherit; }
.obra-row:first-child { border-top: 0; }
.obra-row:hover { background: var(--surface-2); border-radius: 10px; }
.obra-ico { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--ink); color: var(--brand); flex-shrink: 0; }
.obra-corpo { flex: 1; min-width: 0; }
.obra-nome { font-weight: 650; font-size: 14.5px; }
.obra-local { font-size: 12px; display: flex; align-items: center; gap: 4px; }
.obra-datas { display: flex; gap: 18px; text-align: right; flex-shrink: 0; }
.obra-datas__lbl { display: block; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; color: var(--ink-faint); }
.obra-prox { color: var(--brand-deep); }

/* -- Aviso de fila (perdidas a rever) ------------------------- */
.aviso-fila { display: flex; align-items: center; gap: 10px; padding: 13px 16px; margin-bottom: 16px; border-radius: var(--r-md); background: var(--tone-vermelho-bg); border: 1px solid #ECCFCB; color: var(--ink); font-size: 13.5px; }
.aviso-fila__pt { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px; background: var(--tone-vermelho-fg); color: #fff; font-weight: 800; font-size: 12.5px; }

/* -- Performance: layout -------------------------------------- */
.perf-grid { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.perf-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; align-content: start; }

/* Banner amarelo de volume adjudicado */
.banner-adjud { background: var(--brand); border-color: var(--brand); }
.banner-adjud__lbl { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; color: rgba(26,26,23,.65); }
.banner-adjud__val { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.banner-adjud__delta { font-size: 13px; margin-top: 4px; }
.qbars { display: flex; gap: 12px; margin-top: 22px; }
.qbar { flex: 1; text-align: center; }
.qbar-trilho { height: 80px; display: flex; align-items: flex-end; justify-content: center; }
.qbar-fill { display: block; width: 60%; min-height: 4px; background: var(--ink); border-radius: 7px 7px 0 0; }
.qbar-lbl { font-size: 11.5px; font-weight: 700; margin-top: 8px; }
.qbar-val { font-size: 11px; color: rgba(26,26,23,.7); }

/* Donut de conversão */
.perf-donut { display: flex; flex-direction: column; align-items: center; }
.donut-wrap { position: relative; width: 156px; height: 156px; margin: 4px 0 12px; }
.donut-centro { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-centro strong { display: block; font-size: 30px; font-weight: 800; }
.donut-centro span { font-size: 12px; color: var(--ink-soft); }
.donut-legenda { display: flex; flex-direction: column; gap: 6px; width: 100%; font-size: 13px; color: var(--ink-soft); }
.donut-legenda .dot, .grafico-legenda .dot, .donut-legenda span > .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

/* -- Ranking por comercial ------------------------------------ */
.rank { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 14px; padding: 12px 2px; border-top: 1px solid var(--line-soft); }
.rank-row:first-child { border-top: 0; }
.rank-idx { width: 22px; color: var(--ink-faint); font-size: 13px; }
.rank-nome { width: 150px; font-weight: 650; font-size: 14px; flex-shrink: 0; }
.rank-trilho { flex: 1; height: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.rank-fill { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.rank-val { width: 96px; text-align: right; font-weight: 800; font-size: 14px; }

/* -- Gráfico (legenda + totais) ------------------------------- */
.grafico-legenda { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-soft); }
.grafico-totais { display: flex; gap: 40px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.grafico-totais__v { font-size: 20px; font-weight: 800; }

/* -- Responsivo ----------------------------------------------- */
@media (max-width: 1000px) {
    .perf-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .obra-datas { gap: 12px; }
}

/* -- Correção infinite-grow do Chart.js: contentor de altura fixa -- */
.grafico-box { position: relative; height: 200px; width: 100%; }
.grafico-box > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.donut-wrap > canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* -- Ficha de cliente: filtro + lista de orçamentos -- */
.dados--2col { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; align-items: baseline; }
.dados--2col dt { color: var(--ink-soft); font-size: 13px; }
.ficha-filtro { display: flex; align-items: center; gap: 8px; }
.ficha-filtro select { padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 13.5px; }
.ficha-filtro__datas { display: inline-flex; align-items: center; gap: 6px; }
.ficha-filtro__datas input { padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.ficha-mais { text-align: center; margin-top: 14px; }

/* Tabela de orçamentos na ficha do cliente.
   Desktop (>=821px): larguras fixas — Número e Data sempre numa linha (Data
   sempre visível), Total/Estado com espaço próprio, e o nome da Obra ocupa o
   resto truncando com reticências. min-width dá scroll horizontal em janelas
   estreitas em vez de espremer. Em telemóvel usa o modo cartão (tabela--cards),
   por isso estas regras ficam só no desktop para não truncar dentro dos cards. */
@media (min-width: 821px) {
    .tabela--orc-cliente { table-layout: fixed; min-width: 780px; }
    .tabela--orc-cliente th, .tabela--orc-cliente td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .tabela--orc-cliente th:nth-child(1), .tabela--orc-cliente td:nth-child(1) { width: 152px; }
    .tabela--orc-cliente td:nth-child(1) code { font-size: 12px; }
    .tabela--orc-cliente th:nth-child(3), .tabela--orc-cliente td:nth-child(3) { width: 128px; }
    .tabela--orc-cliente th:nth-child(4), .tabela--orc-cliente td:nth-child(4) { width: 132px; }
    .tabela--orc-cliente th:nth-child(5), .tabela--orc-cliente td:nth-child(5) { width: 132px; }
    /* Coluna Obra (2) ocupa o espaço restante e trunca no anchor. */
    .tabela--orc-cliente td.cel-obra a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* -- Ligação de regresso (ex.: orçamento → obra) -- */
.ligacao-voltar { display: inline-block; margin-bottom: 6px; font-size: 13px; color: var(--ink-soft); }
.ligacao-voltar:hover { color: var(--ink); }

/* -- Chips de cliente (consulta dos clientes já existentes na obra) -- */
.chips-cliente { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.chips-cliente__lista { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip-cliente { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 12.5px; color: var(--ink); }
/* Só informativo: sem cursor/hover, para não sugerir que muda o cliente. */
.chip-cliente--info { cursor: default; color: var(--ink-soft); }

/* -- Modal (confirmação de edição de orçamento) -- */
.modal-overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(26,26,23,.45); backdrop-filter: blur(2px); }
.modal { position: relative; width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-pop); padding: 26px 24px 22px; }
.modal h3 { margin: 0 0 8px; }
.modal__botoes { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal__fechar { position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border-radius: 8px; font-size: 22px; line-height: 1; color: var(--ink-soft); }
.modal__fechar:hover { background: var(--surface-2); color: var(--ink); }

/* -- Atalho de Margens (diretores) na barra de topo -- */
.topo__mg { display: inline-flex; }
.topo__cal--mg { color: var(--brand-deep); }
.modal.atalho-mg { max-width: 560px; }
.atalho-mg h3 { display: inline-flex; align-items: center; gap: 8px; }
.atalho-mg__campo { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-soft); }
.atalho-mg__campo:focus-within { border-color: var(--brand-deep); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-deep) 20%, transparent); }
.atalho-mg__campo input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font: inherit; color: var(--ink); }
.atalho-mg__corpo { margin-top: 10px; max-height: 54vh; overflow-y: auto; }
.atalho-mg__tit { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-faint); margin: 14px 4px 4px; }
.atalho-mg__grupo:first-child .atalho-mg__tit { margin-top: 2px; }
.atalho-mg__cli { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; margin: 12px 4px 3px; }
.atalho-mg__obra-it, .atalho-mg__orc { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px; background: none; cursor: pointer; font: inherit; color: var(--ink); }
.atalho-mg__obra-it:hover, .atalho-mg__orc:hover { background: var(--surface-2); }
.atalho-mg__1 { flex: 1; min-width: 0; font-weight: 600; }
.atalho-mg__2 { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.atalho-mg__orc > .mono:first-child { flex: 1; min-width: 0; font-weight: 600; }
.atalho-mg__orc-t { color: var(--ink-soft); white-space: nowrap; }
.atalho-mg__orc-e { font-size: 11.5px; color: var(--ink-faint); white-space: nowrap; }
.atalho-mg__voltar { border: 0; background: none; color: var(--brand-deep); font-weight: 600; cursor: pointer; padding: 2px 0; margin-bottom: 4px; font-size: 13px; }
.atalho-mg__obra { font-size: 13.5px; color: var(--ink); margin-bottom: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.atalho-mg__vazio, .atalho-mg__dica { padding: 16px 6px; color: var(--ink-faint); font-size: 13px; }

/* -- Manual de ajuda -- */
.ajuda-doc { max-width: 860px; }
.ajuda-busca { display: flex; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink-soft); }
.ajuda-busca:focus-within { border-color: var(--brand-deep); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-deep) 18%, transparent); }
.ajuda-busca input { flex: 1; min-width: 0; border: 0; outline: none; background: none; font: inherit; color: var(--ink); }
.ajuda-cat { margin-top: 18px; }
.ajuda-cat__tit { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); margin: 0 0 6px; }
.ajuda-art { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--surface); overflow: hidden; }
.ajuda-art[open] { border-color: var(--line-strong); }
.ajuda-art__tit { display: flex; align-items: center; gap: 10px; padding: 13px 15px; font-weight: 650; cursor: pointer; list-style: none; }
.ajuda-art__tit::-webkit-details-marker { display: none; }
.ajuda-art__tit::after { content: '+'; margin-left: auto; color: var(--ink-faint); font-size: 18px; line-height: 1; }
.ajuda-art[open] .ajuda-art__tit::after { content: '−'; }
.ajuda-tag { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 999px; }
.ajuda-tag--comercial { background: var(--tone-azul-bg, #e7eef5); color: var(--tone-azul-fg, #3672a0); }
.ajuda-tag--diretor { background: var(--tone-amarelo-bg, #f7efd0); color: var(--tone-amarelo-fg, #9a7a10); }
.ajuda-art__corpo { padding: 2px 16px 16px; border-top: 1px solid var(--line); }
.ajuda-art__corpo h2 { font-size: 17px; margin: 14px 0 6px; }
.ajuda-art__corpo h3 { font-size: 15px; margin: 12px 0 5px; }
.ajuda-art__corpo p { margin: 8px 0; line-height: 1.55; }
.ajuda-art__corpo ul, .ajuda-art__corpo ol { margin: 8px 0; padding-left: 22px; line-height: 1.55; }
.ajuda-art__corpo li { margin: 3px 0; }
.ajuda-art__corpo blockquote { margin: 10px 0; padding: 9px 13px; border-left: 3px solid var(--brand-deep); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--ink-soft); font-size: 13.5px; }
.ajuda-art__corpo a { color: var(--brand-deep); font-weight: 600; }
.ajuda-cab { max-width: 860px; align-items: flex-start; }
/* Gestão de conteúdos (Admin IT) */
.ajuda-gerir-cat td { background: var(--surface-2); font-weight: 800; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); }
.ajuda-gerir-cat td { display: flex; align-items: center; gap: 8px; }
.ajuda-cat-mover { display: inline-flex; gap: 2px; margin-left: auto; }
.ajuda-cat-mover button { border: 0; background: none; cursor: pointer; color: var(--ink-soft); padding: 2px 5px; border-radius: 5px; font-size: 13px; line-height: 1; }
.ajuda-cat-mover button:hover { background: var(--surface); color: var(--ink); }
.ajuda-cat-mover button:disabled { opacity: .3; cursor: default; }
.ajuda-manut { max-width: 860px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.ajuda-manut.is-on { border-color: #E7B84B; background: var(--tone-amarelo-bg, #f9f0d6); }
.ajuda-manut label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; color: var(--ink-soft); }
.ajuda-manut input { margin-top: 2px; flex-shrink: 0; }
.ajuda-manut-aviso { display: flex; align-items: center; gap: 16px; color: var(--ink-soft); }
.ajuda-manut-aviso h2 { margin: 0 0 4px; font-size: 18px; color: var(--ink); }
.ajuda-manut-aviso p { margin: 0; }
.ajuda-editor { width: 100%; font-family: var(--mono); font-size: 13.5px; line-height: 1.5; resize: vertical; }
.ajuda-dica { margin-top: 8px; font-size: 12.5px; color: var(--ink-faint); }
.ajuda-dica code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.form__grelha { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 18px; margin-bottom: 4px; }
.form__grelha .campo { margin: 0; }
.form__grelha .campo--largo { grid-column: 1 / -1; }
.campo-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
@media (max-width: 700px) { .form__grelha { grid-template-columns: 1fr 1fr; } }

/* -- Pré-visualização de orçamento com zoom (janela sobreposta na obra) --
   O modal é uma coluna flex limitada à altura do ecrã; o "viewport" fica no
   meio e faz scroll quando o conteúdo (já com zoom aplicado) é maior. */
.orc-preview-caixa { display: flex; flex-direction: column; max-height: 92vh; }
.orc-zoom-barra { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding-right: 40px; }
.orc-zoom-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font-size: 16px; line-height: 1; }
.orc-zoom-btn--txt { font-size: 12.5px; font-weight: 600; }
.orc-zoom-btn:hover { border-color: var(--ink-soft); }
.orc-zoom-valor { min-width: 48px; text-align: center; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.orc-zoom-viewport { overflow: auto; flex: 1 1 auto; }

/* -- Filtros do localizador de orçamentos -- */
.filtros-orc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.filtros-orc input[type="search"] { flex: 1; min-width: 160px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); font-size: 13.5px; }
.filtros-orc .select-curto { padding: 9px 11px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); font-size: 13.5px; }
.filtros-orc__data { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); }
.filtros-orc__data input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; }

/* -- Orçamentos da obra: último por cliente, expansível -- */
.tabela--orcamentos-obra tbody { border: 0; }
/* O número do orçamento (código) nunca deve partir em duas linhas. */
.tabela--orcamentos-obra .cel-principal code { white-space: nowrap; }
.col-expandir { width: 36px; text-align: center; padding-left: 6px !important; padding-right: 6px !important; }
.btn-expandir { width: 24px; height: 24px; border: 1px solid var(--line); border-radius: 7px; font-size: 16px; line-height: 1; color: var(--ink-soft); display: inline-grid; place-items: center; }
.btn-expandir:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-faint); }
.linha-anterior > td { background: var(--surface-2); }
.linha-anterior code { opacity: .85; }

/* -- Contador de orçamentos/revisões (só o dígito, pill discreta) -- */
.contador-rev { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); font-size: 11.5px; font-weight: 600; vertical-align: middle; }

/* -- Conversão de desconto a líquido (orçamento) -- */
/* Análise de margens (modal, admin/diretores). */
.tabela--margens { font-size: 12.5px; }
.tabela--margens th, .tabela--margens td { padding: 6px 6px; white-space: nowrap; }
/* Colunas (com o checkbox de seleção em 1.º): 9=«Venda un.», 10=«Venda». */
/* Linha vertical a separar a zona de edição (até «Venda un.») dos resultados. */
.tabela--margens th:nth-child(9), .tabela--margens td:nth-child(9) { border-right: 2px solid var(--line); padding-right: 7px; }
.tabela--margens th:nth-child(10), .tabela--margens td:nth-child(10) { padding-left: 7px; }
/* A Descrição (3.ª col) absorve o espaço livre — as outras ficam juntas (sem vão)
   — e corta com reticências em vez de partir a linha; o nome completo fica no title. */
.tabela--margens th:nth-child(3), .tabela--margens td:nth-child(3) { width: 100%; }
.tabela--margens td:nth-child(3) { max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tabela--margens tfoot td { border-top: 2px solid var(--line); }
.mg-pos { color: var(--tone-verde-fg); font-weight: 600; }
.mg-neg { color: var(--tone-vermelho-fg); font-weight: 600; }
/* Sem dados para avaliar a margem (orçamento sem custo congelado). */
.mg-sem { display: inline-flex; color: var(--ink-faint); cursor: help; vertical-align: middle; }
.aviso-margens { margin: 12px 0 0; padding: 9px 13px; font-size: 12.5px; color: var(--tone-amarelo-fg);
    background: var(--tone-amarelo-bg); border: 1px solid #F4E2A4; border-radius: 10px; }

/* Ferramenta de margens do diretor (interativa) */
/* A grelha cabe na largura normal: a Descrição encolhe/corta e preenche o
   espaço livre, por isso não é preciso o cap alargado nem scroll horizontal. */
.mg-tool { padding: 16px 18px; }
.mg-glob { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; margin-bottom: 14px; }
.mg-glob label { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--ink-soft); }
.mg-cell { width: 46px; text-align: right; border: 1px solid var(--line-strong); border-radius: 7px; padding: 5px 5px;
    font: inherit; font-size: 12.5px; font-family: var(--mono); background: var(--surface); color: var(--ink); }
.mg-cell:focus { outline: none; border-color: var(--brand-deep); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-deep) 22%, transparent); }
.mg-cell.mg-venda { width: 70px; font-weight: 700; }
.mg-cell.mg-mrg { width: 74px; font-weight: 600; }
.mg-cell.mg-pos { color: var(--tone-verde-fg); }
.mg-cell.mg-neg { color: var(--tone-vermelho-fg); }
/* Esconde as setas dos number inputs — poupam largura e limpam a grelha. */
.mg-cell::-webkit-outer-spin-button, .mg-cell::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.mg-cell { -moz-appearance: textfield; appearance: textfield; }
.tabela--margens td:has(.mg-cell) { padding: 4px 6px; }
.tabela--margens th .mg-sub { display: block; font-size: 10px; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--ink-faint); }
.tabela--margens th.mg-sel, .tabela--margens td.mg-sel { width: 30px; text-align: center; padding-left: 4px; padding-right: 4px; }
.tabela--margens .mg-chk, #mgChkAll { cursor: pointer; width: 15px; height: 15px; }
.mg-glob--precos { margin-top: -6px; }
.mg-preco-msg { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.mg-preco-msg--ok { color: var(--tone-verde-fg); }
.mg-resumo { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 16px; padding: 14px 18px; background: var(--surface-2); border-radius: 12px; }
.mg-resumo .b { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); font-weight: 700; display: block; }
.mg-resumo .v { font-size: 24px; font-weight: 800; font-family: var(--mono); letter-spacing: -.02em; margin-top: 2px; display: block; }
.mg-resumo__df .v { display: flex; align-items: baseline; gap: 4px; }
.mg-resumo__df .mg-df { width: 64px; font-size: 20px; font-weight: 800; font-family: var(--mono); text-align: right; padding: 3px 6px; }
.mg-resumo__df .mg-df-pct { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.mg-resumo__df .mg-df-eur { display: block; font-size: 12px; margin-top: 3px; }
/* Telemóvel: a grelha da ferramenta continua a fazer scroll horizontal (é um
   editor de muitas colunas), mas o resumo compacta-se para 2 colunas. */
@media (max-width: 820px) {
    .mg-tool { padding: 14px 12px; }
    .mg-glob { font-size: 12.5px; gap: 9px; }
    .mg-resumo { gap: 12px 18px; padding: 13px 14px; }
    .mg-resumo > div { flex: 1 1 40%; min-width: 118px; }
    .mg-resumo .v { font-size: 19px; }
    .mg-resumo__df .mg-df { width: 58px; font-size: 17px; }
    /* Botões um por baixo do outro (não cabem lado a lado no telemóvel). */
    .mg-tool .form__botoes { flex-direction: column; align-items: stretch; gap: 8px; }
    .mg-tool .form__botoes .btn { width: 100%; justify-content: center; }

    /* ---- Grelha de margens em CARTÕES (sem scroll horizontal) ----
       Cada artigo é um cartão; os campos ficam com rótulo (data-label) por
       cima. Os inputs mantêm os data-i/data-k, por isso o recálculo funciona. */
    .tabela--margens { display: block; min-width: 0; }
    .tabela--margens thead, .tabela--margens tfoot { display: none; }
    .tabela--margens tbody { display: block; }
    .tabela--margens tbody tr {
        display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; align-items: start;
        border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; margin-bottom: 10px;
        background: var(--surface); box-shadow: var(--sh-card);
    }
    .tabela--margens tbody td, .tabela--margens td:has(.mg-cell) {
        display: flex; flex-direction: column; gap: 4px; align-items: flex-start;
        padding: 0; border: 0; text-align: left; font-size: 14px;
    }
    .tabela--margens tbody td::before {
        content: attr(data-label); font-size: 10.5px; font-weight: 700;
        text-transform: uppercase; letter-spacing: .03em; color: var(--ink-faint);
    }
    .tabela--margens tbody td.mg-c-ref, .tabela--margens tbody td.mg-c-desc { grid-column: 1 / -1; }
    /* No cartão a descrição mostra-se por inteiro (anula o corte do modo tabela). */
    .tabela--margens tbody td.mg-c-desc { font-weight: 600; font-size: 14.5px; width: auto; max-width: none; overflow: visible; white-space: normal; }
    .tabela--margens tbody .mg-cell { width: 100%; max-width: 150px; font-size: 15px; padding: 8px; }
    /* Checkbox de seleção no canto superior direito do cartão. */
    .tabela--margens tbody td.mg-sel { position: absolute; top: 10px; right: 11px; padding: 0; width: auto; }
    .tabela--margens tbody td.mg-sel::before { content: none; }
    .tabela--margens tbody td.mg-c-ref { padding-right: 30px; }
}
/* Atalho da interação do diretor para o orçamento com margens calculadas. */
.tl-orc-atalho { display: inline-flex; align-items: center; gap: 6px; margin-top: 7px; padding: 5px 11px; border-radius: 999px;
    background: var(--brand-soft); border: 1px solid #F4E2A4; color: var(--brand-deep); font-size: 12.5px; font-weight: 700; text-decoration: none; }
.tl-orc-atalho:hover { background: var(--brand-deep); color: #fff; border-color: var(--brand-deep); }

/* Etiqueta "líq." por baixo do preço (não colada ao lado), alinhada à direita. */
.liq-tag { display: block; width: fit-content; margin: 3px 0 0 auto; padding: 0 6px; border-radius: 9px; background: #eef6f0; border: 1px solid #cfe6d8; color: #2e7d52; font-size: 11px; font-weight: 600; white-space: nowrap; }
.acoes-linha { white-space: nowrap; text-align: right; }
.link-acao { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; margin-left: 3px; cursor: pointer; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.link-acao:hover { background: var(--surface-2); color: var(--ink); }
.aplicar-desc__sep { color: var(--line); margin: 0 2px; }

/* -- Observações da obra (caixa recolhida com contador) -- */
.bloco-recolhe { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.bloco-recolhe > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.bloco-recolhe > summary::-webkit-details-marker { display: none; }
.bloco-recolhe > summary::before { content: '▸'; color: var(--ink-soft); font-size: 11px; transition: transform .15s; }
.bloco-recolhe[open] > summary::before { transform: rotate(90deg); }
.ver-mais-int { margin-top: 6px; }
.ver-mais-int > summary { cursor: pointer; color: var(--ink-soft); font-size: 13px; list-style: none; }
.ver-mais-int > summary::-webkit-details-marker { display: none; }

/* -- Sino: dropdown de próximos contactos -- */
.sino__cab { padding: 10px 12px 6px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--line); }
.sino__item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
a.sino__item:hover { background: var(--surface-2); }
.sino__item--info { color: var(--ink-soft); }
.sino__num { display: inline-grid; place-items: center; min-width: 26px; height: 24px; padding: 0 6px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: 13px; }
.sino__item.is-rever .sino__num { background: var(--brand-soft); border-color: #F4E2A4; color: var(--brand-deep); }
.sino__item.is-atraso .sino__num { background: #fdecec; border-color: #f3c7c4; color: #bf453c; }
.sino__item.is-hoje .sino__num { background: #fff5e0; border-color: #f0dca8; color: #997400; }
.sino__rodape { display: block; padding: 9px 12px; font-size: 13px; font-weight: 600; color: var(--acento, #997400); text-decoration: none; }
.sino__rodape:hover { background: var(--surface-2); }

/* -- Chip de filtro ativo (lista de obras) -- */
.chip-filtro { margin: 10px 0 0; padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-filtro a { margin-left: auto; font-size: 13px; }

/* -- Aviso de limite (contador) -- */
.ajuda--erro { color: #bf453c; font-weight: 600; }
/* Ajuste do contentor do dropdown para itens de largura total */
.sino__lista { padding: 0; width: 320px; overflow: hidden; }
.sino__vazio { padding: 14px; }
.sino__item:last-of-type { border-bottom: none; }

/* -- Modal de adjudicação: lista de orçamentos -- */
.lista-radio { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; max-height: 320px; overflow:auto; }
.radio-linha { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; }
.radio-linha:hover { background: var(--surface-2); }
.radio-linha:has(input:checked) { border-color: #2e7d52; background: #eef6f0; }

/* -- Timeline de auditoria -- */
a.tl-link { display: flex; align-items: flex-start; gap: 10px; text-decoration: none; color: inherit; padding: 9px 8px; border-radius: 8px; }
a.tl-link:hover { background: var(--surface-2); }
.audit-tag { display: inline-block; padding: 0 7px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--ink-soft); }
.tl-ir { margin-left: auto; align-self: center; color: var(--ink-soft); font-weight: 700; }
.tl-dot--adjudicado, .tl-dot--orcamento_criado { background: #2e7d52; }
.tl-dot--desadjudicado, .tl-dot--obra_editada { background: #bf453c; }
.tl-dot--estado { background: #3672a0; }
.tl-dot--fatura, .tl-dot--recibo { background: #997400; }

/* -- Células de duas linhas (info principal + secundária) -- */
.cel-2l { display: flex; flex-direction: column; line-height: 1.25; text-decoration: none; }
a.cel-2l:hover .cel-1 { text-decoration: underline; }
.cel-2l .cel-1 { font-weight: 600; color: var(--ink); }
.cel-2l .cel-2 { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.tabela--lista2l td { vertical-align: middle; }

/* -- Matriz de permissões de acesso -- */
.tabela--permissoes th.centro, .tabela--permissoes td.centro { text-align: center; }
.tabela--permissoes thead tr:first-child th { border-bottom: none; }
.tabela--permissoes .subcabecalho th { font-weight: 500; font-size: 12px; color: var(--ink-soft); padding-top: 0; }
.tabela--permissoes tbody td { border-left: 1px solid var(--line); }
.tabela--permissoes tbody td:first-child { border-left: none; }
.tabela--permissoes input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; }

/* ===== Polish de estilo (mockups) ===== */
/* Rótulo dourado por cima do título da página */
.eyebrow { text-transform: uppercase; letter-spacing: 0.09em; font-size: 11.5px; font-weight: 700; color: var(--brand-deep); margin: 0 0 7px; }

/* Ponto colorido antes do estado (pill) */
.estado-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; flex: 0 0 auto; }

/* Linha de lista: avatar de iniciais + duas linhas */
.cel-ent { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.cel-ent .sigla { flex: 0 0 auto; }
.cel-ent:hover .cel-1 { text-decoration: underline; }

/* Localização com pin */
.cel-loc { display: inline-flex; align-items: center; gap: 5px; }
.cel-loc svg { color: var(--ink-faint); flex: 0 0 auto; margin-top: -1px; }

/* ===== Pills de filtro + barra de filtros ===== */
.barra-filtros { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill:hover { background: var(--surface-2); color: var(--ink); }
.pill--ativo { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.barra-pesquisa--fim { margin: 0; flex: 0 1 auto; }
@media (max-width: 720px) { .barra-pesquisa--fim { width: 100%; } }

/* ===== Pesquisa global (barra do topo) ===== */
.topo__pesquisa-wrap { position: relative; flex: 1 1 auto; max-width: 520px; }
.pesquisa-pop { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md, 12px); box-shadow: var(--sh-pop, 0 12px 32px rgba(0,0,0,.12)); padding: 6px; z-index: 50; max-height: 70vh; overflow: auto; }
.pesquisa-vazio { padding: 14px; color: var(--ink-soft); font-size: 14px; }
.pesquisa-grupo { padding: 4px 0; }
.pesquisa-grupo__tit { text-transform: uppercase; letter-spacing: 0.07em; font-size: 11px; font-weight: 700; color: var(--ink-faint); padding: 6px 10px 3px; }
.pesquisa-item { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; border-radius: 8px; text-decoration: none; }
.pesquisa-item:hover { background: var(--surface-2); }
.pesquisa-item__1 { font-weight: 600; color: var(--ink); font-size: 14px; }
.pesquisa-item__2 { font-size: 12px; color: var(--ink-soft); }

/* Totais não quebram linha */
.tabela .num, .nowrap { white-space: nowrap; }
/* Visto verde de adjudicado (só símbolo) */
.visto-adj { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--tone-verde-bg); color: var(--tone-verde-fg); }
/* Chevron de "abrir" no fim da linha */
.ir-detalhe { color: var(--ink-faint); display: inline-flex; vertical-align: middle; margin-left: 4px; }
.ir-detalhe:hover { color: var(--ink); }

/* "Aberto por" sob o 1º contacto da datebar */
.datebar-sub { margin-top: 4px; font-size: 12.5px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }

/* ===== Calendário mensal ===== */
.cal-nav { gap: 6px; }
.cal-grelha { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cab { text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); padding: 4px 0; }
.cal-cab--fds { color: var(--ink-faint); }
.cal-dia { min-height: 104px; border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: 6px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.cal-dia--vazio { background: transparent; border-color: transparent; }
.cal-dia--fds { background: var(--surface-2); }
.cal-dia--feriado { background: var(--tone-vermelho-bg, #F6D9D6); border-color: #E9C3BF; }
.cal-dia--hoje { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.cal-dia__topo { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.cal-dia__num { font-weight: 700; font-size: 13px; color: var(--ink); }
.cal-feriado { font-size: 10px; color: var(--tone-vermelho-fg, #BF453C); font-weight: 600; text-align: right; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 70%; }
.cal-marcacoes { display: flex; flex-direction: column; gap: 3px; }
.cal-marc { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--ink); text-decoration: none; padding: 2px 4px; border-radius: 5px; }
.cal-marc:hover { background: var(--surface-2); }
.cal-marc__dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cal-marc__txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-mais { font-size: 11px; color: var(--ink-soft); padding: 0 4px; }
@media (max-width: 720px) {
    .cal-dia { min-height: 72px; }
    .cal-marc__txt { display: none; }
    .cal-marc { justify-content: center; }
}

/* Cadeia de responsáveis (atual + anteriores desvanecidos) */
.resp-cadeia{display:inline-flex;align-items:center;gap:6px;flex-wrap:wrap}
.resp-cadeia--form{margin-top:8px}
.sigla--ant{background:var(--cor-fundo);color:var(--cor-suave);border-color:var(--cor-borda);opacity:.6;font-size:.72rem}
.resp-seta{opacity:.5}

/* Filtro de intervalo de datas (Obras/Projetos) */
.barra-datas{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-left:auto}
.barra-datas--full{margin-left:0;margin-bottom:14px}
.campo-data{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:600;color:var(--cor-suave);background:var(--cor-branco);border:1px solid var(--cor-borda);border-radius:999px;padding:5px 12px}
.campo-data input[type=date]{border:0;background:transparent;font:inherit;color:var(--cor-texto);padding:0;outline:none;min-width:104px}
.barra-datas .select-curto{border-radius:999px;padding:7px 14px;background:var(--cor-branco);font-size:13px;font-weight:600;color:var(--cor-suave)}
.barra-datas .btn{border-radius:999px}
.contador-resultados{margin:0 0 12px;font-size:13px;color:var(--cor-suave)}
.contador-resultados strong{color:var(--cor-texto);font-weight:700;font-size:14px}

/* Dia do calendário clicável (ver tudo desse dia) */
a.cal-dia__num--link{color:inherit;text-decoration:none;cursor:pointer}
a.cal-dia__num--link:hover{text-decoration:underline}
a.cal-mais{cursor:pointer;text-decoration:none}
a.cal-mais:hover{text-decoration:underline}

/* Grupo de campos com permissão: invisível no layout, mas desativa o conteúdo quando bloqueado */
.grupo-campo{display:contents;border:0;margin:0;padding:0;min-width:0}
fieldset.grupo-campo[disabled]{opacity:.75}

/* Volume adjudicado: barras mensais compactas (hover = comparação homóloga) */
.mbars { display: flex; gap: 4px; margin-top: 18px; align-items: flex-end; }
.mbar { flex: 1; text-align: center; cursor: default; }
.mbar-trilho { height: 60px; display: flex; align-items: flex-end; justify-content: center; }
.mbar-fill { display: block; width: 72%; min-height: 3px; background: var(--ink); border-radius: 4px 4px 0 0; transition: opacity .15s; }
.mbar:hover .mbar-fill { opacity: .7; }
.mbar-lbl { font-size: 9px; font-weight: 700; margin-top: 5px; color: rgba(26,26,23,.6); }
/* Workflow: barras por trimestre (com número por cima). */
.wf-tri { gap: 18px; margin-top: 22px; }
.wf-tri .mbar-trilho { height: 104px; }
.wf-tri .mbar-fill { width: 54%; }
.wf-tri .mbar-lbl { font-size: 12px; margin-top: 8px; color: var(--ink-soft); }
.wf-bar-num { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 5px; }

/* Performance: gráfico+conversão em cima, KPIs em grelha fluida por baixo */
.perf-top { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-bottom: 16px; align-items: start; }
.perf-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 760px) { .perf-top { grid-template-columns: 1fr; } }

.rev-data { font-size: 11px; color: var(--cor-suave); margin-left: 4px; }

/* Pesquisa dentro das Observações da ficha de obra */
.obs-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.obs-busca { display: inline-flex; align-items: center; gap: 7px; }
.obs-busca input[type=search] { padding: 5px 10px; border: 1px solid var(--cor-borda); border-radius: 999px; font-size: 12.5px; background: var(--cor-branco); min-width: 170px; }
.obs-busca__n { font-size: 11.5px; white-space: nowrap; }
.obs-texto { white-space: pre-wrap; margin: 0; color: var(--cor-texto); max-height: 360px; overflow: auto; font-size: 12.5px; line-height: 1.5; }
mark { background: #FFE082; color: inherit; padding: 0 1px; border-radius: 2px; }

/* Painel "Aplicar descontos" — layout limpo (Desc.1, Desc.2, converter) */
.aplicar-desc { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; padding: 12px 14px; background: var(--cor-fundo); border: 1px solid var(--cor-borda); border-radius: var(--raio); }
.aplicar-desc__linha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aplicar-desc__lbl { font-size: 13px; color: var(--cor-suave); min-width: 156px; }
.aplicar-desc__pct { width: 90px; }
.aplicar-desc__linha--fim { margin-top: 2px; padding-top: 9px; border-top: 1px solid var(--cor-borda); }

.tabela--editor { table-layout: fixed; }
.tabela--editor .in-tabela { min-width: 0; }

/* Ordenar o menu (Definições) */
.ordem-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ordem-menu__item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--cor-borda); border-radius: var(--raio); background: var(--cor-branco); }
.ordem-menu__pos { color: var(--cor-suave); width: 22px; }
.ordem-menu__lbl { flex: 1; font-weight: 600; }
.ordem-menu__acoes { display: flex; gap: 6px; }

/* ============================================================
   MÓVEL / TABLET (≤ 820px) — aspeto minimalista e listas em cartão
   ============================================================ */
@media (max-width: 820px) {
    /* Conteúdo e cabeçalhos mais compactos */
    .conteudo { padding: 16px 12px 64px; }
    .cabecalho-pagina h1 { font-size: 22px; }
    .obra-titulo-nome { font-size: 22px; }
    .cabecalho-pagina--acoes { flex-direction: column; align-items: stretch; gap: 10px; }
    .cabecalho-pagina--acoes .form__botoes { display: flex; flex-wrap: wrap; gap: 8px; }
    .cabecalho-pagina--acoes .form__botoes .btn { flex: 1 1 auto; justify-content: center; }
    .cartao { padding: 16px 14px; border-radius: 14px; }

    /* Grelhas empilham; KPIs 2 a 2 */
    .grelha-2, .dash-cols, .perf-grid, .perf-top { grid-template-columns: 1fr; }
    .dash-kpis, .kpi-grid, .kpi-grid--3 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .dash-kpi, .kpi { padding: 13px 13px; }
    .dash-kpi__val, .kpi__val { font-size: 22px; }

    /* Barras de filtros e ferramentas: embrulham e ocupam bem o espaço */
    .barra-filtros .pills { gap: 6px; }
    .barra-icones { flex-wrap: wrap; gap: 8px; }
    .barra-icones .filtro-ic { flex: 1 1 auto; }
    .ic-btn--texto { width: 100%; justify-content: center; }
    .pop { left: 0; right: 0; min-width: 0; }

    /* Alvos de toque maiores */
    .btn { min-height: 42px; }
    .pill { padding: 6px 12px; }

    /* ---- Listas em modo CARTÃO (tabela--cards) ---- */
    table.tabela--cards, .tabela--cards thead, .tabela--cards tbody,
    .tabela--cards tr, .tabela--cards td { display: block; width: auto; }
    .tabela--cards thead { display: none; }
    .tabela--cards tfoot { display: none; }
    .tabela--cards tr {
        border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px;
        padding: 10px 13px; background: var(--surface); box-shadow: var(--sh-card);
    }
    .tabela--cards td {
        border: 0 !important; padding: 5px 0; text-align: left;
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
    }
    .tabela--cards td::before {
        content: attr(data-label); flex: 0 0 auto;
        font-size: 11.5px; font-weight: 700; color: var(--ink-soft);
        text-transform: uppercase; letter-spacing: .03em;
    }
    /* Célula "principal" (nome+nº) a toda a largura, sem rótulo */
    .tabela--cards td.cel-principal { display: block; }
    .tabela--cards td.cel-principal::before { content: none; }
    .tabela--cards td.num { justify-content: space-between; }
    .tabela--cards td.tabela__acoes { justify-content: flex-end; }
    .tabela--cards td.tabela__acoes::before { content: none; }
    .tabela--cards td.tabela__acoes:empty, .tabela--cards td:empty { display: none; }
    .tabela--cards .col-expandir { position: absolute; right: 12px; top: 10px; }
    .tabela--cards tr { position: relative; }
    /* O botão +/contador fica sobreposto ao canto superior direito; o título
       (nome da obra) reserva espaço à direita para não passar por baixo dele. */
    .tabela--orcamentos-obra.tabela--cards td.cel-principal { padding-right: 68px; }
    /* As "versões anteriores" ficam ligeiramente recuadas dentro do grupo */
    .tabela--cards .linha-anterior { margin-left: 14px; background: var(--surface-2); }

    /* Dropdown de marcas (filtro de produtos): ocupa a largura disponível em
       vez de um mínimo fixo que pode sair do ecrã em telemóveis estreitos. */
    .prod-marcas__pop { left: 0; right: 0; min-width: 0; }

    /* Observações: a busca passa para uma linha própria, a toda a largura */
    .obs-summary { align-items: flex-start; }
    .obs-summary .obs-busca { flex: 1 0 100%; margin-top: 4px; }
    .obs-summary .obs-busca input[type=search] { flex: 1 1 auto; width: 100%; min-width: 0; }

    /* Ficha "Dados" da obra: 2 campos por linha (rótulo em cima, valor em
       baixo). Preenche a largura e reduz a altura do cartão. Campos longos
       (Local, Responsável, Notas…) ocupam a linha inteira. */
    .dados-obra { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
    .dados-obra .campo-dado { display: block; min-width: 0; }
    .dados-obra .campo-dado--wide { grid-column: 1 / -1; }
    .dados-obra dt { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 3px; }
    .dados-obra dd { font-size: 15px; }

    /* Editor de linhas em telemóvel: a busca inline não ultrapassa o ecrã
       (a barra "+ Adicionar / + Linha livre" já fica no início da linha). */
    .add-busca { max-width: min(460px, 82vw); }
    .add-busca__res { max-height: 220px; }
}

/* ── Reparações ──────────────────────────────────────────────────────────── */
.obrigatorio { color: var(--tone-vermelho-fg); font-weight: 700; }
.aviso-inline { background: var(--brand-soft); border: 1px solid #F0DEB0; color: #8A6D1A;
    border-radius: var(--r-sm); padding: 10px 13px; font-size: 13px; }
/* Segmentos (escolha única em pílulas) */
.seg-tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 999px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg-tab { padding: 7px 15px; border-radius: 999px; font-size: 13px; font-weight: 650;
    color: var(--ink-soft); cursor: pointer; user-select: none; text-decoration: none; }
.seg-tab.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--sh-card); }
/* Caixa secundária (adicionar contacto) */
.addbox { border: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r-sm);
    padding: 12px 14px; }
/* Fotos da avaria: zona única que acumula ficheiros (até 4) + lista com descrição */
.reparo-add { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.reparo-lista { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.reparo-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 8px 10px; background: var(--surface-2); }
.reparo-item__nome { font-size: 12.5px; font-weight: 600; flex: 0 0 auto;
    max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reparo-item input[type=text] { flex: 1; min-width: 120px; font-size: 12.5px; padding: 6px 9px; }
.reparo-item__x { border: 0; background: none; color: var(--ink-faint); font-size: 20px;
    line-height: 1; cursor: pointer; padding: 0 4px; }
.reparo-item__x:hover { color: var(--tone-vermelho-fg); }
@media (max-width: 560px) { .reparo-item__nome { max-width: 110px; } }

/* ── Ficha da reparação ──────────────────────────────────────────────────── */
.idbox-rep { text-align:right; }
.rep-barcode { height:34px; width:170px; margin-left:auto; margin-top:6px;
    background-image:repeating-linear-gradient(90deg,var(--ink) 0 2px,transparent 2px 4px,var(--ink) 4px 5px,transparent 5px 9px,var(--ink) 9px 12px,transparent 12px 13px,var(--ink) 13px 14px,transparent 14px 18px);
    border-radius:2px; }
/* Linha do tempo do estado */
.rep-timeline { display:flex; gap:4px; }
.rep-tl-step { flex:1; text-align:center; position:relative; }
.rep-tl-step .dot { width:28px; height:28px; border-radius:50%; margin:0 auto 7px; display:grid; place-items:center;
    font-size:13px; font-weight:800; background:var(--surface-2); color:var(--ink-faint); border:1px solid var(--line); position:relative; z-index:2; }
.rep-tl-step.done .dot { background:var(--c); color:#fff; border-color:var(--c); }
.rep-tl-step.now .dot { background:var(--c); color:#fff; border-color:var(--c); box-shadow:0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent); }
.rep-tl-step .t { font-size:12px; font-weight:650; color:var(--ink-soft); display:block; }
.rep-tl-step.now .t { color:var(--ink); }
.rep-tl-step .d { font-size:11px; color:var(--ink-faint); }
.rep-tl-step::before { content:""; position:absolute; top:14px; left:-50%; width:100%; height:2px; background:var(--line); z-index:1; }
.rep-tl-step:first-child::before { display:none; }
.rep-tl-step.done::before, .rep-tl-step.now::before { background:var(--c); }
/* Fotos */
.rep-fotos-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:12px; }
.rep-foto-item { margin:0; }
.rep-foto-item img { width:100%; aspect-ratio:4/3; object-fit:cover; border-radius:var(--r-sm); border:1px solid var(--line); display:block; }
.rep-foto-item figcaption { font-size:12px; color:var(--ink-soft); margin-top:5px; }
/* Histórico */
.rep-hist { list-style:none; margin:0; padding:0; }
.rep-hist li { display:flex; gap:12px; padding:10px 0; border-top:1px solid var(--line-soft); }
.rep-hist li:first-child { border-top:0; }
.rep-hist__pt { width:9px; height:9px; border-radius:50%; margin-top:6px; flex:0 0 auto; }
@media (max-width:640px){ .rep-timeline{ overflow-x:auto; } .rep-tl-step{ min-width:80px; } }

/* Busca de produto INLINE numa linha do orçamento (dropdown sobre a tabela) */
.linha-prod-busca { position: relative; }
.linha-prod-res {
    position: absolute; top: calc(100% + 2px); left: 0; min-width: 320px; max-width: 520px;
    z-index: 40; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-sm); box-shadow: var(--sh-pop); max-height: 260px; overflow-y: auto;
}

/* Utilitário: coluna centrada (th + td). */
.col-center { text-align: center; }
