/* Gerador de propostas Saara: a ferramenta (barra, editor, lista, catálogo).
   Cores e fontes do Brand Book: papel #F4F4F4, areia #DCBFA5, petróleo #2E4F65,
   laranja #E25220, chumbo #1E1E1E. Nexa → Poppins, Gotham → Montserrat. */
:root {
  --paper: #F4F4F4;
  --white: #FFFFFF;
  --ember: #E25220;
  --ember-2: #C6431A;
  --blue: #2E4F65;
  --sand: #DCBFA5;
  --sand-2: #F3EAE1;
  --ink: #1E1E1E;
  --ink-2: #4A4744;
  --ink-3: #7A746D;
  --line: rgba(30, 30, 30, .12);
  --line-2: rgba(30, 30, 30, .07);
  --font-display: 'Poppins', system-ui, sans-serif;
  --font-text: 'Montserrat', system-ui, sans-serif;
  --bar-h: 64px;
  --radius: 12px;
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { height: 100%; }
body { min-height: 100%; }
body { font-family: var(--font-text); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

/* ---------- barra ---------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  height: var(--bar-h); display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.25rem; background: var(--white); border-bottom: 1px solid var(--line);
}
.bar__brand { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.bar__brand img { height: 24px; width: auto; }
.bar__brand span { font-family: var(--font-display); font-weight: 500; font-size: .875rem; color: var(--ink-3); padding-left: .75rem; border-left: 1px solid var(--line); }
.bar__tabs { display: flex; gap: .25rem; }
.bar__tabs button { border: 0; background: none; padding: .55rem .9rem; border-radius: 999px; font-weight: 600; font-size: .8125rem; color: var(--ink-2); min-height: 40px; }
.bar__tabs button:hover { background: var(--paper); }
.bar__tabs button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.bar__actions { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.salvo { font-size: .75rem; color: var(--ink-3); white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .55rem 1.1rem; border-radius: 999px; border: 1px solid var(--ember);
  background: var(--ember); color: var(--white); font-weight: 600; font-size: .8125rem; white-space: nowrap;
  transition: background .2s ease, border-color .2s ease;
}
.btn:hover { background: var(--ember-2); border-color: var(--ember-2); }
.btn--ghost { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: var(--paper); border-color: var(--ink-3); }
.btn--perigo { background: var(--white); color: #B42318; border-color: rgba(180, 35, 24, .3); }
.btn--perigo:hover { background: #FEF3F2; border-color: #B42318; }

/* ---------- tela da proposta ---------- */
.tela--editor { display: grid; grid-template-columns: minmax(360px, 460px) minmax(0, 1fr); height: calc(100vh - var(--bar-h)); }
.editor { background: var(--white); border-right: 1px solid var(--line); min-height: 0; }
.editor__scroll { height: 100%; overflow-y: auto; padding: .75rem 1rem 2rem; }
.preview { min-height: 0; overflow: auto; padding: 32px; background: #E7E5E2; }
.preview__zoom { zoom: var(--zoom, .7); width: 210mm; margin: 0 auto; display: grid; gap: 14mm; }

/* seções do editor */
.sec { border-bottom: 1px solid var(--line-2); }
.sec > summary {
  list-style: none; cursor: pointer; display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: 1rem .25rem; min-height: 52px;
}
.sec > summary::-webkit-details-marker { display: none; }
.sec__t { font-family: var(--font-display); font-weight: 600; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.sec__t::before { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform .2s ease; margin-right: .15rem; }
.sec[open] .sec__t::before { transform: rotate(45deg); }
.sec__r { font-size: .75rem; color: var(--ink-3); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; }
.sec__c { padding: 0 .25rem 1.25rem; display: grid; gap: .85rem; }

/* campos */
.f { display: grid; gap: .3rem; min-width: 0; }
.f__r { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.f small { font-size: .75rem; color: var(--ink-3); }
.f input, .f select, .f textarea, .busca, .cat__row input, .cat__row select {
  width: 100%; min-height: 40px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); transition: border-color .15s ease, box-shadow .15s ease;
}
.f textarea { resize: vertical; line-height: 1.5; min-height: 64px; }
.f input:hover, .f select:hover, .f textarea:hover { border-color: rgba(30, 30, 30, .25); }
.f input:focus, .f select:focus, .f textarea:focus, .busca:focus, .cat__row input:focus, .cat__row select:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(226, 82, 32, .15); }
.money { position: relative; }
.money span { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); font-size: .8125rem; color: var(--ink-3); pointer-events: none; }
.money input { padding-left: 2.1rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.grid3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) minmax(0, 1fr); gap: .6rem; }
.span2 { grid-column: 1 / -1; }
.linha { display: flex; gap: .5rem; align-items: end; }
.grow { flex: 1; }
.x { width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 1.1rem; color: var(--ink-3); }
.x:hover { color: #B42318; border-color: #B42318; }

.chk, .toggle { display: flex; align-items: center; gap: .6rem; min-height: 36px; cursor: pointer; }
.chk input, .toggle input, .svc__chk input { width: 18px; height: 18px; accent-color: var(--ember); flex-shrink: 0; }
.chk em { font-style: normal; color: var(--ink-3); font-size: .8125rem; margin-left: .25rem; }
.toggle { background: var(--sand-2); border-radius: var(--radius); padding: .75rem .9rem; font-weight: 600; }

/* serviços */
.frente { display: grid; gap: .35rem; }
.frente + .frente { margin-top: .6rem; }
.frente__cab { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.frente__cab b { font-family: var(--font-display); font-weight: 600; font-size: .8125rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ember); }
.pill { font-size: .6875rem; font-weight: 700; background: var(--ember); color: var(--white); border-radius: 999px; padding: 0 .45rem; line-height: 1.5; }
.svc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); transition: border-color .15s ease, background .15s ease; }
.svc:hover { border-color: rgba(30, 30, 30, .25); }
.svc.is-on { border-color: rgba(226, 82, 32, .45); background: #FFFBF8; }
.svc__chk { display: flex; align-items: center; gap: .65rem; padding: .6rem .8rem; min-height: 44px; cursor: pointer; }
.svc__chk span { font-weight: 600; flex: 1; }
.svc__chk em { font-style: normal; font-size: .75rem; color: var(--ink-3); white-space: nowrap; }
.svc__edit { padding: .2rem .8rem .85rem; display: grid; gap: .7rem; }
.svc > .svc__edit:first-child { padding-top: .8rem; }
.sub > summary { cursor: pointer; font-size: .8125rem; font-weight: 600; color: var(--blue); padding: .2rem 0; list-style: none; }
.sub > summary::-webkit-details-marker { display: none; }
.sub > summary::before { content: '+ '; }
.sub[open] > summary::before { content: '− '; }
.sub[open] { display: grid; gap: .7rem; }
.add { justify-self: start; border: 1px dashed rgba(30, 30, 30, .3); background: none; border-radius: 999px; padding: .5rem 1rem; font-weight: 600; font-size: .8125rem; color: var(--ink-2); min-height: 40px; }
.add:hover { border-color: var(--ember); color: var(--ember); }

/* sistema */
.mods { display: grid; gap: .6rem; }
.mod { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; display: grid; gap: .6rem; background: var(--white); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.chips > span { font-size: .75rem; color: var(--ink-3); margin-right: .15rem; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: .3rem .7rem; font-size: .75rem; font-weight: 600; min-height: 32px; }
.chip:hover { border-color: var(--ember); color: var(--ember); }

/* investimento */
.resumo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .6rem; }
.resumo div { background: var(--blue); color: var(--white); border-radius: var(--radius); padding: .8rem .9rem; display: grid; gap: .1rem; }
.resumo span { font-size: .75rem; opacity: .8; }
.resumo b { font-family: var(--font-display); font-size: 1.125rem; font-weight: 600; }
.resumo small { font-size: .75rem; opacity: .85; }
.aviso { font-size: .8125rem; color: #93370D; background: #FFFAEB; border: 1px solid #FEDF89; border-radius: 8px; padding: .55rem .75rem; }

.editor__pe { display: flex; flex-wrap: wrap; gap: .5rem; padding: 1.25rem .25rem 0; }

/* ---------- telas de lista e catálogo ---------- */
.tela--lista, .tela--catalogo { min-height: calc(100vh - var(--bar-h)); }
.painel { max-width: 1000px; margin: 0 auto; padding: 2.5rem 1.25rem 4rem; display: grid; gap: 1.25rem; }
.painel__cab { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; }
.painel h1 { font-family: var(--font-display); font-weight: 700; font-size: 1.75rem; letter-spacing: -.02em; }
.nota { color: var(--ink-3); max-width: 60ch; margin-top: .25rem; }
.painel__acoes { display: flex; gap: .5rem; }
.painel__acoes label.btn { cursor: pointer; }
.busca { max-width: 420px; }
.lista { list-style: none; padding: 0; display: grid; gap: .6rem; }
.lista__vazia { color: var(--ink-3); padding: 2rem 0; }
.card { display: flex; align-items: center; gap: 1rem; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .6rem .4rem .4rem; }
.card.is-atual { border-color: rgba(226, 82, 32, .5); }
.card__abrir { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; align-items: baseline; text-align: left; border: 0; background: none; padding: .7rem .8rem; border-radius: 8px; }
.card__abrir:hover { background: var(--paper); }
.card__num { grid-row: span 2; font-family: var(--font-display); font-weight: 600; font-size: .8125rem; color: var(--ember); }
.card__abrir b { font-family: var(--font-display); font-weight: 600; font-size: 1rem; }
.card__abrir b i { font-style: normal; font-weight: 500; color: var(--ink-3); }
.card__meta { font-size: .8125rem; color: var(--ink-3); }
.card__acoes { display: flex; gap: .25rem; }
.card__acoes button { border: 0; background: none; font-size: .8125rem; font-weight: 600; color: var(--ink-2); padding: .5rem .6rem; border-radius: 8px; min-height: 40px; }
.card__acoes button:hover { background: var(--paper); }
.card__acoes .perigo { color: #B42318; }

.cat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; display: grid; gap: .75rem; }
.cat h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.125rem; }
.cat__tab { display: grid; gap: .4rem; }
.cat__row { display: grid; grid-template-columns: minmax(0, 1.6fr) 150px 170px 150px; gap: .6rem; align-items: center; }
.cat__row--cab span { font-size: .75rem; font-weight: 600; color: var(--ink-3); }
.cat__nome { font-weight: 600; }

.toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--white); padding: .7rem 1.1rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.18); }

