/* Caixas de seleção — sistemas a intervencionar (tipo "Prédio") */
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; margin-top: 6px; }
.chk-grid .chk { display: flex; align-items: center; justify-content: flex-start; gap: 10px; font-size: 14px; font-weight: 400; cursor: pointer; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); transition: border-color .15s var(--ease), background .15s var(--ease); }
.chk-grid .chk:hover { border-color: var(--border-strong); }
.chk-grid .chk:has(input:checked) { border-color: var(--accent); background: var(--accent-pale); }
.chk-grid .chk input[type="checkbox"] { -webkit-appearance: auto; appearance: auto; width: 17px; min-width: 17px; height: 17px; flex: 0 0 auto; margin: 0; padding: 0; accent-color: var(--accent); cursor: pointer; box-shadow: none; }
.chk-grid .chk span { flex: 1 1 auto; text-align: left; white-space: normal; line-height: 1.25; color: var(--ink); user-select: none; }

/* Parecer do consultor — cartão destacado */
.parecer-card { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r); background: var(--surface); padding: 16px 20px 18px; box-shadow: var(--shadow-card); }
.parecer-card.has-text { background: var(--surface-2); }
.parecer-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.parecer-badge { display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.parecer-badge .ic { width: 16px; height: 16px; }
.parecer-meta { font-size: 12.5px; color: var(--muted); flex: 1 1 auto; }
.parecer-text { font-size: 14.5px; line-height: 1.72; color: var(--ink); margin: 0; }
.parecer-empty { font-size: 13.5px; color: var(--muted); margin: 0; }
.parecer-foot { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: 11.5px; color: var(--faint); line-height: 1.45; }
.parecer-foot .ic { width: 14px; height: 14px; flex: none; margin-top: 1px; opacity: .65; }

/* =============================================================================
 *  Business Plan - Dashboard by Opção Sensata
 *  styles.css — Sistema de design (minimalismo utilitário, editorial)
 * ========================================================================== */

:root {
  /* Canvas e superfícies */
  --canvas: #FBFBFA;
  --surface: #FFFFFF;
  --surface-2: #F7F6F3;
  --border: #EAEAEA;
  --border-strong: #DEDDD9;

  /* Texto */
  --ink: #1A1A19;
  --ink-soft: #3A3A38;
  --muted: #5E5D59;
  --faint: #767570;

  /* Acento (verde sóbrio, dessaturado) */
  --accent: #2E5E4E;
  --accent-ink: #224A3D;
  --accent-pale: #EAF1EE;

  /* Semânticos (pastéis lavados) */
  --pos: #346538;  --pos-bg: #EDF3EC;
  --neg: #9F2F2D;  --neg-bg: #FDEBEC;
  --info: #1F6C9F; --info-bg: #E1F3FE;
  --warn: #956400; --warn-bg: #FBF3DB;

  /* Tipografia */
  --sans: "Geist", "SF Pro Display", "Helvetica Neue", system-ui, sans-serif;
  --mono: "Geist Mono", "SF Mono", "JetBrains Mono", ui-monospace, monospace;

  /* Geometria */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --pad: 28px;
  --shadow-card: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-lift: 0 2px 10px rgba(0,0,0,0.05);
  --shadow-modal: 0 24px 60px -20px rgba(0,0,0,0.28);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Tema escuro (editorial, dessaturado) ------------------------- */
[data-theme="dark"] {
  --canvas: #151614;
  --surface: #1C1E1B;
  --surface-2: #24251E;
  --border: #2D2F2A;
  --border-strong: #3B3D37;

  --ink: #ECEBE6;
  --ink-soft: #C6C5BF;
  --muted: #A6A49B;
  --faint: #87857D;

  --accent: #6CC1A1;
  --accent-ink: #59B392;
  --accent-pale: #21392F;

  --pos: #6FC089;  --pos-bg: #18301E;
  --neg: #E08583;  --neg-bg: #371E1E;
  --info: #6FB6E2; --info-bg: #15303F;
  --warn: #D8AC4E; --warn-bg: #322706;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-lift: 0 2px 10px rgba(0,0,0,0.5);
  --shadow-modal: 0 24px 60px -20px rgba(0,0,0,0.7);
}
[data-theme="dark"] .card { box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px -8px rgba(0,0,0,0.55); }
/* Botões: neutralizar os valores fixos (#fff / #333) do tema claro */
[data-theme="dark"] .btn { background: var(--ink); border-color: var(--ink); color: var(--canvas); box-shadow: none; }
[data-theme="dark"] .btn:hover { background: #fff; border-color: #fff; }
[data-theme="dark"] .btn.ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
[data-theme="dark"] .btn.ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
[data-theme="dark"] .btn.accent { background: var(--accent); border-color: var(--accent); color: #0F211A; box-shadow: 0 1px 2px rgba(0,0,0,0.4); }
[data-theme="dark"] .btn.accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
[data-theme="dark"] .btn.danger { background: transparent; color: var(--neg); border-color: var(--neg-bg); }
[data-theme="dark"] .btn.danger:hover { background: var(--neg-bg); }
[data-theme="dark"] .seg button.active { color: #0F211A; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-pale); }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.018em; line-height: 1.2; color: var(--ink); }
a { color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 16px; color: var(--ink); }

.num { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: -0.01em; }
.mono { font-family: var(--mono); }
.ic { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; flex: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- Botões -------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  padding: 9px 16px; min-height: 40px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 500; letter-spacing: 0.01em;
  transition: background .18s var(--ease), transform .1s var(--ease), border-color .18s;
  white-space: nowrap;
}
.btn:hover { background: #333; border-color: #333; }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn.accent { background: var(--accent); border-color: var(--accent); box-shadow: 0 1px 2px rgba(34,74,61,0.25), 0 6px 16px -8px rgba(34,74,61,0.45); }
.btn.accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--neg); border-color: var(--neg-bg); }
.btn.danger:hover { background: var(--neg-bg); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 16px; height: 16px; }

/* ---------- Formulários --------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 500; color: var(--ink-soft); letter-spacing: 0.005em; }
.field .hint { font-size: 12.5px; color: var(--faint); line-height: 1.4; }
.field input, .field select, .field textarea {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r); padding: 11px 13px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-pale);
}
.field.with-suffix { position: relative; }
.field.with-suffix .suffix {
  position: absolute; right: 11px; bottom: 9px; font-size: 12px;
  color: var(--faint); font-family: var(--mono); pointer-events: none;
}
/* Sufixo ancorado à própria caixa (input), não ao fundo do campo — evita que
   m²/€/dias caia por baixo quando o campo estica ou tem dica. */
.field .ctrl { position: relative; }
.field.with-suffix .ctrl .suffix { top: 50%; bottom: auto; transform: translateY(-50%); }
.field.err input, .field.err select { border-color: var(--neg); }
.field .err-msg { font-size: 12.5px; color: var(--neg); }
input.num, .field input[type="number"] { font-family: var(--mono); }

/* ========================================================================== *
 *  LOGIN
 * ========================================================================== */
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(60vw 60vw at 85% -10%, rgba(46,94,78,0.04), transparent 60%),
    radial-gradient(50vw 50vw at -10% 110%, rgba(46,94,78,0.03), transparent 60%),
    var(--canvas);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 36px 32px; box-shadow: var(--shadow-card);
}
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-mark .glyph {
  width: 30px; height: 30px; border-radius: 7px; background: var(--ink);
  display: grid; place-items: center; flex: none; color: #FBFBFA;
}
.brand-mark .glyph svg { width: 17px; height: 17px; vertical-align: 0; }
/* Logótipo Casa Analítica.com Consulting — duas versões (clara/escura) conforme o tema */
.brand-mark .logo-icon { height: 40px; width: auto; border-radius: 8px; object-fit: contain; flex: none; display: block; }
.auth-card .brand-mark .logo-icon { height: 72px; }
.topbar .brand-mark .logo-icon { height: 34px; }
.brand-mark .logo-dark { display: none; }
[data-theme="dark"] .brand-mark .logo-light { display: none; }
[data-theme="dark"] .brand-mark .logo-dark { display: block; }
.auth-card h1 { font-size: 21px; margin-top: 26px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-form .btn { width: 100%; margin-top: 4px; padding: 11px; }
.auth-note {
  margin-top: 18px; font-size: 11.5px; color: var(--faint); line-height: 1.5;
  border-top: 1px solid var(--border); padding-top: 16px;
}
.auth-error {
  background: var(--neg-bg); color: var(--neg); font-size: 12.5px;
  padding: 9px 12px; border-radius: var(--r-sm);
}

/* ========================================================================== *
 *  ESTRUTURA DA APLICAÇÃO
 * ========================================================================== */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }

.sidebar {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; padding: 20px 16px;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar .brand-mark { padding: 4px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint); font-weight: 600; padding: 16px 10px 6px;
}
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border-radius: var(--r-sm); font-size: 13.5px; color: var(--ink-soft);
  font-weight: 500; transition: background .14s, color .14s;
  text-decoration: none;
}
.nav a .ic { width: 17px; height: 17px; color: var(--muted); flex: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-pale); color: var(--accent-ink); }
.nav a.active .ic { color: var(--accent); }
.sidebar .spacer { flex: 1; }
.user-chip {
  border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 8px; background: var(--accent-pale);
  color: var(--accent-ink); display: grid; place-items: center;
  font-size: 13px; font-weight: 600; flex: none; font-family: var(--mono);
}
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .meta .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta .rl { font-size: 11px; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-sm);
  width: 40px; height: 40px; display: grid; place-items: center; color: var(--muted);
  transition: background .14s, color .14s; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .ic { width: 16px; height: 16px; }

/* Conteúdo principal */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 30;
}
.view { padding: 36px 40px 64px; max-width: 1180px; width: 100%; margin: 0 auto; }
.view-head { margin-bottom: 28px; }
.view-head .eyebrow {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent); font-weight: 600;
}
.view-head h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.028em; margin-top: 9px; }
.view-head p { color: var(--muted); margin-top: 8px; max-width: 60ch; font-size: 14px; }
.view-head .row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* ---------- Cartões / Bento ---------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--pad);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), 0 4px 16px -8px rgba(0,0,0,0.06);
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.card .card-title { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.card .card-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--faint); font-weight: 600; margin: 30px 0 14px;
  display: flex; align-items: center; gap: 10px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- KPI ----------------------------------------------------------- */
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 600;
}
.kpi .value { font-family: var(--mono); font-size: 30px; font-weight: 500; letter-spacing: -0.025em; }
.kpi .value.sm { font-size: 23px; }
.kpi .delta { font-size: 12px; font-family: var(--mono); display: inline-flex; gap: 5px; align-items: center; }
.kpi .delta.up { color: var(--pos); }
.kpi .delta.down { color: var(--neg); }

