:root {
  --pri: #f26b1d;
  --pri-d: #d4570f;
  --pri-l: #fff1e8;
  --ink: #1f2a37;
  --ink-2: #4b5563;
  --mute: #8a94a3;
  --line: #e5e8ec;
  --bg: #f3f4f6;
  --card: #ffffff;
  --ok: #16a34a;
  --ok-l: #e8f7ee;
  --warn: #d97706;
  --warn-l: #fef4e2;
  --bad: #dc2626;
  --bad-l: #fdecec;
  --info: #2563eb;
  --info-l: #eaf1fe;
  --r: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  max-width: 560px; margin: 0 auto; min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex: none; display: block; }
[hidden] { display: none !important; }

/* ---------- Header ---------- */
#hdr {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: var(--ink); color: #fff;
}
.hdr-t { flex: 1; min-width: 0; padding-left: 4px; }
#hdr-title { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hdr-sub { color: #b8c0cc; font-size: 12px; display: block; }
#hdr-sub:empty { display: none; }
#hdr .icon-btn { color: #fff; }
#hdr-act { display: flex; gap: 4px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; background: transparent; border-radius: 10px; cursor: pointer; font-size: 18px;
}
.icon-btn:active { background: rgba(127, 127, 127, .18); }

/* ---------- View ---------- */
#view { padding: 14px 14px 90px; outline: none; }
.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-2); margin: 20px 2px 8px;
}
.section-title a { color: var(--pri-d); text-transform: none; letter-spacing: 0; font-weight: 600; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.right { text-align: right; }
.strong { font-weight: 700; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* ---------- Cards / listas ---------- */
.card {
  background: var(--card); border-radius: var(--r); padding: 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06); border: 1px solid var(--line);
}
.card + .card { margin-top: 10px; }
.list { background: var(--card); border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-bottom: 1px solid var(--line); cursor: pointer; background: var(--card);
}
.item:last-child { border-bottom: 0; }
.item:active { background: #f8f9fa; }
.item .t { font-weight: 600; }
.item .s { font-size: 13px; color: var(--mute); }
.item .body { flex: 1; min-width: 0; }
.item .body > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .v { text-align: right; font-weight: 700; white-space: nowrap; }
.item > .ic:last-child { color: var(--mute); }
.av {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none;
  background: var(--pri-l); color: var(--pri-d); font-weight: 700;
}
.av.ok { background: var(--ok-l); color: var(--ok); }
.av.bad { background: var(--bad-l); color: var(--bad); }
.av.info { background: var(--info-l); color: var(--info); }
.av.warn { background: var(--warn-l); color: var(--warn); }

/* ---------- KPIs e grade de módulos ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi small { color: var(--mute); font-size: 12px; display: block; }
.kpi b { font-size: 19px; display: block; margin-top: 2px; }
.kpi.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi.dark small { color: #b8c0cc; }

.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tile .ic { color: var(--pri); }
.tile:active { transform: scale(.97); }

.hero {
  background: linear-gradient(135deg, var(--pri) 0%, #f59042 100%); color: #fff;
  border-radius: var(--r); padding: 16px; display: flex; gap: 14px; align-items: center; cursor: pointer;
}
.hero h3 { font-size: 17px; }
.hero p { font-size: 13px; opacity: .92; }
.hero .ic { opacity: .95; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 -14px 12px; padding: 0 14px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 8px 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.tab.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Chips e barras ---------- */
.chip {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: #eef0f3; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em;
}
.chip.ok { background: var(--ok-l); color: var(--ok); }
.chip.warn { background: var(--warn-l); color: var(--warn); }
.chip.bad { background: var(--bad-l); color: var(--bad); }
.chip.info { background: var(--info-l); color: var(--info); }
.chip.pri { background: var(--pri-l); color: var(--pri-d); }
.bar { height: 8px; background: #eceef1; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pri); border-radius: 99px; transition: width .3s; }
.bar.ok i { background: var(--ok); }
.bar.bad i { background: var(--bad); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; background: #eceef1; color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--pri); color: #fff; }
.btn.dark { background: var(--ink); color: #fff; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger-t { color: var(--bad); }
.btn.whats { background: #25d366; color: #fff; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; }

.fab {
  position: fixed; z-index: 15; width: 58px; height: 58px; border-radius: 18px; border: 0;
  right: max(16px, calc(50% - 280px + 16px)); bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  background: var(--pri); color: #fff; display: grid; place-items: center; cursor: pointer;
  box-shadow: 0 6px 18px rgba(242, 107, 29, .45);
}

/* ---------- Formulários ---------- */
.form { display: flex; flex-wrap: wrap; gap: 12px 10px; }
.field { display: flex; flex-direction: column; gap: 5px; width: 100%; }
.field.half { width: calc(50% - 5px); }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--mute); font-size: 12px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 11px;
  border: 1px solid #d5dae1; background: #fff; font-size: 16px; /* 16px evita zoom no iOS */
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri); outline-offset: -1px; border-color: var(--pri); }
.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; min-height: 0; accent-color: var(--pri); }
.form .row { width: 100%; }

.search { position: relative; margin-bottom: 12px; }
.search input { padding-left: 14px; }

/* ---------- Sheet ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 50; background: rgba(15, 20, 28, 0);
  display: flex; align-items: flex-end; justify-content: center; transition: background .25s;
}
.sheet-wrap.open { background: rgba(15, 20, 28, .5); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; background: var(--bg); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .25s ease-out;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-grip { width: 40px; height: 5px; border-radius: 9px; background: #cdd2d9; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 6px 16px; }
.sheet-head h3 { font-size: 17px; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(20px + var(--safe-b)); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 20px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600;
  max-width: 90vw; text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Navegação inferior ---------- */
#nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 30;
  width: 100%; max-width: 560px; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #fff; border-top: 1px solid var(--line);
}
#nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--mute);
}
#nav a.on { color: var(--pri-d); }
#nav .nav-cta span {
  width: 46px; height: 46px; margin-top: -22px; border-radius: 16px; display: grid; place-items: center;
  background: var(--pri); color: #fff; box-shadow: 0 4px 12px rgba(242, 107, 29, .4);
}
#nav .nav-cta.on { color: var(--pri-d); }

