/* financiamento.autocavado.pt — portal do cliente (documentos de financiamento) */
:root {
    --bg: #0b1220;
    --surface: #ffffff;
    --surface-alt: #f4f6fb;
    --text: #101828;
    --muted: #667085;
    --border: #e4e7ec;
    --primary: #1570ef;
    --primary-d: #1257c4;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #f59e0b;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(16, 24, 40, .10);
    /* Scrollbar personalizado — nunca o nativo do SO */
    --scrollbar-track-bg: transparent;
    --scrollbar-thumb: rgba(16, 24, 40, 0.22);
    --scrollbar-thumb-hover: rgba(16, 24, 40, 0.42);
}
* { box-sizing: border-box; }

/* Scrollbar global (ver pilot/base.css): webkit p/ Chrome/Safari; Firefox via
   @supports; rede de segurança que força auto no Chrome (nunca o nativo do SO). */
::-webkit-scrollbar             { width: 8px; height: 8px; }
::-webkit-scrollbar-button      { display: none; height: 0; width: 0; }
::-webkit-scrollbar-track       { background: var(--scrollbar-track-bg, transparent); }
::-webkit-scrollbar-thumb       { background: var(--scrollbar-thumb, rgba(16, 24, 40, 0.22)); border-radius: 0; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover, rgba(16, 24, 40, 0.42)); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb, rgba(16, 24, 40, 0.22)) transparent; }
}
@supports selector(::-webkit-scrollbar) {
  * { scrollbar-width: auto !important; scrollbar-color: auto !important; }
}
body.fin-portal {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(180deg, #0b1220 0%, #0b1220 220px, #eef1f7 220px, #eef1f7 100%);
    color: var(--text);
    min-height: 100vh;
}

/* Estados de erro / sucesso */
.fin-state { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.fin-state-card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 40px 32px; max-width: 440px; text-align: center;
}
.fin-state-icon { font-size: 44px; margin-bottom: 8px; }
.fin-state h1 { font-size: 1.4rem; margin: 6px 0 10px; }
.fin-state p { color: var(--muted); margin: 6px 0; }
.fin-state-sub { font-size: .85rem; color: var(--muted); }

/* Layout */
/* Hero (estilo do portal de eventos) */
.fin-hero { color: #fff; padding: 48px 20px 40px; text-align: center; }
.fin-hero-inner { max-width: 820px; margin: 0 auto; }
.fin-hero-brand { font-weight: 800; letter-spacing: .4px; text-transform: uppercase; font-size: .9rem; opacity: .85; margin-bottom: 14px; }
.fin-hero-title { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 800; margin: 0 0 16px; line-height: 1.1; }
.fin-hero-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center; font-size: .9rem; opacity: .92; }
.fin-hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.fin-main { max-width: 880px; margin: 0 auto; padding: 0 24px 64px; }
/* A folga do rodapé fixo de contacto vive DENTRO do rodapé minimal: no body
   ficava uma faixa branca por baixo do preto. */
#minimal-footer { --mf-safe-bottom: 76px; }

/* Rodapé fixo de contacto (igual ao portal de propostas) */
.fin-sticky-footer {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 90;
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    padding: 10px 16px; background: rgba(255,255,255,.97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border);
}
.fin-fab {
    display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 999px;
    padding: 10px 16px; font: inherit; font-weight: 600; font-size: .86rem; cursor: pointer;
    text-decoration: none; box-shadow: 0 2px 8px rgba(16,24,40,.12); transition: transform .15s, filter .15s;
}
.fin-fab:hover { transform: translateY(-2px); filter: brightness(1.04); }
.fin-fab .ph-icon { font-size: 1.2rem; }
.fin-fab-call  { background: #eef2ff; color: var(--primary); }

.fin-card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 28px; margin-bottom: 18px;
}
.fin-card h1 { font-size: 1.35rem; margin: 0 0 8px; }
.fin-card p { color: var(--muted); line-height: 1.5; margin: 6px 0; }

/* Gate de PIN */
.fin-pin-gate { text-align: center; max-width: 460px; margin: 0 auto; }
.fin-pin-input {
    font-size: 1.8rem; letter-spacing: 12px; text-align: center;
    width: 220px; padding: 12px; margin: 14px auto 6px; display: block;
    border: 2px solid var(--border); border-radius: 10px; font-weight: 700;
}
.fin-pin-input:focus { outline: none; border-color: var(--primary); }
.fin-pin-error { color: var(--red); font-size: .85rem; margin: 8px 0; }

/* Botões */
.fin-btn {
    border: none; border-radius: 10px; padding: 12px 22px; font: inherit; font-weight: 600;
    cursor: pointer; transition: background .15s, opacity .15s;
}
.fin-btn-primary { background: var(--primary); color: #fff; }
.fin-btn-primary:hover { background: var(--primary-d); }
.fin-btn-primary:disabled { opacity: .55; cursor: default; }
.fin-btn-ghost { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }

/* Grupos de documentos */
.fin-group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px; }
.fin-group-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.fin-group-title { font-size: 1.05rem; font-weight: 700; }
.fin-group-role { font-size: .72rem; color: var(--muted); background: var(--surface-alt); padding: 2px 8px; border-radius: 999px; }
.fin-group-sub { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }

.fin-doc-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.fin-doc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.fin-doc-label { font-weight: 600; font-size: .9rem; }
.fin-doc-req { color: var(--red); font-size: .72rem; margin-left: 6px; }
.fin-doc-opt { color: var(--muted); font-size: .72rem; margin-left: 6px; }
.fin-doc-state { font-size: .74rem; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.fin-doc-state.is-empty { background: var(--surface-alt); color: var(--muted); }
.fin-doc-state.is-ok    { background: rgba(22,163,74,.12); color: var(--green); }

.fin-uploaded { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fin-uploaded li { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text); }
.fin-uploaded li .fin-rev { font-size: .7rem; color: var(--muted); margin-left: auto; }
.fin-uploaded li .fin-rev.valid { color: var(--green); }
.fin-uploaded li .fin-rev.invalid { color: var(--red); }
.fin-uploaded li .fin-rev-note { flex-basis: 100%; font-size: .72rem; color: var(--red); margin-left: 22px; }

.fin-drop {
    margin-top: 10px; border: 1.5px dashed var(--border); border-radius: 10px;
    padding: 14px; text-align: center; color: var(--muted); font-size: .85rem; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.fin-drop:hover, .fin-drop.is-over { border-color: var(--primary); background: rgba(21,112,239,.04); }
.fin-drop input { display: none; }
.fin-doc-uploading { font-size: .78rem; color: var(--primary); margin-top: 6px; }
.fin-doc-error { font-size: .78rem; color: var(--red); margin-top: 6px; }

/* Adicionar sócio */
.fin-add-subject { display: flex; gap: 8px; margin-bottom: 16px; }
.fin-add-subject input { flex: 1; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; }

/* Barra de submissão */
.fin-submit-bar {
    position: sticky; bottom: 0; background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 22px; display: flex; align-items: center;
    justify-content: space-between; gap: 14px; margin-top: 6px;
}
.fin-submit-hint { font-size: .82rem; color: var(--muted); }
.fin-done { text-align: center; max-width: 460px; margin: 40px auto; }

/* Documentos da Autocávado (anexados pelo CRM — ex.: simulação da financeira) */
.fin-staff-docs { border-left: 3px solid var(--primary); }
.fin-staff-link, .fin-file-link {
    background: none; border: none; padding: 0; font: inherit; cursor: pointer; text-align: left;
    color: var(--primary); font-weight: 600;
}
.fin-staff-link:hover, .fin-file-link:hover { text-decoration: underline; }
.fin-file-link { color: var(--text); font-weight: 500; }

/* Painel lateral (drawer) — pré-visualização de documentos */
body.fin-no-scroll { overflow: hidden; }
.fin-drawer-overlay {
    position: fixed; inset: 0; z-index: 1000; background: rgba(16, 24, 40, .45);
    opacity: 0; transition: opacity .2s ease; display: flex; justify-content: flex-end;
}
.fin-drawer-overlay[hidden] { display: none; } /* o atributo hidden tem de vencer o display:flex */
.fin-drawer-overlay.is-open { opacity: 1; }
.fin-drawer {
    width: min(720px, 92vw); height: 100%; background: var(--surface);
    display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(16, 24, 40, .25);
    transform: translateX(100%); transition: transform .22s ease;
}
.fin-drawer-overlay.is-open .fin-drawer { transform: translateX(0); }
.fin-drawer-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.fin-drawer-title { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-drawer-actions { display: flex; align-items: center; gap: 6px; }
.fin-drawer-open, .fin-drawer-close {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface-alt); color: var(--text); font-size: 1rem; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none;
}
.fin-drawer-open:hover, .fin-drawer-close:hover { background: #e9edf5; }
.fin-drawer-body { flex: 1 1 auto; overflow: auto; background: var(--surface-alt); }
.fin-drawer-frame { width: 100%; height: 100%; border: 0; background: #fff; }
.fin-drawer-imgwrap { padding: 16px; display: flex; justify-content: center; }
.fin-drawer-img { max-width: 100%; height: auto; border-radius: 8px; box-shadow: var(--shadow); }
.fin-drawer-fallback { padding: 48px 24px; text-align: center; color: var(--muted); }
.fin-drawer-fallback-icon { font-size: 42px; margin-bottom: 10px; }
.fin-drawer-fallback p { margin: 0 0 16px; }
.fin-drawer-fallback .fin-btn { display: inline-block; text-decoration: none; }

/* Dados próprios de cada pessoa (proponente/cônjuge/sócio) */
.fin-subject-data { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.fin-subject-data-head { font-size: .82rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.fin-subject-remove {
    margin-left: 8px; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface-alt); color: var(--red); cursor: pointer; line-height: 1; flex: 0 0 auto;
}
.fin-subject-remove:hover { background: rgba(220, 38, 38, .1); }

/* Texto introdutório por tipo de requerente */
.fin-type-intro { border-left: 3px solid var(--primary); }
.fin-type-intro .fin-group-sub { margin-bottom: 0; }

/* Progresso (enviados / validados) — anéis visíveis ao cliente */
.fin-rings { display: flex; gap: 28px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.fin-ring { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.fin-ring-circle { position: relative; width: 96px; height: 96px; }
.fin-ring-svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.fin-ring-track { fill: none; stroke: var(--surface-alt); stroke-width: 9; }
.fin-ring-fill { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset .7s ease; }
.fin-ring-fill.is-blue { stroke: var(--primary); }
.fin-ring-fill.is-green { stroke: var(--green); }
.fin-ring-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; color: var(--text); }
.fin-ring-label { font-size: .82rem; font-weight: 600; color: var(--text); }
.fin-ring-count { font-size: .74rem; color: var(--muted); }

/* Informações adicionais */
.fin-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.fin-info-fld { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.fin-info-fld input, .fin-info-fld select {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
.fin-info-fld input:focus, .fin-info-fld select:focus { outline: none; border-color: var(--primary); }
.fin-info-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.fin-info-ok { color: var(--green); font-weight: 700; font-size: .85rem; }

@media (max-width: 560px) {
    .fin-main { padding: 0 14px 48px; }
    .fin-card, .fin-group { padding: 20px 16px; }
    .fin-info-grid { grid-template-columns: 1fr; }
}