/* ---------- Badges -------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600; padding: 3px 9px; border-radius: 9999px;
  background: var(--surface-2); color: var(--muted);
}
.badge.pos { background: var(--pos-bg); color: var(--pos); }
.badge.neg { background: var(--neg-bg); color: var(--neg); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.accent { background: var(--accent-pale); color: var(--accent-ink); }

/* ---------- Tabelas ------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--faint); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl td.r { font-family: var(--mono); }
.tbl tr.subtotal td { font-weight: 600; background: var(--surface-2); }
.tbl tr.grand td { font-weight: 700; border-top: 2px solid var(--ink); font-size: 14.5px; }
.tbl tr.section-row td {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--accent); font-weight: 600; background: transparent; padding-top: 18px;
}
.tbl .pct { color: var(--faint); font-size: 11.5px; }

/* ---------- Relatório ----------------------------------------------------- */
.report-layout { display: grid; grid-template-columns: 340px 1fr; gap: 24px; align-items: start; }
.report-inputs .card { padding: 22px; }
.report-inputs .card-sub { margin-bottom: 6px; }
.report-inputs .section-title { margin: 22px 0 12px; }
.report-inputs .section-title:first-of-type { margin-top: 16px; }
.report-output { min-width: 0; }
@media (max-width: 1024px) { .report-layout { grid-template-columns: 1fr; } }

