:root {
  --bg: #f6f7f9; --card: #ffffff; --text: #1b1f24; --muted: #5d6673; --line: #e3e6ea;
  --accent: #1f5fbf; --ok: #1a7f4b; --mod: #5c8f1d; --att: #b7791f; --hi: #c2541b; --bad: #b42318;
  --chip: #eef1f5;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --card: #1a1e24; --text: #e6e9ed; --muted: #9aa4b1; --line: #2a3038;
    --accent: #6ea8ff; --ok: #3fb97a; --mod: #9ccc4a; --att: #e0a63c; --hi: #ef8650; --bad: #f2665a;
    --chip: #232932;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
       background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { background: var(--card); border-bottom: 1px solid var(--line); }
header .wrap { display: flex; align-items: center; gap: 24px; height: 56px; }
header .logo { font-weight: 700; letter-spacing: .2px; color: var(--text); }
header nav a { color: var(--muted); margin-right: 18px; }
header nav a.on { color: var(--text); font-weight: 600; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi .lbl { color: var(--muted); font-size: 13px; }
.kpi .val { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; }
tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }
.tablewrap { overflow-x: auto; }
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 28px;
         border-radius: 6px; font-weight: 700; color: #fff; padding: 0 6px; }
.f-Baixo { background: var(--ok); } .f-Moderado { background: var(--mod); } .f-Atenção { background: var(--att); }
.f-Elevado { background: var(--hi); } .f-Alto { background: var(--bad); } .f-none { background: var(--muted); }
.chip { display: inline-block; background: var(--chip); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.flag { padding: 8px 12px; border-radius: 8px; margin: 6px 0; border-left: 4px solid; background: var(--chip); }
.flag.critico { border-color: var(--bad); } .flag.alerta { border-color: var(--att); } .flag.info { border-color: var(--accent); }
.up { color: var(--ok); } .down { color: var(--bad); }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
               padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--bad); }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px;
                          background: var(--bg); color: var(--text); width: 100%; }