/* ---------- telas menores ---------- */
@media screen and (max-width: 1000px) {
  .tela--editor { grid-template-columns: minmax(0, 1fr); height: auto; }
  .editor, .preview { min-width: 0; }
  .editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .editor__scroll { height: auto; overflow: visible; }
  .preview { padding: 16px; }
  .bar { gap: .75rem; overflow-x: auto; }
  .bar__brand span, .salvo { display: none; }
  .cat__row { grid-template-columns: 1fr 1fr; }
  .cat__row--cab { display: none; }
  .cat__nome { grid-column: 1 / -1; }
}

/* ---------- rascunho ---------- */
.status { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .85rem .25rem 1rem; border-bottom: 1px solid var(--line-2); }
.status__r { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.status small { flex-basis: 100%; font-size: .75rem; color: var(--ink-3); }
.seg { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; border-radius: 999px; padding: .4rem .9rem; font-size: .8125rem; font-weight: 600; color: var(--ink-2); min-height: 34px; }
.seg button[aria-pressed="true"][data-v="rascunho"] { background: var(--sand); color: var(--ink); }
.seg button[aria-pressed="true"][data-v="finalizada"] { background: #127A4B; color: #fff; }
.filtros-linha { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between; }
.filtros { display: flex; gap: .35rem; }
.filtros button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: .45rem .9rem; font-weight: 600; font-size: .8125rem; min-height: 38px; }
.filtros button span { color: var(--ink-3); font-weight: 500; margin-left: .15rem; }
.filtros button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.filtros button[aria-pressed="true"] span { color: rgba(255,255,255,.7); }
.tag { display: block; font-style: normal; font-size: .6875rem; font-weight: 700; border-radius: 999px; padding: .1rem .5rem; margin-top: .3rem; text-align: center; }
.tag--rasc { background: var(--sand-2); color: #8A5A2B; }
.tag--ok { background: #E7F6EE; color: #127A4B; }
.card__acoes .continuar { color: var(--ember); }

/* ---------- módulos do serviço (páginas, integrações) ---------- */
.smods { display: grid; gap: .8rem; padding: .8rem; background: var(--paper); border-radius: 10px; }
.smods__t { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.smods__g { display: grid; gap: .4rem; }
.smods__g + .smods__g { padding-top: .7rem; border-top: 1px solid var(--line-2); }
.smods__g > b { font-family: var(--font-display); font-size: .75rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.smod { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem; background: var(--white); border: 1px solid var(--line); border-left: 3px solid var(--ember); border-radius: 8px; padding: .35rem .35rem .35rem .5rem; }
.smod input { width: 100%; min-height: 30px; padding: .25rem .4rem; border: 1px solid transparent; border-radius: 6px; background: none; font-size: .8125rem; }
.smod input:hover { border-color: var(--line); }
.smod input:focus { outline: none; border-color: var(--ember); background: var(--white); box-shadow: 0 0 0 3px rgba(226, 82, 32, .15); }
.smod__n { font-weight: 600; }
.smod__d { grid-column: 1 / -1; color: var(--ink-2); margin-top: -.3rem; }
.x--sm { width: 30px; height: 30px; font-size: 1rem; border-color: transparent; }
.chip--novo { border-style: dashed; background: var(--white); }

/* ---------- proposta com PDF gerado (travada) ---------- */
.campos { border: 0; padding: 0; margin: 0; min-width: 0; }
.campos:disabled .f input, .campos:disabled .f select, .campos:disabled .f textarea,
.campos:disabled .smod input { background: var(--paper); color: var(--ink-2); cursor: not-allowed; }
.campos:disabled .chip, .campos:disabled .add, .campos:disabled .x, .campos:disabled .svc__chk { opacity: .5; cursor: not-allowed; }
.status--travada { display: grid; gap: .75rem; background: #EAF0F3; border: 1px solid rgba(46,79,101,.25); border-radius: var(--radius); padding: .9rem 1rem; margin: .75rem 0 .5rem; }
.status--travada b { font-family: var(--font-display); font-weight: 600; color: var(--blue); display: block; }
.status--travada small { color: var(--ink-2); font-size: .8125rem; flex-basis: auto; }
.status__acoes { display: flex; flex-wrap: wrap; gap: .5rem; }
.tag--pdf { background: #EAF0F3; color: var(--blue); }

/* ---------- combinados (editor) ---------- */
.nota-sec { font-size: .8125rem; color: var(--ink-3); }
.termo { display: grid; gap: .4rem; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.termo.is-off { background: var(--paper); }
.termo.is-off .chk span { color: var(--ink-3); }
.termo .chk em { display: block; margin-left: 0; font-size: .75rem; }

/* ---------- celular ---------- */
.vista-mob { display: none; }
@media screen and (max-width: 1000px) {
  .vista-mob { display: flex; position: sticky; top: var(--bar-real, 0); z-index: 15; gap: .35rem; padding: .6rem 1rem; background: var(--white); border-bottom: 1px solid var(--line); }
  .vista-mob button { flex: 1; min-height: 40px; border: 1px solid var(--line); background: var(--white); border-radius: 999px; font-weight: 600; font-size: .8125rem; }
  .vista-mob button[aria-pressed="true"] { background: var(--ink); color: var(--white); border-color: var(--ink); }
  body.ver-previa .editor { display: none; }
  body:not(.ver-previa) .preview { display: none; }
  .preview { min-height: calc(100vh - 120px); }
}
@media screen and (max-width: 700px) {
  body { font-size: 15px; }
  .bar { flex-wrap: wrap; height: auto; padding: .6rem 1rem .5rem; gap: .5rem; overflow: visible; }
  .bar__brand { order: 1; }
  .bar__brand img { height: 22px; }
  .bar__actions { order: 2; margin-left: auto; gap: .4rem; }
  .bar__actions [data-acao="nova"] { display: none; }
  .bar__actions .btn { padding: .5rem .9rem; }
  .bar__tabs { order: 3; width: 100%; overflow-x: auto; }
  .bar__tabs button { flex: 1; white-space: nowrap; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .grid3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid3 > :first-child { grid-column: 1 / -1; }
  .editor__scroll { padding: .5rem 1rem 2rem; }
  .sec__r { max-width: 45%; }
  .painel { padding: 1.5rem 1rem 3rem; }
  .painel h1 { font-size: 1.5rem; }
  .painel__acoes { width: 100%; }
  .painel__acoes > * { flex: 1; }
  .filtros { width: 100%; overflow-x: auto; }
  .busca { max-width: none; }
  .card { flex-wrap: wrap; padding: .4rem; }
  .card__abrir { flex-basis: 100%; }
  .card__acoes { width: 100%; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line-2); padding-top: .25rem; }
  .status--travada .status__acoes .btn { flex: 1; }
  .toast { left: 1rem; right: 1rem; transform: none; text-align: center; border-radius: 14px; }
  .cat__row:not(.cat__row--cab) { padding-bottom: .75rem; border-bottom: 1px solid var(--line-2); }
  .cat__row:last-child { border-bottom: 0; padding-bottom: 0; }
}

/* Medição dos títulos com a prévia escondida (celular): fora da tela, invisível. */
body.medindo .preview { display: block !important; position: absolute !important; left: -10000px; top: 0; width: 1000px; visibility: hidden; }

/* ---------- catálogo: serviços criados ---------- */
.painel__acoes { flex-wrap: wrap; }
.cat--form { border-color: rgba(226, 82, 32, .45); box-shadow: 0 8px 24px rgba(30, 30, 30, .06); }
.cat--form .f textarea { min-height: 88px; }
.cat__acoes { display: flex; gap: .5rem; }
.cat__meu { display: inline-block; font-size: .6875rem; font-weight: 700; color: var(--ember); background: #FDEEE8; border-radius: 999px; padding: .05rem .5rem; margin-left: .35rem; vertical-align: middle; }
.cat__links { display: flex; gap: .75rem; margin-top: .2rem; }
.cat__links button { border: 0; background: none; padding: .2rem 0; font-size: .75rem; font-weight: 600; color: var(--blue); min-height: 28px; }
.cat__links button:hover { text-decoration: underline; }
.cat__links .perigo { color: #B42318; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