/* ---------- Editor de preços por cidade / freguesia ---------------------- */
.city-block { border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; background: var(--surface); overflow: hidden; }
.city-block > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: flex; align-items: center; gap: 12px; transition: background .14s; }
.city-block > summary::-webkit-details-marker { display: none; }
.city-block > summary::after { content: "+"; margin-left: 6px; color: var(--muted); font-family: var(--mono); font-size: 17px; line-height: 1; }
.city-block[open] > summary::after { content: "\2013"; }
.city-block > summary:hover { background: var(--surface-2); }
.city-block .ci-name { font-size: 14.5px; font-weight: 600; }
.city-block .ci-count { font-size: 12px; color: var(--muted); font-weight: 500; font-family: var(--mono); margin-left: auto; }
.ci-body { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.ci-city { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; padding: 16px 0; }
.ci-city .field { width: 150px; }
.ci-city .ci-ro { font-size: 12px; padding-bottom: 9px; }
.ci-body .tbl td:first-child { color: var(--ink-soft); }
.ci-body .tbl input { font-family: var(--mono); color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 7px 9px; text-align: right; transition: border-color .15s var(--ease); }
.ci-body .tbl input::placeholder { color: var(--faint); }
.ci-body .tbl input:focus { outline: none; border-color: var(--accent); }

/* ---------- Seletor de tipo (segmented control) -------------------------- */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: var(--surface); border: none; border-right: 1px solid var(--border); padding: 10px 20px; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .14s, color .14s; }
.seg button:last-child { border-right: none; }
.seg button:not(.active):hover { background: var(--surface-2); color: var(--ink); }
.seg button.active { background: var(--accent); color: #fff; }
.seg.sm button { padding: 7px 14px; font-size: 12.5px; }

.report-hero {
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 0;
  border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.report-hero .verdict { padding: 32px; border-right: 1px solid var(--border); }
.report-hero .verdict .big {
  font-family: var(--mono); font-size: 44px; font-weight: 500; letter-spacing: -0.03em; margin-top: 6px;
}
.report-hero .side { padding: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.bar { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- Arquivo ------------------------------------------------------- */
.archive-list { display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.archive-item {
  display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  transition: background .14s;
}
.archive-item:last-child { border-bottom: none; }
.archive-item:hover { background: var(--surface-2); }
.archive-item .ti { font-weight: 600; font-size: 14.5px; }
.archive-item .me { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 14px; flex-wrap: wrap; }
.archive-item .me .num { color: var(--ink-soft); }
.archive-actions { display: flex; gap: 7px; }

/* ---------- Estados vazios ------------------------------------------------ */
.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
  padding: 48px 32px; text-align: center; color: var(--muted);
}
.empty .ic { width: 30px; height: 30px; color: var(--faint); margin: 0 auto 14px; }
.empty h3 { font-size: 15px; color: var(--ink); }
.empty p { font-size: 13px; margin-top: 6px; max-width: 42ch; margin-inline: auto; }
.empty .btn { margin-top: 18px; }

/* ---------- Modal --------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(20,20,19,0.4);
  display: grid; place-items: center; padding: 24px; z-index: 100;
  animation: fade .18s var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: 100%; max-width: 460px; box-shadow: var(--shadow-modal);
  animation: pop .22s var(--ease);
}
.modal.wide { max-width: 720px; }
.modal-head { padding: 22px 24px 0; }
.modal-head h2 { font-size: 18px; }
.modal-head p { color: var(--muted); font-size: 13px; margin-top: 6px; }
.modal-body { padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; max-height: 64vh; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }

/* ---------- Toast --------------------------------------------------------- */
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--r-sm);
  font-size: 13px; box-shadow: var(--shadow-modal); display: flex; gap: 10px; align-items: center;
  animation: slideIn .26s var(--ease); max-width: 340px;
}
.toast.ok { background: var(--accent-ink); }
.toast.err { background: var(--neg); }
.toast .ic { width: 16px; height: 16px; flex: none; }
@keyframes slideIn { from { opacity: 0; transform: translateX(16px); } }

/* ---------- Entradas animadas -------------------------------------------- */
.reveal { opacity: 0; transform: translateY(12px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease); }

/* ---------- Tabs ---------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tabs button {
  background: none; border: none; padding: 10px 14px; font-size: 13.5px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .14s, border-color .14s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--accent-ink); border-bottom-color: var(--accent); }

/* Pequenos utilitários de layout */
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.fieldset { display: grid; gap: 16px; }
.fieldset.two { grid-template-columns: 1fr 1fr; }
.fieldset.three { grid-template-columns: 1fr 1fr 1fr; }
.subnote { font-size: 12px; color: var(--muted); line-height: 1.5; }
.parecer-text { font-size: 14.5px; line-height: 1.72; color: var(--ink-soft); white-space: normal; }

/* ---------- REFERÊNCIA — instantâneo de mercado (bento) ------------------- */
.ref-snap { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); padding: 18px; box-shadow: var(--shadow-card); }
.ref-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.ref-loc { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ref-pin { width: 34px; height: 34px; border-radius: 9px; background: var(--accent-pale); color: var(--accent); display: grid; place-items: center; flex: none; }
.ref-pin .ic { width: 18px; height: 18px; }
.ref-loc-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.ref-loc-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ref-growth { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 9999px; background: var(--pos-bg); color: var(--pos); white-space: nowrap; }
.ref-growth.down { background: var(--neg-bg); color: var(--neg); }
.ref-growth span { font-size: 11px; opacity: .75; font-weight: 500; }
.ref-growth .ic { width: 15px; height: 15px; }
.ref-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ref-tile { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; transition: transform .18s var(--ease), border-color .18s var(--ease); }
.ref-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.ref-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--accent); margin-bottom: 12px; }
.ref-ic .ic { width: 18px; height: 18px; }
.ref-num { font-family: var(--mono); font-size: 22px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; color: var(--ink); }
.ref-unit { font-family: var(--sans); font-size: 12px; color: var(--faint); font-weight: 400; margin-left: 2px; }
.ref-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-top: 7px; }
.ref-compare { margin-top: 14px; padding: 15px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.rc-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.rc-lbl { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.rc-delta { font-size: 11px; font-weight: 600; color: var(--info); background: var(--info-bg); padding: 3px 9px; border-radius: 9999px; white-space: nowrap; }
.rc-bar { position: relative; height: 8px; border-radius: 5px; background: var(--border); }
.rc-fill { position: absolute; left: 0; top: 0; height: 100%; border-radius: 5px; background: var(--accent); }
.rc-mark { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--ink); border-radius: 2px; transform: translateX(-1px); }
.rc-legend { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; gap: 10px; }
.rc-legend .num { font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.rc-mkt { font-size: 11.5px; color: var(--muted); }
@media (max-width: 560px) { .ref-tiles { grid-template-columns: 1fr; } }

/* ---------- Tooltips (siglas técnicas: TRIU, Alvará, ABC) ----------------- */
.tip { position: relative; display: inline-flex; vertical-align: middle; margin-left: 5px; }
.tip-q {
  width: 15px; height: 15px; border-radius: 50%; border: 1px solid var(--border-strong);
  color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1; cursor: help;
  display: grid; place-items: center; user-select: none;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}
.tip:hover .tip-q, .tip:focus-visible .tip-q { color: var(--accent); border-color: var(--accent); background: var(--accent-pale); }
.tip:focus-visible { outline: none; }
.tip-pop {
  position: absolute; bottom: calc(100% + 9px); left: 50%; z-index: 60;
  transform: translateX(-50%) translateY(4px) scale(0.97); transform-origin: bottom center;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.45;
  letter-spacing: 0.005em; text-align: left; padding: 9px 12px; border-radius: var(--r-sm);
  width: max-content; max-width: 230px; box-shadow: var(--shadow-modal);
  opacity: 0; pointer-events: none;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.tip-pop::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink); }
.tip:focus-visible .tip-pop { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
@media (hover: hover) and (pointer: fine) { .tip:hover .tip-pop { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .tip-pop { transition: opacity .16s ease; transform: translateX(-50%); } .tip:hover .tip-pop, .tip:focus-visible .tip-pop { transform: translateX(-50%); } }

/* ---------- Responsivo ---------------------------------------------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 50;
    transform: translateX(-100%); transition: transform .26s var(--ease);
    box-shadow: var(--shadow-modal);
  }
  .sidebar.open { transform: none; }
  .topbar { display: flex; }
  .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 45; }
  .view { padding: 24px 18px 56px; }
  .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .fieldset.two, .fieldset.three { grid-template-columns: 1fr; }
  .report-hero { grid-template-columns: 1fr; }
  .report-hero .verdict { border-right: none; border-bottom: 1px solid var(--border); }
  .view-head h1 { font-size: 23px; }
}
@media (min-width: 901px) and (max-width: 1180px) {
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Impressão (PDF do relatório) --------------------------------- */
/* Cabeçalho de marca do relatório — só visível na impressão/PDF */
.print-head { display: none; }

@page { size: A4; margin: 15mm 13mm 16mm; }
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  /* Imprimir sempre em tom claro, mesmo que o ecrã esteja em modo escuro */
  :root, [data-theme="dark"] {
    --canvas: #FFFFFF; --surface: #FFFFFF; --surface-2: #F7F6F3;
    --border: #EAEAEA; --border-strong: #DEDDD9;
    --ink: #1A1A19; --ink-soft: #3A3A38; --muted: #5E5D59; --faint: #767570;
    --accent: #2E5E4E; --accent-ink: #224A3D; --accent-pale: #EAF1EE;
    --pos: #346538; --pos-bg: #EDF3EC; --neg: #9F2F2D; --neg-bg: #FDEBEC; --warn: #956400; --warn-bg: #FBF3DB; --info: #1F6C9F; --info-bg: #E1F3FE;
  }
  .sidebar, .topbar, .no-print, .toasts, .nav, .topbar-mobile { display: none !important; }
  html, body { background: #fff !important; }
  .app { display: block; }
  .view, .view.reveal { max-width: none; padding: 0; opacity: 1 !important; transform: none !important; }
  #report-output, .reveal, .reveal.in { opacity: 1 !important; transform: none !important; }

  /* Cabeçalho de marca */
  .print-head { display: flex !important; align-items: center; gap: 16px; padding: 0 0 14px; margin-bottom: 18px;
    border-bottom: 2.5px solid #2E5E4E; }
  .print-head .ph-brand { display: flex; align-items: center; flex: none; }
  .print-head .ph-brand img { height: 46px; width: auto; border-radius: 9px; }
  .print-head .ph-doc { flex: 1 1 auto; padding: 0 4px; border-left: 1px solid #e3e3e0; padding-left: 16px; }
  .print-head .ph-eyebrow { font-size: 9.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #2E5E4E; }
  .print-head .ph-title { font-size: 17px; font-weight: 700; color: #14140f; letter-spacing: -.01em; margin-top: 2px; }
  .print-head .ph-sub { font-size: 11.5px; color: #57564f; margin-top: 2px; }
  .print-head .ph-date { flex: none; align-self: flex-start; font-size: 11px; color: #787774; text-align: right; padding-top: 2px; }

  /* Layout em folha */
  .section-title { break-after: avoid; page-break-after: avoid; margin-top: 22px; }
  .card, .report-hero, .ref-snap, .parecer-card, .kpi { break-inside: avoid; page-break-inside: avoid; box-shadow: none !important; }
  table, tr, td, th { break-inside: avoid; }
  thead { display: table-header-group; }
  .report-hero { border: 1px solid #e3e3e0; }
  .archive-list { break-inside: avoid; }
  a[href]::after { content: ""; }
}