label { font-size: 13px; color: var(--muted); display: block; margin-bottom: 3px; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.bar { height: 8px; background: var(--chip); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.banner { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid var(--line);
          border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.comp td:first-child { width: 230px; }
ul.det { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
pre { white-space: pre-wrap; font-size: 12px; }
svg.spark { vertical-align: middle; }
.two { display: grid; gap: 16px; grid-template-columns: 1fr; }
.two > * { min-width: 0; }   /* texto longo (URL) não alarga a coluna */
.biblioteca td { white-space: nowrap; vertical-align: top; }
.biblioteca td.doc { white-space: normal; overflow-wrap: anywhere; width: 100%; }
.biblioteca textarea { width: 100%; resize: vertical; }
@media (min-width: 900px) { .two { grid-template-columns: 3fr 2fr; } }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--chip); }
header .wrap { flex-wrap: wrap; }
.perfil-sel select { width: auto; min-width: 160px; font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.chip.on { color: var(--text); font-weight: 600; outline: 1px solid var(--line); }
details.inline > summary { cursor: pointer; list-style: none; display: inline; }
td.num { white-space: nowrap; }
.acts { display: flex; gap: 8px; flex-wrap: nowrap; }

tr.clica { cursor: pointer; }
tr.clica .seta { display: inline-block; color: var(--muted); transition: transform .15s; width: 10px; }
tr.clica.aberto .seta { transform: rotate(90deg); }
tr.exp > td { background: var(--bg); padding: 14px 16px; }
tr.exp:hover td { background: var(--bg); }
.fat-cols { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.fat-h { font-weight: 650; margin-bottom: 6px; }
.fat { margin-bottom: 8px; }
.fat .det { margin: 2px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }

/* fluxo financeiro */
.meses { display: grid; grid-template-columns: repeat(12, minmax(48px, 1fr)); gap: 6px; overflow-x: auto; }
.mes { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border-radius: 8px;
       color: var(--muted); position: relative; text-decoration: none !important; }
.mes:hover { background: var(--chip); }
.mes.on { background: var(--chip); color: var(--text); font-weight: 600; outline: 1px solid var(--line); }
.mes .barras { display: flex; align-items: flex-end; gap: 3px; height: 90px; width: 100%; justify-content: center; }
.mes .b { width: 14px; border-radius: 3px 3px 0 0; min-height: 1px; }
.b.prev, .leg.prev { background: color-mix(in srgb, var(--accent) 30%, transparent); outline: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.b.rec, .leg.rec { background: var(--accent); }
.mes.futuro .b.prev { background: transparent; outline-style: dashed; }
.leg { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: -1px; }
.falta-dot { position: absolute; top: 2px; right: 4px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700;
             border-radius: 999px; min-width: 17px; height: 17px; line-height: 17px; text-align: center; padding: 0 4px; }
.st { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; white-space: nowrap;
      background: var(--chip); color: var(--muted); border: 1px solid transparent; }
.st-recebido { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.st-diferente, .st-atrasado { color: var(--att); border-color: color-mix(in srgb, var(--att) 40%, transparent); }
.st-nao-recebido { color: #fff; background: var(--bad); }
.st-previsto { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.st-extra { color: var(--mod); border-color: color-mix(in srgb, var(--mod) 35%, transparent); }
td.ativo { max-width: 300px; }
td.ativo a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
td.mot, .flag { overflow-wrap: anywhere; }
.card.caixa { border-left: 4px solid var(--accent); }
.card.caixa .lbl { color: var(--muted); font-size: 13px; }
.card.caixa .val { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* flag só leitura "Documentos da gestora" (página do ativo) */
a.flag-docs { display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; text-decoration: none; }
a.flag-docs:hover { text-decoration: underline; }
a.flag-docs input[disabled] { pointer-events: none; }
#documentos, #form-docs { scroll-margin-top: 16px; }

/* garantias (página do ativo): em destaque, logo abaixo do score */
.gar-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card.gar { border-left: 4px solid var(--ok); }
.gar .lbl { color: var(--muted); font-size: 13px; }
.gar-lendo { margin-bottom: 12px; }
.gar-legal { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 10%, var(--card));
             margin-bottom: 12px; }
.gar-topo { display: flex; gap: 16px 28px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.gar-principal { font-size: 22px; font-weight: 700; line-height: 1.25; }
.gar-principal.f-forte { color: var(--ok); } .gar-principal.f-media { color: var(--accent); }
.gar-principal.f-fraca { color: var(--att); }
.gar-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.gar-chip { text-decoration: none; border: 1px solid transparent; }
.chip.gar-chip.f-forte { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip.gar-chip.f-media { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip.gar-chip.f-fraca { color: var(--att); border-color: color-mix(in srgb, var(--att) 40%, transparent); }
.gar-resumo { font-size: 15px; margin: 8px 0 10px; }
.gar-itens { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 10px; }
.gar-item { border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px;
            background: var(--bg); min-width: 0; scroll-margin-top: 16px; }
.gar-item.f-forte { border-left-color: var(--ok); } .gar-item.f-fraca { border-left-color: var(--att); }
.gar-item p { margin: 6px 0; }
.gar-tit { font-weight: 650; font-size: 16px; }
.gar-dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 8px 0; font-size: 14px; }
.gar-dl dt { color: var(--muted); } .gar-dl dd { margin: 0; overflow-wrap: anywhere; }
.gar-cit { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--muted); font-size: 13px;
           font-style: italic; overflow-wrap: anywhere; }
.gar-cit cite { display: block; font-style: normal; margin-top: 4px; }
.gar details summary { cursor: pointer; color: var(--accent); }
.gar-situ { margin-top: 14px; }
.gar-pe { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
#garantias { scroll-margin-top: 16px; }

/* login e conta */
.usuario-menu { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.usuario-menu a { color: var(--muted); }
.usuario-menu a.on { color: var(--text); font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; }
button.link:hover { color: var(--text); text-decoration: underline; }
.entrada { max-width: 400px; margin: 48px auto; }
.entrada h1 { margin-top: 0; }
.entrada label { display: block; margin-top: 12px; }
.entrada input { width: 100%; }
.entrada button { width: 100%; margin-top: 18px; }
.senha-nova { font-family: ui-monospace, monospace; font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.acessos { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.acessos ul { margin: 6px 0 10px; padding-left: 18px; }
.acessos li form { display: inline; margin-left: 8px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--chip); color: var(--muted); }

/* Entrar com Google */
.entrada a.btn.google { display: block; width: 100%; text-align: center; margin-top: 8px; font-weight: 600; box-sizing: border-box; }
.entrada .ou { display: flex; align-items: center; gap: 10px; margin: 16px 0 4px; color: var(--muted); font-size: 13px; }
.entrada .ou::before, .entrada .ou::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* pedidos de compartilhamento e transferência */
.badge-n { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; text-align: center; }
.pedido { margin-bottom: 12px; }
.pedido .o-que { font-weight: 600; }
.pedido form.aceite { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-top: 10px; }
.acessos .oferecer { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