/* ---------- Resultados de calculadora ---------- */
.result { background: var(--ink); color: #fff; border-radius: var(--r); padding: 16px; }
.result .big { font-size: 30px; font-weight: 800; }
.result .grid2 { margin-top: 12px; }
.result .grid2 > div { background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 10px; }
.result small { color: #b8c0cc; display: block; font-size: 12px; }
.result b { font-size: 17px; }

.qty { display: flex; align-items: center; gap: 6px; }
.qty input { width: 80px; min-height: 38px; text-align: center; padding: 6px; }
.qty button { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 18px; cursor: pointer; }

.empty { text-align: center; padding: 36px 20px; color: var(--mute); }
.empty .ic { margin: 0 auto 10px; opacity: .6; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { font-size: 12px; color: var(--mute); text-transform: uppercase; }
.table .n { text-align: right; white-space: nowrap; }

.contrato-txt { white-space: pre-wrap; font-family: Georgia, serif; font-size: 14px; line-height: 1.6; }

/* ---------- Fase 1: leitura fácil, ações grandes ---------- */
body { font-size: 16px; }
.item .t { font-size: 16px; }
.field > span { font-size: 14px; }
#nav a { font-size: 12px; }
.btn-grande { min-height: 56px; font-size: 17px; border-radius: 14px; }
/* nome da obra encolhe com "..." e a etiqueta de situação nunca é cortada */
.item .body > .row { overflow: visible; }
.item .body > .row .t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { flex: none; white-space: nowrap; }

.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acao {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  min-height: 124px; padding: 16px; border: 0; border-radius: 18px; cursor: pointer;
  color: #fff; font-size: 20px; font-weight: 800; text-align: left; line-height: 1.15;
}
.acao small { display: block; font-size: 13px; font-weight: 500; opacity: .92; margin-top: 4px; }
.acao:active { transform: scale(.97); }
.acao.gastei { background: #dc2626; }
.acao.recebi { background: #16a34a; }
.acao.orcar { background: var(--ink); }
.acao.pedir { background: var(--pri); }

.with-mic { display: flex; gap: 6px; width: 100%; }
.with-mic > input, .with-mic > textarea { flex: 1; min-width: 0; }
.mic {
  flex: none; width: 48px; min-height: 46px; border-radius: 11px; border: 1px solid #d5dae1;
  background: #fff; color: var(--pri-d); display: grid; place-items: center; cursor: pointer;
}
.mic.ouvindo { background: var(--bad); border-color: var(--bad); color: #fff; animation: pulso 1s infinite; }
@keyframes pulso { 50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, .22); } }

.pergunta { display: block; font-size: 17px; font-weight: 800; color: var(--ink); margin: 18px 0 8px; }
.pergunta:first-child { margin-top: 4px; }
.pergunta small { font-weight: 500; }
.valor-grande input { font-size: 30px; font-weight: 800; min-height: 64px; }
.valor-grande .mic { min-height: 64px; }

.escolha { display: flex; flex-wrap: wrap; gap: 8px; }
.escolha button {
  min-height: 46px; padding: 0 16px; border-radius: 999px; border: 1.5px solid #d5dae1;
  background: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
}
.escolha button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.foto-btns { display: flex; gap: 8px; }
.foto-btns .btn { flex: 1; }
.thumb { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.foto-full {
  position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .92);
  display: grid; place-items: center; padding: 16px;
}
.foto-full img { max-width: 100%; max-height: 90dvh; border-radius: 8px; }
.foto-full .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; }

details.mais { width: 100%; margin-top: 8px; }
details.mais > summary { cursor: pointer; font-weight: 700; color: var(--pri-d); padding: 12px 0; list-style: none; }
details.mais > summary::before { content: '＋ '; }
details.mais[open] > summary::before { content: '－ '; }
details.mais > .form { padding-top: 4px; }

.ajuda { display: flex; align-items: center; gap: 12px; background: #e9f9ef; border: 1px solid #bfe9cf; color: #146c35; }
.ajuda b { color: #0f5a2b; }

/* ---------- Impressão ---------- */
#print-area { display: none; }
@media print {
  body { max-width: none; padding: 0; background: #fff; }
  #hdr, #view, #nav, .fab, .sheet-wrap, .toast { display: none !important; }
  #print-area { display: block; }
  .doc { font: 12pt/1.5 Georgia, serif; color: #000; padding: 10mm; }
  .doc h1 { font-size: 18pt; margin-bottom: 12px; }
  .doc .table td, .doc .table th { border-color: #999; }
}
