* { box-sizing: border-box; }
body { margin: 0; background: #f4f6f4; color: #22332b; font: 15px/1.45 system-ui, -apple-system, 'Segoe UI', sans-serif; }
header { background: #183c2d; color: white; padding: 14px 5%; display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; }
header b { font-size: 22px; }
header span { opacity: .75; }
main { max-width: 1500px; margin: auto; padding: 20px; }
h1, h2, h3 { margin-top: 0; }
h1 { font-size: 24px; }
code { background: #eef3ef; padding: 1px 4px; border-radius: 4px; }

/* Formulários: 16px evita o zoom automático do iPhone ao tocar no campo */
button, input, textarea, select { font: inherit; font-size: 16px; }
button { border: 0; border-radius: 8px; padding: 10px 14px; min-height: 44px; background: #236348; color: white; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: #e4ece5; color: #204333; }
button.small { min-height: 36px; padding: 6px 10px; font-size: 14px; margin-top: 6px; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #8fc27f; outline-offset: 2px; }
input, textarea, select { width: 100%; border: 1px solid #c5d1c8; border-radius: 6px; padding: 10px; background: white; color: inherit; }
input[type=color] { height: 44px; padding: 4px; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; margin: 10px 0 5px; font-weight: 600; }

.panel { background: white; border: 1px solid #dce4dd; border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.narrow { max-width: 650px; margin-left: auto; margin-right: auto; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.workspace { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.workspace.projection { grid-template-columns: 1fr; }
.muted { color: #5d6e64; font-size: 13px; }
.entry { border-top: 1px solid #dce4dd; padding: 10px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.entry.row { display: flex; gap: 10px; align-items: center; white-space: normal; }
.alert { background: #fff1c9; color: #5a4100; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.badge { background: #e4ece5; color: #204333; border-radius: 99px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.badge.phase-review { background: #fff1c9; color: #6b4e00; }
.badge.phase-approved { background: #d4ecd0; color: #1d4d1f; }
#conn { background: #fde0dc; color: #8a1f11; }
#saveState[data-kind=warn] { color: #8a5a00; font-weight: 600; }
#saveState[data-kind=ok] { color: #236348; }
summary { cursor: pointer; font-weight: bold; padding: 10px 0; }
#qr { background: white; padding: 10px; width: max-content; }
#notice { position: fixed; bottom: 15px; right: 15px; left: auto; max-width: min(520px, calc(100% - 30px)); background: #183c2d; color: white; border-radius: 8px; padding: 12px 14px; display: none; z-index: 10; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

/* ---------- Prévia do PRI (espelha referencia-pri.png) ---------- */
.preview-wrap { overflow-x: auto; }
.preview { --brand: #397523; --on-brand: #fff; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-template-rows: auto minmax(220px, auto) auto auto; gap: 1px; background: #89ad7d; border: 1px solid #819e78; min-width: 760px; }
.preview .heading { grid-column: 1 / -1; background: var(--brand); color: var(--on-brand, #fff); padding: 10px 14px; display: flex; gap: 16px; align-items: center; }
.heading .title { flex: 1; display: flex; flex-direction: column; }
.heading .title strong { font-size: 30px; line-height: 1; }
.heading .title span { font-weight: 700; font-size: 14px; }
.heading .info { display: grid; grid-template-columns: auto minmax(120px, auto); gap: 4px 6px; font-size: 12px; }
.heading .lbl, .heading .val { background: white; color: #22332b; border-radius: 4px; padding: 2px 8px; text-align: center; }
.heading img { max-width: 110px; max-height: 52px; background: white; object-fit: contain; border-radius: 4px; padding: 2px; }
.cell { background: #fff; padding: 9px 10px; min-width: 0; overflow-wrap: anywhere; font-size: 12px; white-space: pre-wrap; }
.cell b { display: block; margin-bottom: 7px; color: #162d21; white-space: normal; }
.cell ul { margin: 0; padding-left: 16px; white-space: normal; text-align: justify; }
.cell li { margin-bottom: 2px; }
.cell .empty { color: #9aa9a0; }
.cell.inputs, .cell.deliverables, .cell.technology, .cell.mission { background: #e1eddf; }
.suppliers { grid-column: 1; grid-row: 2; }
.inputs { grid-column: 2; grid-row: 2; }
.roles { grid-column: 3 / 5; grid-row: 2 / 5; }
.deliverables { grid-column: 5; grid-row: 2; }
.customers { grid-column: 6; grid-row: 2; }
.team { grid-column: 1 / 3; grid-row: 3; }
.technology { grid-column: 1 / 3; grid-row: 4; }
.indicators { grid-column: 5 / 7; grid-row: 3; }
.mission { grid-column: 5 / 7; grid-row: 4; }

@media (max-width: 900px) {
  main { padding: 12px; }
  .panel { padding: 16px; }
  .workspace, .grid { grid-template-columns: 1fr; }
  .toolbar button { flex: 1 1 auto; }
}

/* ---------- Impressão / PDF: A4 paisagem ---------- */
@page { size: A4 landscape; margin: 8mm; }
@media print {
  body { background: white; }
  header, #notice, .no-print { display: none !important; }
  main, .workspace, .panel, .preview-wrap { display: block; margin: 0; padding: 0; border: 0; overflow: visible; max-width: none; }
  .preview .heading { color: var(--on-brand, #fff); }
  .preview { min-width: 0; width: 100%; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .cell { font-size: 8.5pt; break-inside: avoid; }
}
